What is the time complexity of accessing an element in an array?
- O(1)
- O(n)
- O(log n)
- O(n log n)
Option 1, O(1), represents constant time complexity. Accessing an element in an array by its index takes the same amount of time, regardless of the array size. Hence, it is independent of the array's size, resulting in constant time complexity.
Loading...
Related Quiz
- The "A" in ACID properties guarantees that database transactions are ___________.
- Thread creation is less expensive than ___________ creation.
- The method used by wireless access points to allocate available bandwidth among connected devices is called _________.
- In a large enterprise network, you're tasked with implementing VLANs (Virtual Local Area Networks) to segment the network. How would you use TCP/IP protocols to ensure proper communication between VLANs while maintaining security?
- The ___________ file in Node.js contains configuration settings for a Node.js application.