Any2Quiz
CBSE / 12 / Computer Science / Programming

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 free

Sample questions

  1. What is a data structure?

    1. A way to organize data in a computer
    2. A type of programming language
    3. A specific type of algorithm
    4. 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.

  2. What is the time complexity of searching for an element in a sorted array using binary search?

    1. O(n)
    2. O(n^2)
    3. O(log n)
    4. 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.

  3. What is a graph?

    1. A linear data structure
    2. A non-linear data structure consisting of nodes and edges
    3. A type of sorting algorithm
    4. 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.

  4. What are the advantages and disadvantages of using a heap data structure?

    1. Advantages: efficient search; Disadvantages: slow insertion and deletion.
    2. Advantages: efficient insertion and deletion, efficient finding of min/max; Disadvantages: slow search.
    3. Advantages: fast search; Disadvantages: inefficient sorting.
    4. 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.

  5. 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.

    1. A simple array is sufficient.
    2. A hash table is suitable for quick retrieval of stock prices.
    3. A binary search tree offers efficient updates and retrievals.
    4. 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.

Take the full quiz

More quizzes

Browse all Programming quizzes