0% found this document useful (0 votes)
28 views18 pages

CS403 Midterm Preparation File by ZB

Uploaded by

Amir Maqbol
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
0% found this document useful (0 votes)
28 views18 pages

CS403 Midterm Preparation File by ZB

Uploaded by

Amir Maqbol
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 CS403 midterm preparation file ZB

In the name of God , Most


Gracious, Most merciful

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

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


a) O(n)
b) O(1)
c) O(log n)
d) O(n log n)
Answer: b) O(1)

4. Which data structure follows the Last In First Out (LIFO) principle?
a) Queue
b) Stack
c) Linked List
d) Tree
Answer: b) Stack

5. What does the acronym ‘OOP’ stand for in programming?


a) Overloaded Object Program
b) Object-Oriented Programming
c) Organized Optimization Programming
d) Original Object Processing
Answer: b) Object-Oriented Programming
ZB
MCQS ZB
Midterm preparation file

6. Which of the following is NOT a valid type of constructor in C++?


a) Default constructor
b) Copy constructor
c) Parameterized constructor
d) Friend constructor
Answer: d) Friend constructor

7. In an AVL tree, what is the balance factor of a node?


a) Difference between left and right subtrees
b) Height of the left subtree
c) Height of the right subtree
d) Depth of the node
Answer: a) Difference between left and right subtrees

8. Which type of search algorithm is used in a binary search tree?


a) Linear search
b) Binary search
c) Depth-first search
d) Breadth-first search
Answer: b) Binary search

9. Which of the following is a characteristic of a recursive function?


a) It must contain a base case
b) It does not return any value
c) It can only work with arrays
d) It is always more efficient than iterative solutions
Answer: a) It must contain a base case

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

14. What is the primary purpose of a hash function?


a) To sort elements
b) To encrypt data
c) To map data to a fixed-size value
d) To store data in a sorted order
Answer: c) To map data to a fixed-size value

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

16. What is the worst-case time complexity of merge sort?


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

17. Which of the following is used to prevent infinite recursion in a function?


a) Recursion limit
b) Base case
c) Function pointer
d) Stack pointer
Answer: b) Base case

18. Which of the following is a key feature of a binary search tree?


a) All nodes have only two children
b) The left child is always less than the parent node
c) The right child is always greater than the parent node
d) All of the above
Answer: d) All of the above

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

20. Which of the following algorithms is NOT a comparison-based sorting algorithm?


a) Quick sort
b) Merge sort
c) Heap sort
d) Counting sort
Answer: d) Counting sort
MCQS MIDTERM PREPARATION FILE ZB

21. Which of the following is an example of a non-linear data


structure?

ZB
a) Array
b) Stack
c) Tree
d) Queue
Answer: c) Tree

22. Which of the following is NOT a feature of dynamic


programming?
a) Solving overlapping subproblems
b) Using recursion
c) Storing solutions to subproblems
d) Greedy choice property
Answer: d) Greedy choice property

23. Which of the following is true about depth-first search


(DFS) in a graph?
a) DFS uses a queue for storing nodes
b) DFS explores a node's neighbors before moving deeper
c) DFS is implemented using recursion or stack
d) DFS always finds the shortest path
Answer: c) DFS is implemented using recursion or stack

24. Which of the following is the best data structure for


implementing a priority queue?
a) Stack
b) Queue
c) Binary heap
d) Linked list
Answer: c) Binary heap

25. Which type of error occurs when a program attempts to


access a memory location that it is not allowed to?
a) Syntax error
b) Logic error
c) Runtime error
d) Linker error
Answer: c) Runtime error
ZB
ZB
MCQS Midterm preparation file

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

27. Which of the following is true about the QuickSort algorithm?


a) It always performs the same number of comparisons
b) It works by partitioning the array around a pivot element
c) It uses dynamic programming
d) It has a worst-case time complexity of O(n^2) in all cases
Answer: b) It works by partitioning the array around a pivot element

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

29. Which of the following is true for a binary tree?


a) Each node has at most two children
b) It is always balanced
c) The left subtree is always smaller than the right subtree
d) All of the above
Answer: a) Each node has at most two children

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

Midterm preparation file

31. Which of the following is true about a doubly linked list?


a) Each node has only one pointer
b) It supports traversal in both directions
c) It is more space-efficient than a singly linked list
d) It cannot be used to implement a stack
Answer: b) It supports traversal in both directions

32. Which of the following is the primary advantage of using a hash


table?
a) Sorted order of elements
b) Fast access to elements
c) Lower memory consumption
d) Ability to handle duplicates
Answer: b) Fast access to elements

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

34. In which data structure are elements arranged in a hierarchical manner?

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

Answer: b) Dijkstra’s algorithm

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

37. Which of the following operations is performed at the end of a


queue?
a) Enqueue
b) Dequeue
c) Peek
d) Pop
Answer: a) Enqueue

38. What is the worst-case time complexity of the Bubble Sort


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

39. Which of the following is a correct property of a heap data


structure?
a) It is always a balanced binary tree
b) The parent node is always larger than both of its children in a
max-heap
c) The tree is complete
d) All of the above
Answer: d) All of the above
ZB

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

42. Which of the following is NOT a type of binary tree?


a) Complete binary tree
b) Balanced binary tree
c) Ternary tree
d) Full binary tree
Answer: c) Ternary tree

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

44. Which of the following is an advantage of using a stack?


a) Supports efficient search operations
b) Useful in recursion
c) Allows efficient random access
d) Allows elements to be accessed in a sorted order
Answer: b) Useful in recursion

45. Which of the following is the best description of a queue?


a) Follows Last In First Out (LIFO)
b) Follows First In First Out (FIFO)
c) A dynamic data structure
d) A collection of elements with no order
Answer: b) Follows First In First Out (FIFO)

46. What is the primary disadvantage of using a hash table?


a) Slow lookup time
b) Requires sorting
c) It has a fixed size
d) Collisions may occur
Answer: d) Collisions may occur

47. Which of the following is a correct statement regarding the time


complexity of quicksort in the worst case?
a) O(n)
b) O(n^2)
c) O(n log n)
d) O(log n)
Answer: b) O(n^2)
ZB
MCQS ZB
Midterm preparation file

48. In which scenario would a linked list be more efficient than an


array?
a) Random access to elements
b) Frequent insertions and deletions
c) Sorting elements
d) Searching for elements
Answer: b) Frequent insertions and deletions

49. Which type of tree is used in a balanced binary search tree?


a) AVL tree
b) Binary heap
c) Trie
d) Red-Black tree
Answer: a) AVL 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: [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