CS403 Midterm Preparation File by ZB
CS403 Midterm Preparation File by ZB
CS403
MCQS Midterm preparation file ZB
ZB
MCQS
1. Which of the following is an example of a non-primitive data type?
a) int
b) float
c) string
d) char
Answer: c) string
2. Which of the following is used to store multiple values in a single variable in Python?
a) List
b) Set
c) Tuple
d) Dictionary
Answer: a) List
4. Which data structure follows the Last In First Out (LIFO) principle?
a) Queue
b) Stack
c) Linked List
d) Tree
Answer: b) Stack
10. Which of the following is NOT a valid way to create an object in C++?
a) Using a constructor
b) Using a destructor
c) Using dynamic memory allocation
d) Using a copy constructor
Answer: b) Using a destructor
MCQS ZB
Midterm preparation file
11. In which type of sorting algorithm does the smallest element get swapped with the first
element?
ZB
a) Bubble sort
b) Selection sort
c) Insertion sort
d) Quick sort
Answer: b) Selection sort
12. Which of the following algorithms is considered the most efficient for sorting large datasets?
a) Bubble sort
b) Quick sort
c) Insertion sort
d) Merge sort
Answer: b) Quick sort
13. In which type of data structure is data stored in the form of nodes, connected by pointers?
a) Array
b) Queue
c) Linked list
d) Hash table
Answer: c) Linked list
15. Which of the following is NOT a valid type of polymorphism in Object-Oriented Programming?
a) Method overloading
b) Method overriding
c) Constructor overloading
d) Constructor overriding
Answer: d) Constructor overriding
MCQS Midterm preparation file
ZB
ZB
19. In a circular queue, what happens when the rear pointer reaches the last position of the
array?
a) It is set to null
b) It points to the front of the queue
c) The queue overflows
d) It causes a segmentation fault
Answer: b) It points to the front of the queue
ZB
a) Array
b) Stack
c) Tree
d) Queue
Answer: c) Tree
26. In which sorting algorithm are elements swapped if they are in the wrong order, and
the process is repeated for each element in the array?
a) Quick sort
b) Bubble sort
c) Selection sort
d) Insertion sort
Answer: b) Bubble sort
28. Which data structure is used for implementing the Breadth-First Search (BFS)
algorithm?
a) Stack
b) Queue
c) Linked list
d) Array
Answer: b) Queue
30. Which of the following is the correct time complexity for accessing an element in a
hash table?
a) O(n)
b) O(1)
c) O(log n)
d) O(n log n)
Answer: b) O(1)
ZB
MCQS ZB
33. Which of the following sorting algorithms has the best average
case time complexity?
a) Merge sort
b) Quick sort
c) Bubble sort
d) Selection sort
Answer: b) Quick sort
MCQS ZB
ZB
Midterm preparation file
a) Array
b) Tree
c) Stack
d) Queue
Answer: b) Tree
35. Which of the following algorithms is typically used for solving the shortest path problem in a
graph?
a) Depth-first search
b) Dijkstra’s algorithm
c) Quick sort
d) Merge sort
36. Which of the following is NOT a valid data structure for implementing a priority queue?
a) Binary heap
b) Array
c) Queue
d) Linked list
Answer: c) Queue
ZB
MCQS
ZB
Midterm preparation file
ZB
MCQS
Midterm preparation file
40. Which algorithm is used to find the Minimum Spanning Tree (MST) of a
graph?
a) Dijkstra’s algorithm
b) Kruskal’s algorithm
c) Prim’s algorithm
d) Both b and c
Answer: d) Both b and c
41. In which type of recursion does a function call itself twice with different
parameters?
a) Linear recursion
b) Tail recursion
c) Binary recursion
d) Indirect recursion
Answer: c) Binary recursion
43. Which algorithm uses the divide and conquer approach to solve
problems?
a) Merge sort
b) Bubble sort
c) Linear search
d) Selection sort
Answer: a) Merge sort
ZB
ZB
MCQS
Midterm preparation file
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