Data Structures Quiz - CBSE Class 12 Computer Science
Free practice quiz: Data Structures (CBSE Class 12 Computer Science). 12 multiple-choice questions with answers and explanations. Play online, no sign-up needed.
Play all 12 questions freeSample questions
What is a data structure?
- A way to organize data in a computer
- A type of programming language
- A specific type of algorithm
- A hardware component
Show answer
Answer: A. A way to organize data in a computer
Data structures are fundamental ways to organize and store data in a computer so that it can be used efficiently.
What is the time complexity of searching for an element in a sorted array using binary search?
- O(n)
- O(n^2)
- O(log n)
- O(1)
Show answer
Answer: C. O(log n)
Binary search has a time complexity of O(log n) because it repeatedly divides the search interval in half.
What is a graph?
- A linear data structure
- A non-linear data structure consisting of nodes and edges
- A type of sorting algorithm
- A way to represent a tree
Show answer
Answer: B. A non-linear data structure consisting of nodes and edges
A graph is a non-linear data structure composed of nodes (vertices) connected by edges.
What are the advantages and disadvantages of using a heap data structure?
- Advantages: efficient search; Disadvantages: slow insertion and deletion.
- Advantages: efficient insertion and deletion, efficient finding of min/max; Disadvantages: slow search.
- Advantages: fast search; Disadvantages: inefficient sorting.
- Advantages: efficient sorting; Disadvantages: inefficient search.
Show answer
Answer: B. Advantages: efficient insertion and deletion, efficient finding of min/max; Disadvantages: slow search.
Heaps excel at priority queue operations but are not ideal for searching.
Design a data structure to efficiently manage a system for tracking real-time stock prices of multiple companies, allowing for quick updates and retrievals. Justify your choice.
- A simple array is sufficient.
- A hash table is suitable for quick retrieval of stock prices.
- A binary search tree offers efficient updates and retrievals.
- A linked list provides dynamic storage for stock prices.
Show answer
Answer: B. A hash table is suitable for quick retrieval of stock prices.
Hash tables provide O(1) average time complexity for both insertion and retrieval, making them suitable for real-time updates and lookups of stock prices. Company names or stock symbols can act as keys.