CS201 Midterm and Finall Term Preparation by ZB
CS201 Midterm and Finall Term Preparation by ZB
https://whatsapp.com/channel/0029VafvOcy90x2tPbUaX02I
CS201
ZB
MCQS
1. What is the time complexity of accessing an element in an array? a) O(1)
b) O(n)
c) O(log n)
d) O(n^2)
Answer: a) O(1)
9. Which of the following represents the worst-case time complexity of Quick Sort? a)
O(n)
b) O(log n)
c) O(n log n)
d) O(n^2)
Answer: d) O(n^2)
ZB
c) Linked List
d) Array
Answer: b) Stack
12. Which of the following is a feature of a binary search tree? a) Every node has
two children
b) The left child is always greater than the parent
c) The right child is always smaller than the parent
d) Nodes are ordered in a way that every left child is smaller than the parent and
every right child is greater.
Answer: d) Nodes are ordered in a way that every left child is smaller than the
parent and every right child is greater.
14. Which of the following is a valid way to declare a constant in Python? a) const x
= 10
b) final x = 10
c) x = 10
d) Python does not have constants
Answer: d) Python does not have constants
ZB
16. In which of the following algorithms, a divide and conquer approach is used? a) ZB
Quick Sort
b) Bubble Sort
c) Selection Sort
d) Insertion Sort
Answer: a) Quick Sort
17. Which of the following best describes the purpose of a constructor in a class? a)
It defines a method to delete the object
b) It initializes the object's attributes
c) It defines the class's behavior
d) It checks if the object is valid
Answer: b) It initializes the object's attributes
18. Which data structure is most suitable for implementing recursion? a) Queue
b) Stack
c) Linked List
d) Array
Answer: b) Stack
19. Which of the following sorting algorithms has the best average-case time
complexity? a) Selection Sort
b) Bubble Sort
c) Merge Sort
d) Quick Sort
Answer: c) Merge Sort
20. Which of the following is not a valid data type in Python? a) int
b) float
c) character
d) string
Answer: c) character
MCQS MIDTERM PREPARATION FILE ZB
21. Which function is used to obtain the length of a list in Python? a) length()
b) len()
ZB
c) size()
d) count()
Answer: b) len()
22. Which of the following is a type of loop used in programming? a) for loop
b) while loop
c) do-while loop
23. In which data structure does each element have a unique identifier? a) List
b) Set
c) Dictionary
d) Queue
Answer: c) Dictionary
24. Which of the following is true about Python's list? a) Lists are immutable
add()
b) append()
c) insert()
27. Which of the following functions is used to sort a list in Python? a) sort()
b) order()
c) organize()
d) sorted()
Answer: a) sort()
29. Which of the following best describes an abstract class in OOP? a) A class
with no methods
b) A class that can be instantiated
c) A class that cannot be instantiated but can be inherited
d) A class that does not require constructors
Answer: c) A class that cannot be instantiated but can be inherited
30. What does the 'return' statement do in a function? a) Ends the function
without returning a value
b) Terminates the program
c) Returns a value and exits the function
d) None of the above
Answer: c) Returns a value and exits the function
ZB
MCQS ZB
b) error
c) try-except
d) assert
Answer: c) try-except
33. What is the time complexity of Bubble Sort in the worst case? a) O(n)
b) O(n^2)
c) O(log n)
d) O(n log n)
Answer: b) O(n^2)
34. Which of the following is a method to remove the last element of a list in Python? a)
pop()
b) delete()
c) remove()
d) discard()
Answer: a) pop()
35. Which of the following data structures uses a FIFO (First In, First Out) order? a) Queue
b) Stack
c) Linked List
d) Tree
Answer: a) Queue
MCQS ZB
ZB
Midterm preparation file
36. Which of the following is not a built-in Python data structure? a) List
b) Dictionary
c) Tree
d) Set
Answer: c) Tree
37. Which algorithm is used for finding the shortest path in a graph? a) Bubble Sort
b) Quick Sort
c) Dijkstra's Algorithm
d) Merge Sort
38. What is the time complexity of accessing an element in a linked list? a) O(1)
b) O(n)
c) O(log n)
d) O(n^2)
Answer: b) O(n)
39. Which of the following best describes the concept of inheritance in object-oriented
40. Which of the following is a valid syntax to define a function in Python that takes two
c) function(a, b) = def:
ZB
Midterm preparation file
41. Which of the following is an example of a class method in Python? a)
@staticmethod
b) @classmethod
c) @method
d) def method()
Answer: b) @classmethod
42. Which of the following methods adds an element to the beginning of a list in
Python? a) append()
b) insert()
c) push()
d) add()
Answer: b) insert()
43. What is the time complexity of accessing an element in a hash table? a) O(1)
b) O(n)
c) O(log n)
d) O(n^2)
Answer: a) O(1)
44. Which of the following operators is used to combine two lists in Python? a) +
b) -
c) *
d) &
Answer: a) +
45. Which of the following sorting algorithms is considered the fastest in average
cases? a) Selection Sort
b) Quick Sort
c) Merge Sort
d) Bubble Sort
Answer: b) Quick Sort
ZB
ZB
MCQS
Midterm preparation file
46. Which of the following is the correct way to create a dictionary in Python? a)
dict = {1: 'apple', 2: 'banana'}
b) dict = (1: 'apple', 2: 'banana')
c) dict = [1: 'apple', 2: 'banana']
d) dict = {1, 'apple', 2, 'banana'}
Answer: a) dict = {1: 'apple', 2: 'banana'}
47. Which function is used to find the maximum value in a list in Python? a) max()
b) highest()
c) largest()
d) get_max()
Answer: a) max()
48. Which of the following is not a valid way to create a loop in Python? a) for i in
range(10):
b) while i < 10:
c) repeat i until 10:
d) while True:
Answer: c) repeat i until 10:
49. Which of the following methods removes an element from a list in Python? a)
remove()
b) pop()
c) discard()
d) delete()
Answer: a) remove()
ZB
MCQS
Midterm preparation file
51. Which data structure does the 'pop()' function belong to? a) Queue
b) Stack
c) Linked List
d) Dictionary
Answer: b) Stack
52. Which of the following statements is true about a hash table? a) Hash tables store elements in a
sorted order
b) Hash tables have fast access times for searches
c) Hash tables only allow unique keys
d) Both b and c
Answer: d) Both b and c
53. Which of the following is true about recursion? a) A recursive function must always call itself
twice
b) Recursive functions must have a base case to prevent infinite recursion
c) Recursion is slower than iteration
d) All recursive functions are always optimized
Answer: b) Recursive functions must have a base case to prevent infinite recursion
54. Which of the following is used to break out of a loop in Python? a) exit()
b) break
c) stop
d) return
Answer: b) break
55. Which of the following best describes an adjacency matrix in graph theory? a) A matrix where
each element represents the weight of an edge
b) A list of all vertices
c) A list of connected nodes only
d) A 2D array that represents the connections between nodes in a graph
Answer: d) A 2D array that represents the connections between nodes in a graph
MCQS Midterm preparation file ZB
56. Which of the following is true about Python's dictionaries? a) They are ordered
collections
b) They store key-value pairs
c) Keys in a dictionary must be mutable
d) None of the above
Answer: b) They store key-value pairs
57. Which of the following is a common use of a stack? a) Undo functionality in text
editors
b) Calculations in arithmetic expressions
c) Both a and b
d) Sorting a list
Answer: c) Both a and b
58. What does the 'del' statement do in Python? a) Deletes an element from a list
b) Deletes a variable
c) Deletes an entire dictionary
d) All of the above
Answer: d) All of the above
60. Which of the following is used to define a class in Python? a) class MyClass:
b) MyClass class:
c) class = MyClass
d) def MyClass:
Answer: a) class MyClass:
ZB
MCQS Midterm preparation file
61. What is the time complexity of the merge operation in Merge Sort? a) O(1)
b) O(n)
c) O(n log n)
d) O(n^2)
Answer: b) O(n)
62. Which of the following is a primary characteristic of a queue? a) Last In First Out (LIFO)
b) First In First Out (FIFO)
c) It is unordered
d) It allows random access to elements
Answer: b) First In First Out (FIFO)
63. Which of the following best describes the purpose of a hash function in a hash table? a) To
retrieve values quickly
b) To compute the index for a given key
c) To check for duplicate keys
d) To ensure keys are unique
Answer: b) To compute the index for a given key
64. Which of the following is true about a doubly linked list? a) It can only be traversed in one
direction
b) It stores two pointers per node, one to the next and one to the previous node
c) It is faster than a singly linked list
d) It does not support deleting elements efficiently
Answer: b) It stores two pointers per node, one to the next and one to the previous node
65. Which of the following is not a valid Python loop? a) for i in range(5):
b) while x > 10:
c) do while x < 5:
d) None of the above
Answer: c) do while x < 5:
MCQS Midterm preparation file ZB
66. What is the purpose of the 'finally' block in exception handling in Python? a) To catch
exceptions
b) To execute code after a try block regardless of whether an exception was raised
c) To re-raise an exception
d) To define default exception handling
Answer: b) To execute code after a try block regardless of whether an exception was raised
67. Which of the following sorting algorithms is considered stable? a) Quick Sort
b) Heap Sort
c) Merge Sort
d) Selection Sort
Answer: c) Merge Sort
68. Which of the following is true about a binary search tree? a) The left child is always
greater than the parent
b) The right child is always smaller than the parent
c) Both the left and right subtrees are binary search trees
d) Binary search trees are unbalanced
Answer: c) Both the left and right subtrees are binary search trees
70. Which of the following is true about Python dictionaries? a) Keys must be mutable
b) They are ordered collections of key-value pairs
c) Values must be unique
d) They do not allow duplicate keys
Answer: d) They do not allow duplicate keys
MCQS
Midterm preparation file ZB
72. What does the 'break' statement do in a loop? a) Exits the loop entirely
b) Skips the current iteration and continues to the next one
c) Stops the program execution
d) Resets the loop variable
Answer: a) Exits the loop entirely
74. Which of the following is the correct way to create a set in Python? a) set =
[1, 2, 3]
b) set = (1, 2, 3)
c) set = {1, 2, 3}
d) set = <1, 2, 3>
Answer: c) set = {1, 2, 3}
75. What is the result of applying the '==' operator in Python? a) It checks if two
variables are the same object
b) It checks if two variables have the same value
c) It assigns one variable to another
d) It compares the data types of two variables
Answer: b) It checks if two variables have the same value
MIDTERM Important topic from 1
to 22 lectures
1. Basics of Programming
Introduction to programming languages (C++, Python, or Java, depending on the
course).
Syntax and semantics of the chosen programming language.
Writing and understanding simple programs.
3. Control Structures
Conditional statements (if, if-else, switch).
Looping structures (for, while, do-while).
Nested loops and control statements like break and continue.
4. Functions
Function declaration, definition, and calling.
Parameter passing (by value and by reference).
Scope of variables (local vs global).
Recursion basics.
5. Arrays
Declaration and initialization.
Single-dimensional and multi-dimensional arrays.
Traversing and basic operations on arrays.
7. Basic Input/Output
cin and cout (in C++) or equivalent functions in other languages.
File handling basics (if included).
Study Tips:
Review lecture slides, assignments, and practice questions.
Focus on solving past papers and sample questions.
Understand how to trace code manually.
MIDTERM important topic ZB
9. Operators
Arithmetic, relational, and logical operators.
Bitwise operators (if included).
Operator precedence and associativity.
10. Strings
13. Structures
d) Both b and c
a) void
b) int
c) float
d) char
Answer: b) int
a) for loop
b) while loop
c) do-while loop
a) int* ptr;
b) int ptr*;
c) int ptr;
15. What is the time complexity of binary search in the worst case?
a) O(1)
b) O(n)
c) O(log n)
d) O(n^2)
Answer: c) O(log n)
Mcqs Final term preparation ZB
a) #import
b) #include
c) #library
Answer: b) #include
a) 1
b) 2
c) 4
d) 8
Answer: a) 1
a) ==
b) >
c) !=
24. Which feature of OOP allows functions with the same name but different parameters?
a) Encapsulation
b) Polymorphism
c) Inheritance
Answer: b) Polymorphism
a) Ends a program
c) Ends a statement
26. Which loop executes the most times for a nested loop structure?
a) Outer loop
b) Inner loop
c) Both execute equally
d) None of the above
Answer: b) Inner loop
40. How many objects can be created from a single class in C++?
a) One
b) Two
c) Unlimited
d) None of the above
Answer: c) Unlimited
Mcqs Final term preparation ZB
42. What does the const keyword signify when used with a function?
a) The function cannot be overridden
b) The function cannot modify class members
c) The function is private
d) None of the above
Answer: b) The function cannot modify class members
60. What is the return type of the main() function in modern C++?
a) void
b) int
c) string
d) char
Answer: b) int
ZB
MCQS ZB
Midterm preparation file
Software / Tools:
Is drive m vu k related sb k sb software add hain jin ko kio bhi
software ki zaroorat hai tu wo is link ko click kr
k download kr sakty hain.
Mega drive:
https://mega.nz/folder/tA5x1LYa#9QpZ11pGc9jERh16nJduKg
Note:
Is file m kisi bhi kisam ka kio bhi virus nahi hai sb safe hai aur sb
software/tools sirf PC/laptop k liye hain.
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
Payary Students kbi b Only files pe depend mat kea kryn just files read krke uspe
total depend krna it's not Good Vu ke tamat Papers Conceptual hoty hn Agr apky
concepts
Ap thori se mehnat Kryn bs ap kbi b fail nahe hongy jab himat haar jao to un maa
baap k bare m socha kro Jo apki fees dete hn jinko ap pe bohat dawy hn Jo har
jga kehty hn Hamara bacha university Mai parh rha ha un maa baap ki umeedy
Kahi mat Tory apny kea naa Sahi apny maa baap k leay mehnat kro himat kro
Everything is possible just do it my Family
Apko Kuch b samj naa ay yaa ap Kuch b pochna chahy to ap mujsy contact kr
saqty hn
> ZB
ZB
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
Dear students, all Virtual University groups, from A to Z,
have been created by students themselves. Virtual
University does not have any official groups. If anyone
claims their group is official, they are fake. Please be
cautious. Virtual University has not yet made any
announcement regarding an official WhatsApp group.
AL-Quran