Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Arrays & CollectionsEasy
Q1. What is a list in Python?
- A.A dictionary mapping keys to their associated values
- B.An immutable sequence that cannot be modified at all
- C.A fixed-size array of uniform typed elements
- D.An ordered mutable collection of any element types✓ Correct
Explanation
A Python list is an ordered, mutable collection that can store elements of any type and dynamically resize.
Report an error in this question
Arrays & CollectionsEasy
Q2. What is an array?
- A.A loop construct that iterates over data elements
- B.A collection of same-type elements in contiguous memory✓ Correct
- C.A reusable function that performs a specific task
- D.A single variable holding one data value
Explanation
An array stores a fixed-size collection of elements of the same type in contiguous memory locations.
Report an error in this question
Arrays & CollectionsEasy
Q3. What is an ArrayList in Java?
- A.A doubly linked list of elements
- B.A key-value pair mapping structure
- C.A fixed-size array that cannot change
- D.A dynamic array that grows and shrinks✓ Correct
Explanation
ArrayList is a resizable array implementation of the List interface that automatically manages its size.
Report an error in this question
Arrays & CollectionsEasy
Q4. What is the index of the first element in an array in C/Java?
- A.0✓ Correct
- B.-1
- C.2
- D.1
Explanation
In C and Java, array indexing starts at 0, so the first element is at index 0.
Report an error in this question
Arrays & CollectionsEasy
Q5. What happens when you access an array index out of bounds?
- A.It returns zero as the default value for any position
- B.It returns null as the default value for the position
- C.It throws an exception or causes undefined behavior✓ Correct
- D.It automatically resizes the array to fit the index
Explanation
Accessing an index outside the array's valid range causes an exception in managed languages or undefined behavior in C/C++.
Report an error in this question
Arrays & CollectionsEasy
Q6. What is a dictionary/map?
- A.An ordered array with indexed elements
- B.A list of words in alphabetical order
- C.A string type for storing text values
- D.A collection of key-value pair entries✓ Correct
Explanation
A dictionary/map stores data as key-value pairs, allowing efficient lookup by key.
Report an error in this question
Arrays & CollectionsMedium
Q7. What is the time complexity of accessing an element by index in an array?
- A.O(n^2)
- B.O(1)✓ Correct
- C.O(n)
- D.O(log n)
Explanation
Array access by index is O(1) because the memory address is calculated directly from the base address and index.
Report an error in this question
Arrays & CollectionsMedium
Q8. What is a tuple?
- A.A mutable list that can change its elements
- B.A key-value map for looking up data by key
- C.An immutable ordered collection of mixed types✓ Correct
- D.A sorted set that maintains element ordering
Explanation
A tuple is an immutable, ordered sequence of elements that can be of different types, used to group related values.
Report an error in this question
Arrays & CollectionsHard
Q9. What is a concurrent hash map?
- A.A hash map using multiple hash functions per key
- B.A thread-safe hash map without full map locking✓ Correct
- C.A distributed database across network nodes only
- D.A regular hash map with no special properties
Explanation
ConcurrentHashMap allows concurrent reads and partitioned writes without locking the entire structure.
Report an error in this question
Arrays & CollectionsHard
Q10. What is a lock-free data structure?
- A.An unprotected array that any thread can freely modify
- B.A concurrent structure using atomic operations not locks✓ Correct
- C.A structure with no synchronization protection at all
- D.A read-only data structure that cannot be changed ever
Explanation
Lock-free data structures use atomic operations (compare-and-swap) instead of locks, ensuring that at least one thread always makes progress.
Report an error in this question
Arrays & CollectionsEasy
Q11. What is the difference between an array and a linked list?
- A.Arrays can dynamically grow and shrink in size without any overhead
- B.Arrays use contiguous memory with O(1) access; linked lists use nodes✓ Correct
- C.They are functionally identical data structures with no differences
- D.Linked lists are always faster than arrays for every type of operation
Explanation
Arrays store elements contiguously enabling O(1) random access; linked lists use nodes connected by pointers enabling O(1) insertion/deletion but O(n) access.
Report an error in this question
Arrays & CollectionsMedium
Q12. What is a deque (double-ended queue)?
- A.A regular first-in first-out queue
- B.A queue allowing insertion at both ends✓ Correct
- C.A sorted list with binary search access
- D.A stack variant for ordered elements
Explanation
A deque supports insertion and removal of elements from both the front and the rear.
Report an error in this question
Arrays & CollectionsHard
Q13. What is a skip list?
- A.A filtered array that excludes elements matching a condition
- B.A probabilistic multi-layer linked list for O(log n) search✓ Correct
- C.A list that skips over certain elements during iteration
- D.A type of priority queue that maintains sorted element order
Explanation
A skip list uses multiple levels of forward pointers to skip over elements, providing O(log n) average search, insertion, and deletion.
Report an error in this question
Arrays & CollectionsHard
Q14. What is the difference between external and internal iterators?
- A.Internal iterators always consume more memory than external iterators
- B.External iterators are always faster than internal iterators in practice
- C.There is no meaningful difference between the two iterator types
- D.External iterators are client-controlled; internal are collection-controlled✓ Correct
Explanation
External iterators let the client control iteration; internal iterators let the collection control iteration by applying a function to each element.
Report an error in this question
Arrays & CollectionsHard
Q15. What is a disjoint set (union-find) data structure?
- A.A structure tracking element partitions with union and find✓ Correct
- B.A sorted set that maintains elements in order
- C.A hash set variant that uses separate chaining for entries
- D.A set that has no intersections with any other set at all
Explanation
Union-Find tracks elements partitioned into disjoint sets, supporting near O(1) union and find operations with path compression and union by rank.
Report an error in this question
Arrays & CollectionsMedium
Q16. What is the difference between a shallow copy and a deep copy of a collection?
- A.They are the same operation with identical results in every case
- B.Shallow copy shares element references; deep copy duplicates all✓ Correct
- C.Shallow copy is always slower than deep copy for all collections
- D.Deep copy shares references while shallow copy duplicates objects
Explanation
A shallow copy creates a new collection with references to the same objects; a deep copy recursively duplicates all nested objects.
Report an error in this question
Arrays & CollectionsHard
Q17. What is consistent hashing?
- A.A type of encryption used for securing sensitive data values
- B.A collision resolution method for hash table bucket overflow
- C.A hashing scheme that minimally redistributes keys on change✓ Correct
- D.Regular hashing with standard hash function methods
Explanation
Consistent hashing maps both keys and nodes onto a ring, so adding or removing a node only redistributes keys to/from adjacent nodes.
Report an error in this question
Arrays & CollectionsMedium
Q18. What is an iterator?
- A.An array index used for element access
- B.An object for traversing a collection sequentially✓ Correct
- C.A sorting algorithm for ordering collections
- D.A type of loop construct for repeating code
Explanation
An iterator provides a standard interface for traversing elements of a collection sequentially without exposing its internal structure.
Report an error in this question
Arrays & CollectionsEasy
Q19. What is a set in programming?
- A.A sorted array of ordered elements
- B.A specialized type of key-value map
- C.A collection with only unique elements✓ Correct
- D.An array that allows duplicate elements
Explanation
A set is a collection that contains no duplicate elements, useful for membership testing and removing duplicates.
Report an error in this question
Arrays & CollectionsMedium
Q20. What is a collision in a hash table?
- A.A runtime error in the hash function code
- B.When a requested key is not found in map
- C.When the hash table is completely full up
- D.When two keys hash to the same index slot✓ Correct
Explanation
A collision occurs when two different keys produce the same hash value, mapping to the same bucket.
Report an error in this question
Arrays & CollectionsHard
Q21. What is the amortized time complexity of adding an element to a dynamic array?
- A.O(1) amortized✓ Correct
- B.Always O(n)
- C.O(log n) each
- D.O(n log n) each
Explanation
While occasional resizing costs O(n), the cost is spread over many insertions, making the amortized cost O(1) per insertion.
Report an error in this question
Arrays & CollectionsEasy
Q22. What is a queue?
- A.A LIFO (Last-In First-Out) structure
- B.A sorted array with indexed elements
- C.A FIFO (First-In First-Out) structure✓ Correct
- D.A hierarchical tree data structure
Explanation
A queue is a FIFO data structure where the first element added is the first one removed.
Report an error in this question
Arrays & CollectionsHard
Q23. What is a bloom filter?
- A.A comparison-based sorting algorithm for arrays
- B.A space-efficient probabilistic set membership tester✓ Correct
- C.An image processing filter for visual enhancement
- D.A standard hash table with separate chaining buckets
Explanation
A bloom filter uses multiple hash functions and a bit array to test membership with possible false positives but no false negatives.
Report an error in this question
Arrays & CollectionsMedium
Q24. What is a priority queue?
- A.A sorted array with indexed element access only
- B.A queue where higher-priority elements dequeue first✓ Correct
- C.A stack with last-in first-out element ordering
- D.A regular first-in first-out queue structure
Explanation
A priority queue serves elements based on their priority rather than insertion order, typically implemented using a heap.
Report an error in this question
Arrays & CollectionsHard
Q25. What is a persistent data structure?
- A.An immutable structure that can never be accessed again
- B.A structure preserving previous versions on modification✓ Correct
- C.A relational database schema structure for queries
- D.A structure saved to persistent disk storage
Explanation
A persistent data structure retains all previous versions of itself when modified, enabling access to any historical state.
Report an error in this question
Arrays & CollectionsMedium
Q26. What is the difference between a singly linked list and a doubly linked list?
- A.Singly linked lists always use more memory than doubly linked
- B.There is no meaningful difference between the two list types
- C.Singly linked has next pointer; doubly linked has next and prev✓ Correct
- D.Doubly linked lists are always slower than singly linked lists
Explanation
A singly linked list node has a pointer to the next node; a doubly linked list node has pointers to both next and previous nodes.
Report an error in this question
Arrays & CollectionsEasy
Q27. What is a stack?
- A.A LIFO (Last-In First-Out) structure✓ Correct
- B.A sorted list of ordered elements
- C.A random access data structure
- D.A FIFO (First-In First-Out) structure
Explanation
A stack is a LIFO data structure where the last element added is the first one removed.
Report an error in this question
Arrays & CollectionsMedium
Q28. What is a hash table?
- A.A balanced binary tree for hierarchical storage
- B.A sorted array of ordered elements in memory
- C.A structure mapping keys to values via hashing✓ Correct
- D.A stack variant that allows random element access
Explanation
A hash table uses a hash function to compute an index into an array of buckets, enabling average O(1) lookup, insertion, and deletion.
Report an error in this question
Arrays & CollectionsMedium
Q29. What is the difference between HashMap and TreeMap in Java?
- A.They are exactly the same data structure implementation
- B.HashMap maintains the insertion order of all its entries
- C.TreeMap is always faster than HashMap for all operations
- D.HashMap is unordered O(1); TreeMap is sorted O(log n)✓ Correct
Explanation
HashMap uses hashing for O(1) average operations but no ordering; TreeMap uses a red-black tree for O(log n) operations with keys in sorted order.
Report an error in this question
Arrays & CollectionsHard
Q30. What is a B-tree and where is it commonly used?
- A.A self-balancing tree with multiple keys per node for databases✓ Correct
- B.A hash table variant that uses tree-based collision resolution
- C.A standard binary tree with two children per node
- D.A linked list type that organizes data in sequential node chains
Explanation
A B-tree is a self-balancing tree where nodes can have multiple keys and children, optimized for disk access and widely used in databases.
Report an error in this question