100% found this document useful (2 votes)
2K views

CS521 Midterm Preparation File by ZB

Excellent

Uploaded by

iqeamobeen123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
2K views

CS521 Midterm Preparation File by ZB

Excellent

Uploaded by

iqeamobeen123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

MCQS CS521 midterm preparation file ZB

In the name of God , Most


Gracious, Most merciful

CS521
MCQS Midterm preparation file ZB

ZB
MCQS

1. Which data structure uses LIFO (Last In, First Out)?


a) Queue
b) Stack
c) Linked List
d) Tree
Answer: b) Stack

2. Which of the following is a disadvantage of an array?


a) Fast access to elements
b) Fixed size
c) Supports dynamic memory allocation
d) Simple to implement
Answer: b) Fixed size

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

4. What is the time complexity of accessing an element in an array?


a) O(log n)
b) O(n)
c) O(1)
d) O(n log n)
Answer: c) O(1)
ZB
MCQS ZB
Midterm preparation file

5. Which of the following is a stable sorting algorithm?

a) Quick Sort

b) Merge Sort

c) Heap Sort

d) Selection Sort

Answer: b) Merge 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

Answer: c) Dijkstra’s Algorithm

7. Which of the following is not a characteristic of a queue?

a) FIFO (First In, First Out)

b) Operations are performed at the front and rear

c) Supports both insertions and deletions at any position

d) Used for scheduling processes

Answer: c) Supports both insertions and deletions at any position

8. What is the space complexity of an algorithm that uses constant space?

a) O(1)

b) O(n)

c) O(n^2)

d) O(log n)

Answer: a) O(1)
MCQS ZB
Midterm preparation file

9. In a hash table, a collision occurs when:

a) Two keys map to the same index

ZB
b) Two keys are inserted into the table

c) The table exceeds its capacity

d) The table becomes empty

Answer: a) Two keys map to the same index

10. Which data structure is used in depth-first search (DFS)?

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?

a) Depth-First Search (DFS)

b) Dijkstra’s Algorithm

c) Bellman-Ford Algorithm

d) Breadth-First Search (BFS)

Answer: d) Breadth-First Search (BFS)

12. Which sorting algorithm has a worst-case time complexity of O(n^2)?

a) Merge Sort

b) Quick Sort

c) Selection Sort

d) Heap Sort

Answer: c) Selection Sort


MCQS Midterm preparation file

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

Answer: a) Dijkstra’s Algorithm

14. Which of the following is not a characteristic of a binary search tree (BST)?

a) Left child is smaller than the parent node

b) Right child is greater than the parent node

c) It can have duplicate values

d) Both subtrees of a node are binary search trees

Answer: c) It can have duplicate values

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

Answer: a) Quick Sort

16. What is the time complexity of the binary search algorithm?

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

17. Which of the following is the correct definition of a tree?

a) A set of nodes connected by edges

ZB
b) A set of nodes connected in a circular fashion

c) A set of nodes with no parent-child relationships

d) A structure with only leaf nodes

Answer: a) A set of nodes connected by edges

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

20. Which of the following is true for a doubly linked list?

a) Each node contains a single pointer to the next node

b) Each node contains two pointers, one to the next and one to the previous node

c) It only allows traversal in one direction

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

21. Which of the following sorting algorithms is not comparison-based?

a) Merge Sort

b) Heap Sort

c) Radix Sort

d) Quick Sort

Answer: c) Radix 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)

Answer: b) O(n log n)

23. Which of the following is a feature of a linked list?

a) Direct access to elements via an index

b) Static size

c) Dynamic size

d) All elements are stored contiguously in memory

Answer: c) Dynamic size

24. What is the time complexity of inserting an element into a max-heap?

a) O(1)

b) O(log n)

c) O(n)

d) O(n log n)

Answer: b) O(log n)
ZB
MCQS ZB

Midterm preparation file


25. Which of the following is true about the breadth-first search (BFS) algorithm?

a) It uses a stack

b) It explores nodes in depth order

c) It uses a queue

d) It is suitable for tree traversal only

Answer: c) It uses a queue

26. Which of the following data structures is used in implementing recursion?

a) Queue

b) Stack

c) Linked List

d) Tree

Answer: b) Stack

27. Which of the following is the correct definition of a graph?

a) A collection of nodes connected in a linear fashion

b) A set of vertices connected by edges

c) A tree structure with no cycles

d) A matrix with numerical values

Answer: b) A set of vertices connected by edges

28. Which of the following is true for the merge sort algorithm?

a) It is not a stable sort

b) It is a divide-and-conquer algorithm

c) It has a worst-case time complexity of O(n^2)

d) It is not efficient for large datasets

Answer: b) It is a divide-and-conquer algorithm


MCQS ZB

ZB
Midterm preparation file

29. Which of the following is true for quicksort?


a) It is always stable
b) It is an in-place sorting algorithm
c) It has a worst-case time complexity of O(n^2)
d) Both b and c
Answer: d) Both b and c

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)

31. Which of the following is true about a hash function?


a) It maps large inputs to smaller outputs
b) It always produces a unique output for every input
c) It is a one-to-one function
d) It is used for sorting data
Answer: a) It maps large inputs to smaller outputs
ZB
MCQS

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)

34. In a graph, what is a cycle?


