CS505 Midterm Preparation File by ZB
CS505 Midterm Preparation File by ZB
CS505
MCQS Midterm preparation file ZB
ZB
MCQS
3. Which of the following sorting algorithms has the best worst-case time complexity? a) Bubble sort
b) Quick sort
c) Merge sort
d) Selection sort
4. Which of the following is true about Big O notation? a) It measures the best-case time complexity.
b) It measures the worst-case time complexity.
c) It is used to determine memory usage.
d) It does not consider input size.
5. Which data structure uses LIFO (Last In, First Out) order? a) Queue
b) Stack
c) Linked list
d) Tree
Answer: b) Stack
6. Which of the following is the correct order of complexity from best to worst? a) O(n), O(log n), O(n^2)
7. Which of the following is the best-case time complexity for Quick Sort? a) O(n^2)
b) O(n log n)
c) O(n)
d) O(log n)
8. Which of the following is the primary purpose of a hash function? a) To sort the data
9. What does BFS (Breadth-First Search) explore first in a graph? a) The deepest node
ZB
c) The most distant node
10. Which of the following is an example of a divide and conquer algorithm? a) Merge Sort
b) Bubble Sort
c) Selection Sort
d) Linear Search
11. Which of the following operations is performed in constant time? a) Inserting an element into
a linked list
12. Which of the following is a feature of a Binary Search Tree (BST)? a) Each node has two
ZB
ZB
13. Which of the following is true for a circular linked list? a) It does not have a head node.
14. Which of the following is a greedy algorithm? a) Dijkstra's shortest path algorithm
b) Merge sort
c) Quick sort
d) Depth-first search
b) Quick Sort
c) Binary Search
d) Depth-first search
16. Which of the following is true for a Min-Heap? a) The parent node is smaller than its
children.
17. What is the time complexity of accessing an element in a hash table? a) O(n)
b) O(log n)
ZB
c) O(1)
d) O(n^2)
Answer: c) O(1)
18. Which of the following algorithms is used for finding the shortest path in a weighted graph? a)
Dijkstra's Algorithm
b) Bellman-Ford Algorithm
c) Floyd-Warshall Algorithm
c) Binary Search
b) O(n log n)
c) O(n)
d) O(log n)
Answer: c) O(n)
ZB
ZB
MCQS Midterm preparation file
21. Which of the following is true about a priority queue? a) It operates on the FIFO principle.
22. Which of the following is the time complexity of a binary search on a sorted array? a) O(n)
b) O(log n)
c) O(n^2)
d) O(n log n)
Answer: b) O(log n)
23. Which of the following is the worst-case time complexity of Quick Sort? a) O(n)
b) O(n log n)
c) O(log n)
d) O(n^2)
Answer: d) O(n^2)
24. Which of the following is NOT a valid data structure for implementing a priority queue? a) Array
b) Binary Heap
c) Linked List
d) Stack
Answer: d) Stack
ZB
MCQS ZB
b) Pre-order
c) Post-order
d) Level-order
Answer: b) Pre-order
b) Merge Sort
c) Selection Sort
d) Heap Sort
27. Which algorithm is used to find the minimum spanning tree in a graph? a) Kruskal's
Algorithm
b) Bellman-Ford Algorithm
c) Dijkstra's Algorithm
d) Floyd-Warshall Algorithm
28. Which of the following is true about a doubly linked list? a) It allows traversal in
b) Each node has two pointers, one for the next node and one for the previous node.
Answer: b) Each node has two pointers, one for the next node and one for the previous
node.
MCQS ZB
ZB
Midterm preparation file
29. What is the worst-case time complexity for finding an element in a binary
search tree? a) O(n)
b) O(log n)
c) O(n^2)
d) O(n log n)
Answer: a) O(n)
30. Which algorithm is used for searching a sorted array in logarithmic time? a)
Linear Search
b) Binary Search
c) Jump Search
d) Exponential Search
31. Which of the following best describes an AVL tree? a) A balanced binary
search tree
b) A self-organizing data structure
c) A type of hash table
d) A graph-based data structure
Answer: a) A balanced
ZB
MCQS
ZB
Midterm preparation file
33. What is the worst-case time complexity for an insertion operation in a binary
search tree (BST)? a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
Answer: c) O(n)
35. Which of the following algorithms is used to find the longest common
subsequence? a) Kruskal’s Algorithm
b) Dijkstra’s Algorithm
c) Dynamic Programming
d) Greedy Algorithm
36. Which of the following statements is true about merge sort? a) Merge sort is
an in-place sorting algorithm.
b) Merge sort is a divide and conquer algorithm.
c) Merge sort does not require additional memory space.
d) Merge sort has a worst-case time complexity of O(n^2).
ZB
MCQS
Midterm preparation file
38. Which of the following algorithms is typically used for solving problems like
scheduling? a) Divide and Conquer
b) Dynamic Programming
c) Greedy Algorithm
d) Backtracking
39. In which type of search does the algorithm explore all neighboring nodes at the
present depth level before moving on to nodes at the next depth level? a) Depth-
first Search (DFS)
b) Breadth-first Search (BFS)
c) Binary Search
d) Uniform Cost Search
ZB
MCQS
Midterm preparation file
41. Which of the following is a valid operation in a queue? a) Pop
b) Enqueue
c) Push
d) Delete
Answer: b) Enqueue
42. What is the space complexity of the recursive Fibonacci sequence algorithm? a) O(1)
b) O(n)
c) O(log n)
d) O(n^2)
Answer: b) O(n)
43. Which of the following is a characteristic of a strongly connected graph? a) All vertices are reachable from each
other.
c) It has no cycles.
44. Which of the following is the correct use of backtracking? a) Finding the shortest path in a graph
Answer: c) O(n^2)
46. Which of the following describes a topological sort in a directed acyclic graph (DAG)? a) A
sorted list of vertices such that for every directed edge u → v, vertex u comes before v.
b) A list of nodes where the highest node is always at the end.
c) A sorted list of edges where the edges are placed based on their weights.
d) A method of sorting that uses a binary search tree.
ZB
Passing Criteria for a Course:
ZB
MCQS Midterm preparation file
ZB
Advice
Hmaesha relax ho ke parha kryn panic mat hua kryn apky
parents ky bohat khawab hoty hn wo pura krny ki puri koshish
kea kryn kbi b ksi pe depend na kea kryn apko bs ak insan
success kr saqta ha or wo insan ap khud hn apky elawa koi nahe
ap bs koshish kryn Allah pak pe strong yakeen rakha kryn or
mehnat krke sb Allah ke hawaly kr dea kryn everything is
possible be brave be strong stay blessed
Hum insan hamesha moat se darty or bhagty hn or moat se
bachny ki koshish krty hn jabke moat ny ana hi ana ha hum
ZB
moat se nahe bach saqty humy jahanam se bachny ki koshish
krni chaheay hum jahanam se bach saqty hn
Insan ko 3 chezo se dar lagta ha Moat Risk/Dolat Ezat Shohrat
Fame
Moat
Humy pta hona chaheay Moat tab ani ha jab Allah
chahy us se pehly puri dunya bi ak tararf ho ke apko
marna chahy to apka kuch nahe beggar saqti
Risk/Dolat
Risk Dolat sb Allah pak ke hath m ha puri dunya ak
taraf b ho jay na apsy apka risk cheen saqti ha na de
saqti ha Ye sirf ALLAh pak ky hath m ha
ZB
Agr ap mujsy contact na kr sky too b ap jo b hn jaha bi hn waha
Allah ka quran pheelay zada se zada with urdu translation jitni
himat ha utna share kryn
ZB
MY Family
ust Relax and focus! Exams are not difficult. Put in your
100% effort and trust in Allah.
AL-Quran