Arrays — Concept Check
Questions on Arrays. The most fundamental data structure. Understand indexing, traversal, and the two-pointer technique used in 90% of array interview problems.
Questions in this quiz
8 questions on Arrays — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.You have an unsorted array of integers and need to find if a specific number exists in it. What is the time complexity of this operation?
- AO(1)
- BO(n)
- CO(log n)
- DO(n^2)
2.A developer needs to insert an element at the beginning of a large array. What is the time complexity of this operation?
- AO(n log n)
- BO(n)
- CO(1)
- DO(log n)
3.An array stores elements in contiguous memory locations. What is the benefit of this arrangement?
- AAllows O(1) random access by index
- BPrevents data corruption
- CReduces memory usage
- DIncreases insertion speed
4.You are given a sorted array and need to find a specific element using binary search. What is the time complexity?
- AO(n)
- BO(1)
- CO(n log n)
- DO(log n)
5.A developer mistakenly believes that inserting an element at the end of an array always takes O(n) time. Why is this incorrect?
- AInsertion at the end is O(1) always
- BInsertion at the end is O(n^2)
- CInsertion at the end is O(log n)
- DInsertion at the end is O(1) amortized
6.Imagine you need to delete an element from the middle of an array. What is the time complexity of this operation?
- AO(log n)
- BO(1)
- CO(n log n)
- DO(n)
7.A programmer claims that accessing any element of an array is O(n) because it involves scanning through elements. Why is this incorrect?
- AAccess is O(1) due to direct indexing
- BAccess is O(n log n) in sorted arrays
- CAccess is O(n^2) due to shifting
- DAccess is O(log n) using binary search
8.In Java, which data structure provides a dynamic resizable version of an array?
- AHashMap
- BVector
- CArrayList
- DLinkedList