CS521 Midterm Preparation File by ZB
CS521 Midterm Preparation File by ZB
CS521
MCQS Midterm preparation file ZB
ZB
MCQS
3. In a binary search tree (BST), the left child of a node has a value that is:
a) Greater than the parent node
b) Smaller than the parent node
c) Equal to the parent node
d) None of the above
Answer: b) Smaller than the parent node
a) Quick Sort
b) Merge Sort
c) Heap Sort
d) Selection Sort
6. Which algorithm is used for finding the shortest path in a weighted graph?
a) BFS
b) DFS
c) Dijkstra’s Algorithm
d) Kruskal’s Algorithm
a) O(1)
b) O(n)
c) O(n^2)
d) O(log n)
Answer: a) O(1)
MCQS ZB
Midterm preparation file
ZB
b) Two keys are inserted into the table
a) Queue
b) Stack
c) Array
d) Linked List
Answer: b) Stack
11. Which algorithm is used for graph traversal that visits all the nodes in a graph level by level?
b) Dijkstra’s Algorithm
c) Bellman-Ford Algorithm
a) Merge Sort
b) Quick Sort
c) Selection Sort
d) Heap Sort
ZB
ZB
13. Which of the following is a greedy algorithm?
a) Dijkstra’s Algorithm
b) Merge Sort
c) Bellman-Ford Algorithm
d) Binary Search
14. Which of the following is not a characteristic of a binary search tree (BST)?
15. Which of the following algorithms has the best average time complexity for sorting?
a) Quick Sort
b) Merge Sort
c) Bubble Sort
d) Insertion Sort
a) O(n)
b) O(log n)
c) O(n log n)
d) O(1)
Answer: b) O(log n)
MCQS MIDTERM PREPARATION FILE ZB
ZB
b) A set of nodes connected in a circular fashion
18. Which of the following is the best-case time complexity of bubble sort?
a) O(n^2)
b) O(n log n)
c) O(1)
d) O(n)
Answer: d) O(n)
19. Which data structure is best suited for implementing a priority queue?
a) Stack
b) Heap
c) Array
d) Linked List
Answer: b) Heap
b) Each node contains two pointers, one to the next and one to the previous node
d) It uses more memory than a singly linked list but requires less traversal time
Answer: b) Each node contains two pointers, one to the next and one to the previous node
ZB
ZB
MCQS Midterm preparation file
a) Merge Sort
b) Heap Sort
c) Radix Sort
d) Quick Sort
22. What is the time complexity of merge sort in the worst case?
a) O(n)
b) O(n log n)
c) O(n^2)
d) O(log n)
b) Static size
c) Dynamic size
a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
Answer: b) O(log n)
ZB
MCQS ZB
a) It uses a stack
c) It uses a queue
a) Queue
b) Stack
c) Linked List
d) Tree
Answer: b) Stack
28. Which of the following is true for the merge sort algorithm?
b) It is a divide-and-conquer algorithm
ZB
Midterm preparation file
30. What is the time complexity of deleting the root element in a min-heap?
a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
Answer: b) O(log n)
ZB
Midterm preparation file
33. What is the worst-case time complexity of the insertion sort algorithm?
a) O(n log n)
b) O(n^2)
c) O(n)
d) O(1)
Answer: b) O(n^2)
35. What is the time complexity of accessing an element in a singly linked list?
a) O(1)
b) O(log n)
c) O(n)
d) O(n^2)
Answer: c) O(n)
ZB
MCQS
Midterm preparation file
37. Which algorithm is used for finding the minimum spanning tree of a graph?
a) Bellman-Ford Algorithm
b) Dijkstra’s Algorithm
c) Kruskal’s Algorithm
d) Floyd-Warshall Algorithm
Answer: c) Kruskal’s Algorithm
39. Which of the following best describes the term "polynomial time"?
a) An algorithm whose time complexity grows faster than any polynomial
b) An algorithm whose time complexity grows as a polynomial of the input size
c) An algorithm whose time complexity grows linearly
d) An algorithm whose time complexity is constant
Answer: b) An algorithm whose time complexity grows as a polynomial of the input
size
ZB
MCQS
Midterm preparation file
41. Which of the following is true for a heap?
c) It is an unordered tree
42. What is the time complexity of the breadth-first search (BFS) algorithm for a graph with V vertices and E edges?
a) O(V + E)
b) O(V^2)
c) O(E)
d) O(V log V)
Answer: a) O(V + E)
a) Bubble Sort
b) Merge Sort
c) Insertion Sort
d) Selection Sort
d) It is difficult to implement
46. Which of the following algorithms does not use a divide-and-conquer approach?
a) Merge Sort
b) Quick Sort
c) Binary Search
d) Insertion Sort
Answer: d) Insertion Sort
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