a) A path that visits the same node more than once
b) A path that starts and ends at the same node
c) A path that does not contain any edges
d) A path that connects two disconnected components
Answer: b) A path that starts and ends at the same node

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)

36. Which of the following is true about a red-black tree?


a) It is always balanced
b) It has a maximum height of 2 log n
c) It is a self-balancing binary search tree
d) It does not allow duplicate nodes
Answer: c) It is a self-balancing binary search tree
ZB

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

38. What is the worst-case time complexity of QuickSort?


a) O(n log n)
b) O(n^2)
c) O(n)
d) O(log n)
Answer: b) O(n^2)

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

40. Which data structure is used to represent a graph efficiently in memory?


a) Array
b) Adjacency List
c) Queue
d) Stack
Answer: b) Adjacency List
ZB

ZB
MCQS
Midterm preparation file
41. Which of the following is true for a heap?

a) It is a complete binary tree

b) It is always a balanced binary search tree

c) It is an unordered tree

d) It can be used to implement a doubly linked list

Answer: a) It is a complete binary 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)

43. Which of the following sorting algorithms is an example of a divide-and-conquer algorithm?

a) Bubble Sort

b) Merge Sort

c) Insertion Sort

d) Selection Sort

Answer: b) Merge Sort

44. Which of the following is a disadvantage of a doubly linked list?

a) It requires more memory per node

b) It does not allow traversal in both directions

c) It has a faster search time compared to an array

d) It is difficult to implement

Answer: a) It requires more memory per node


ZB
MCQS ZB
Midterm preparation file
45. What is the time complexity of deleting the last element from a doubly linked list?
a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
Answer: a) O(1)

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 +92 300 5427579


WhatsApp:
https://whatsapp.com/channel/0029VaODheTDp2Q8YVcoO
N2p
Second WhatsApp channel
channel on WhatsApp:
https://whatsapp.com/channel/0029VafvOcy90x2tPbUaX0
2I
YouTube:
https://youtu.be/-AMj4iNz0UE?si=hg29pJZ1kujzg57J

Phone no : +92 300 5427579


Phone no: +92 330 3869586
Email: [email protected]
ZB
MCQS Midterm preparation file

Passing criteria of this course

ZB
Passing Criteria for a Course:

The passing criteria is defined in such a way that it ensures the


student shall be consistent in his studies
throughout the semester.
Therefore, for passing a course/subject, student shall fulfill the
following:
a) Secure minimum 20% score in Formative Assessments/Mid
terms
b) Secure minimum 20% score in Final Term Examinations.
c) Secure at least 40% marks in aggregate while fulfilling the
above requirements
ZB

ZB
MCQS Midterm preparation file

Course Selection and Credit Hours

Q: How do I select courses when the course selection is open?


A: Follow these steps:
1. Check the credit hours allowed by your university (e.g., 21, 18, or 15
credit hours).
2. Each subject typically has 3 credit hours.
3. Divide the total allowed credit hours by 3 to determine how many
subjects you can select.
Examples:
21 credit hours = 7 su18 credit hours = 6 subjects
15 credit hours = 5 subjects
Remember, the university may allow different credit hours for each
student, so check your specific allowance.
By following these steps, you can make informed decisions during
course selection and manage your credit hours
effectively.

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

Izat Zilat shohrat Fame


Izat Zilat Sirf Allah de saqty hn puri dunya mel ke b
apko zra brabr b demage nahe kr saqti Agr ALLAH
Apko izat dena chahay to puri dunya ak tararf ho ke
b apko 1% b nuksan nahe pohancha saqti
Phr Dar ks bat ka ???????????????
Be brave be strong Just put your trust To ALLAH
Hamesha Confident or himat se raho kbi ksi k samne
mat jhuko puri dunya mel k b apka kuch b nahe
beggar saqti
ZB
ZB
MY REQUEST FROM ALL OF YOU

ZB Request from All of you My family


Mjy ap sbki help or support ki zarort ha or wo ye k hum sb Mel
kr Allah ka Quran ki Urdu translation logo tak pohanchy or
Quran ko samjna asaaan kryn dosro k leay sb tak Allah ka Quran
pohanchy it's my compaign hum log 70+ age k ho jaty hn phr b
hmy namaz tak ki translation nahe pta hoti k hum Allah pak se

Kya Dua kr rhy hn so hum youngster's ko Mel kr puri takat or


energy ke sath Allah ka Quran spread krna ha
Hum puri Koshish kr rhy hn k hum sb Mel k Quran ki
translation or most important topics ko maximum share kry with
translation hmara maksad Quran ko spread krna ha be a part of
us
m apni pocket se ye sb kr rha ho Allah ka Quran spread krny k
leay apne or mene sbny Marna ha ak din to q na Allah k leay
Kuch kryn apni energies apni power ko bajay negative use krny k
Allah k leay invest kryn khud ko be a part of us
Agr m 23 ki age m apny sare sources use kr rha ho pocket se
heavy amounts give away kr rha ho Quran spread krny k leay to
ap just share to kr saqty hn itna e krdyn

Contact ZB +92 300 5427579

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

"And indeed, with hardship comes ease." (Quran 94:5)


Remember, I'm here to support you! Stay brave and strong!"

May Allah bless you

You might also like