โ† Back to Games

๐Ÿ‘‘ Constant Kingdom

Master O(1) constant time operations - input size doesn't matter!

๐Ÿ“Š Array Visualization
array[10] =
N=10
Array Size
โ†’
O(1)
Operation Time
โ†’
1
Steps
โšก O(1) Operations
๐Ÿ“
Array Access
arr[i]
๐Ÿ”„
Swap Elements
a โ†” b
โž•
Arithmetic
+, -, ร—, รท
๐Ÿ“
Assignment
x = value
โš–๏ธ
Comparison
a == b
๐Ÿ“ค
Push/Pop
Stack ops

๐Ÿ“š Why O(1) is Constant Time

O(1) operations take the same amount of time regardless of input size. Whether your array has 10 elements or 10 million elements, accessing arr[5] always takes 1 step!

Key insight: Arrays store elements in contiguous memory. The computer can calculate the exact memory address using: base_address + (index ร— element_size)

Demo
Quiz
Is this operation O(1) or O(N)?
// Loading...
O(1)
O(N)
๐Ÿ“Š Statistics
0
Operations
0
Quiz Score
Access
Current Op
0
Streak