[go: up one dir, main page]

100% found this document useful (1 vote)
125 views18 pages

CS505 Midterm Preparation File by ZB

The document is a midterm preparation file for CS505, containing multiple-choice questions (MCQs) covering key concepts in algorithms, data structures, and complexity analysis. It includes questions on algorithms like Quick Sort, Merge Sort, and Dijkstra's Algorithm, as well as data structures such as stacks, queues, and binary search trees. Additionally, it outlines passing criteria for the course and provides guidance on course selection and credit hours.

Uploaded by

FRAZ AHMAD
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 (1 vote)
125 views18 pages

CS505 Midterm Preparation File by ZB

The document is a midterm preparation file for CS505, containing multiple-choice questions (MCQs) covering key concepts in algorithms, data structures, and complexity analysis. It includes questions on algorithms like Quick Sort, Merge Sort, and Dijkstra's Algorithm, as well as data structures such as stacks, queues, and binary search trees. Additionally, it outlines passing criteria for the course and provides guidance on course selection and credit hours.

Uploaded by

FRAZ AHMAD
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 CS505 midterm preparation file ZB

In the name of God , Most


Gracious, Most merciful

CS505
MCQS Midterm preparation file ZB

ZB
MCQS

1. Which of the following is a correct definition of an algorithm? a) A sequence of steps to solve a


problem
b) A programming language
c) A type of data structure
d) A process that requires human intervention

Answer: a) A sequence of steps to solve a problem

2. Which of the following is NOT a characteristic of a good algorithm? a) Finiteness


b) Definiteness
c) Infinite loops
d) Efficiency

Answer: c) Infinite loops

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

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

Answer: b) It measures the worst-case time complexity.


ZB
MCQS ZB
Midterm preparation file

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)

b) O(n^2), O(log n), O(n)

c) O(log n), O(n), O(n^2)

d) O(n), O(n^2), O(log n)

Answer: c) O(log n), O(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)

Answer: b) O(n log n)

8. Which of the following is the primary purpose of a hash function? a) To sort the data

b) To map data to a fixed-size value

c) To find the maximum value

d) To divide the data into smaller segments

Answer: b) To map data to a fixed-size value


MCQS ZB
Midterm preparation file

9. What does BFS (Breadth-First Search) explore first in a graph? a) The deepest node

b) The nodes closest to the starting point

ZB
c) The most distant node

d) All leaf nodes

Answer: b) The nodes closest to the starting point

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

Answer: a) Merge Sort

11. Which of the following operations is performed in constant time? a) Inserting an element into

a linked list

b) Searching for an element in an unsorted array

c) Accessing an element by index in an array

d) Inserting an element into a balanced tree

Answer: c) Accessing an element by index in an array

12. Which of the following is a feature of a Binary Search Tree (BST)? a) Each node has two

children with equal value

b) Nodes are arranged in increasing order

c) The left child is greater than the parent node

d) The right child is smaller than the parent node

Answer: b) Nodes are arranged in increasing order


MCQS Midterm preparation file

ZB
ZB
13. Which of the following is true for a circular linked list? a) It does not have a head node.

b) The last node points to null.

c) It allows easy traversal from the tail to the head.

d) It has no null pointers.

Answer: d) It has no null pointers.

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

Answer: a) Dijkstra's shortest path algorithm

15. Which of the following is an example of dynamic programming? a) Fibonacci sequence

b) Quick Sort

c) Binary Search

d) Depth-first search

Answer: a) Fibonacci sequence

16. Which of the following is true for a Min-Heap? a) The parent node is smaller than its

children.

b) The parent node is greater than its children.

c) The children of a node can be unordered.

d) The heap is always sorted.

Answer: a) The parent node is smaller than its children.


MCQS MIDTERM PREPARATION FILE ZB

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

d) All of the above

Answer: d) All of the above

19. Which of the following is an example of an NP-complete problem? a) Sorting an array

b) Traveling Salesman Problem

c) Binary Search

d) Finding the maximum element

Answer: b) Traveling Salesman Problem

20. What is the best-case time complexity of Bubble Sort? a) O(n^2)

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.

b) It gives priority to the elements with the highest priority.

c) It does not allow duplicate values.

d) It can be implemented using a stack.

Answer: b) It gives priority to the elements with the highest priority.

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

Midterm preparation file


25. Which of the following traversal methods is used to visit all the nodes in a tree in

the order of root, left subtree, right subtree? a) In-order

b) Pre-order

c) Post-order

d) Level-order

Answer: b) Pre-order

26. Which of the following is a stable sorting algorithm? a) Quick Sort

b) Merge Sort

c) Selection Sort

d) Heap Sort

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

Answer: a) Kruskal's Algorithm

28. Which of the following is true about a doubly linked list? a) It allows traversal in

only one direction.

b) Each node has two pointers, one for the next node and one for the previous node.

c) It cannot be traversed in reverse.

d) It requires more memory than a singly linked list.

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

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

34. Which of the following is an example of a non-linear data structure? a) Array


b) Linked List
c) Binary Tree
d) Stack

Answer: c) Binary Tree

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

Answer: c) Dynamic Programming

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).

Answer: b) Merge sort is a divide and conquer algorithm.


ZB

ZB
MCQS
Midterm preparation file

37. Which of the following is an example of an unsorted collection? a) Array


b) Linked List
c) Stack
d) Priority Queue

Answer: b) Linked List

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

Answer: c) Greedy Algorithm

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

Answer: b) Breadth-first Search (BFS)

40. Which of the following is NOT an application of a stack? a) Undo operations in


text editors
b) Depth-first search in graphs
c) Memory management
d) Sorting large datasets

Answer: d) Sorting large datasets


ZB

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.

b) It has a single source and sink.

c) It has no cycles.

d) All vertices have equal in-degree and out-degree.

Answer: a) All vertices are reachable from each other.

44. Which of the following is the correct use of backtracking? a) Finding the shortest path in a graph

b) Generating all possible subsets of a set

c) Sorting elements in an array

d) Searching for an element in a binary search tree

Answer: b) Generating all possible subsets of a set


ZB
MCQS ZB
Midterm preparation file
45. Which of the following represents the number of comparisons in the worst case for Quick
Sort? a) O(n log n)
b) O(log n)
c) O(n^2)
d) O(n)

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 +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: asktozb@gmail.com
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