Data Structures and Algorithms MCQ's PDF

Summary

This document contains multiple choice questions (MCQs) about data structures and algorithms. The questions cover topics like searching, recursion, hash tables, priority queues, and more. The document also includes explanations for some of the answers.

Full Transcript

**[Data Sturucture and Algorithms]** ### **1. What is the time complexity of searching for an element in a balanced binary search tree (BST)?** - - - - **Answer**: B) O(logn) ### **2. Which data structure is used in recursion?** - - - - **Answer**: B) Stack ### **3. What is...

**[Data Sturucture and Algorithms]** ### **1. What is the time complexity of searching for an element in a balanced binary search tree (BST)?** - - - - **Answer**: B) O(logn) ### **2. Which data structure is used in recursion?** - - - - **Answer**: B) Stack ### **3. What is the worst-case time complexity of inserting an element into a hash table?** - - - - **Answer**: C) O(n) ### **4. Which of the following data structures is used to implement a priority queue?** - - - - **Answer**: C) Heap ### **5. What is the main advantage of a doubly linked list over a singly linked list?** - - - - **Answer**: B) Simplifies backward traversal ### **6. In which traversal of a binary tree are nodes visited in the order: left subtree, root, right subtree?** - - - - **Answer**: C) In-order traversal ### **7. Which of the following sorting algorithms has the best worst-case time complexity?** - - - - **Answer**: B) Merge Sort ### **8. Which of the following is NOT a characteristic of a queue?** - - - - **Answer**: D) LIFO (Last In, First Out) ### **9. What is the space complexity of Depth First Search (DFS) in terms of the number of vertices** VVV**?** - - - - **Answer**: B) O(V) ### **10. Which traversal algorithm is used to solve the shortest path problem in an unweighted graph?** - - - - **Answer**: B) Breadth First Search ### **1. What is the time complexity of solving the Knapsack problem using Dynamic Programming?** - - - - **Answer**: B) O(n⋅W)\ *(where* n *is the number of items and* W *is the capacity of the knapsack.)* ### **2. Which of the following problems is typically solved using backtracking?** - - - - **Answer**: B) Sudoku solver ### **3. What is the time complexity of binary search in a sorted array?** - - - - **Answer**: C) O(logn) ### **4. Which bit manipulation operation checks if the** iii**-th bit of a number** nnn **is set?** - - - - **Answer**: A) n&(1\ 0n\>0 ### **7. Which dynamic programming problem involves finding the length of the longest subsequence that is a palindrome?** - - - - **Answer**: B) Longest Palindromic Subsequence ### **8. What is the key difference between backtracking and brute force?** - - - - **Answer**: B) Backtracking discards partial solutions that cannot lead to valid results ### **9. How can you reverse the digits of a number mathematically?** - - - - **Answer**: A) Use division and modulo operations repeatedly ### **10. What is the time complexity of merging two sorted arrays using the two-pointer technique?** - - - - **Answer**: B)O(n+m)\ *(where* n *and* m *are the sizes of the two arrays.)*

Use Quizgecko on...
Browser
Browser