Data Structures Mastery Quiz Quiz

  1. Array Access

    What is the time complexity for accessing an element in an array by its index?

    1. A: O(n)
    2. B: O(log n)
    3. C: O(1)
    4. D: O(n log n)
    5. E: O(n squared)
  2. Linked List Insertion

    What is the time complexity to insert a node at the beginning of a singly linked list, given the head pointer?

    1. A: O(n)
    2. B: O(log n)
    3. C: O(1)
    4. D: O(n log n)
    5. E: O(n square)
  3. Hash Table Collision

    Which of the following is a common technique for resolving collisions in a hash table?

    1. A: Binary Search
    2. B: Linear Probing
    3. C: Quick Sort
    4. D: Depth-First Search
    5. E: Merg Sort
  4. Binary Search Requirement

    What condition must be met for binary search to function correctly?

    1. A: The data must be sorted
    2. B: The data must be unsorted
    3. C: The data must contain no duplicates
    4. D: The data must be in reverse order
    5. E: The data can be any order
  5. Quick Sort Worst Case

    In what scenario does Quick Sort exhibit its worst-case time complexity?

    1. A: Already sorted data
    2. B: Randomly ordered data
    3. C: Small input size
    4. D: Almost sorted data
    5. E: Descending order data
  6. String Reversal

    Which data structure is most suitable for efficiently reversing a string?

    1. A: Queue
    2. B: Linked List
    3. C: Stack
    4. D: Tree
    5. E: Hash table
  7. Stack Operations

    Which principle does a stack follow?

    1. A: First In, First Out (FIFO)
    2. B: Last In, First Out (LIFO)
    3. C: Random Access
    4. D: Middle In, Middle Out
    5. E: None of the Above
  8. Queue Applications

    Which of the following is a typical application of a queue?

    1. A: Expression Parsing
    2. B: Function Call Management
    3. C: Task Scheduling
    4. D: Recursion Control
    5. E: Memory Allocation
  9. Recursion Base Case

    What is a critical component of a recursive function?

    1. A: Loop Invariant
    2. B: Base Case
    3. C: Global Variable
    4. D: Inline Function
    5. E: Default Parameter
  10. Backtracking Goal

    What is the primary purpose of backtracking algorithms?

    1. A: Find the optimal solution
    2. B: Find all possible solutions
    3. C: Sort data efficiently
    4. D: Search a specific element
    5. E: Reverse a string
  11. Tree Traversal

    Which tree traversal method visits the left subtree, then the root, then the right subtree?

    1. A: Pre-order
    2. B: Post-order
    3. C: In-order
    4. D: Breadth-first
    5. E: Depth-First
  12. Heap Type

    Which type of tree is commonly used to implement a priority queue?

    1. A: Binary Search Tree
    2. B: AVL Tree
    3. C: Red-Black Tree
    4. D: Heap
    5. E: Segment Tree
  13. Graph Representation

    Which data structure is used to represent a graph?

    1. A: Array
    2. B: Linked List
    3. C: Matrix
    4. D: Stack
    5. E: All of the above
  14. Dynamic Programming Savings

    What is the main advantage of using dynamic programming?

    1. A: Reduces code size
    2. B: Avoids redundant calculations
    3. C: Increases memory usage
    4. D: Simplifies debugging
    5. E: Improves readability
  15. Bitwise Operation

    Which bitwise operator performs a logical AND operation on individual bits?

    1. A: |
    2. B: u0026
    3. C: ^
    4. D: ~
    5. E: u003Eu003E
  16. Trie Purpose

    For what purpose is a trie data structure primarily used?

    1. A: Storing numerical data
    2. B: Efficient string retrieval
    3. C: Graph representation
    4. D: Sorting algorithms
    5. E: Dynamic memory allocation
  17. Array Deletion Time Complexity

    What is the average time complexity of deleting an element from the middle of an unsorted array?

    1. A: O(1)
    2. B: O(log n)
    3. C: O(n)
    4. D: O(n log n)
    5. E: O(n^2)
  18. Linked List Cycle Detection

    Which algorithm is commonly used to detect cycles in a linked list?

    1. A: Binary Search
    2. B: Floyd's Cycle-Finding Algorithm
    3. C: Depth-First Search
    4. D: Breadth-First Search
    5. E: Merge Sort
  19. Hash Function Property

    What is a desirable property of a good hash function?

    1. A: Always produces the same hash value for different inputs
    2. B: Distributes keys evenly across the hash table
    3. C: Causes frequent collisions
    4. D: Is very complex and computationally expensive
    5. E: Only works with integer keys
  20. Searching Rotated Sorted Array

    Which search algorithm is most efficient for searching in a rotated sorted array?

    1. A: Linear Search
    2. B: Binary Search
    3. C: Depth-First Search
    4. D: Breadth-First Search
    5. E: Interpolation Search
  21. Merge Sort Time Complexity

    What is the time complexity of Merge Sort in the best, average, and worst cases?

    1. A: O(n), O(n log n), O(n^2)
    2. B: O(log n), O(n log n), O(n log n)
    3. C: O(n log n), O(n log n), O(n log n)
    4. D: O(1), O(log n), O(n)
    5. E: O(n), O(n), O(n)
  22. String Palindrome Check

    What is a palindrome?

    1. A: A string that is always sorted alphabetically
    2. B: A string that reads the same forwards and backward
    3. C: A string containing only numbers
    4. D: A string with no vowels
    5. E: A string that contains all unique characters
  23. Stack Application - Balanced Parentheses

    What is a stack commonly used for in terms of strings and parentheses?

    1. A: Calculating string length
    2. B: Checking for balanced parentheses
    3. C: Reversing a string
    4. D: Sorting strings alphabetically
    5. E: Counting the number of vowels
  24. Graph Shortest Path

    Which algorithm is commonly used to find the shortest path in a weighted graph?

    1. A: Depth-First Search
    2. B: Breadth-First Search
    3. C: Dijkstra's Algorithm
    4. D: Bubble Sort
    5. E: Linear Search
  25. Dynamic Programming Overlapping Subproblems

    What characteristic of problems makes them suitable for solving with dynamic programming?

    1. A: Having no overlapping subproblems
    2. B: Having independent subproblems
    3. C: Having overlapping subproblems
    4. D: Requiring a lot of memory
    5. E: Being very complex and unsolvable by other means