Python 2025 Mcqs
Python 2025 Mcqs
o b) Problem definition
o c) Debugging
o d) Program execution
Answer: b) Problem definition
o a) Clear objectives
o b) Uncertain requirements
o c) Specific constraints
o d) Definite scope
Answer: b) Uncertain requirements
o a) Debugging
o b) Problem design
o c) Program design
o d) Documentation
Answer: c) Program design
4. In problem-solving, what is the term for breaking a problem down into smaller sub-
problems?
o a) Problem decomposition
o b) Problem abstraction
o c) Problem iteration
o d) Debugging
Answer: a) Problem decomposition
o b) Algorithmic approach
o c) Guessing
o d) Random approach
Answer: b) Algorithmic approach
6. What is debugging?
o a) Writing code
o b) Designing algorithms
o d) Deleting files
Answer: c) Testing and fixing errors in the code
o a) Division by zero
o b) Misspelled keywords
o c) Incorrect algorithm
8. Which type of error occurs when the program runs but produces incorrect results?
o a) Logical error
o b) Syntax error
o c) Runtime error
o d) Semantic error
Answer: a) Logical error
9. What type of error will occur if you try to access a variable that has not been defined
in Python?
o a) Runtime error
o b) Syntax error
o c) NameError
o d) ValueError
Answer: c) NameError
• a) Compile-time error
• b) Execution error
• c) Logical error
• d) Syntax error
Answer: b) Execution error
Documentation
• b) Variable names
• a) Easier maintenance
• b) Faster execution
• c) Improved collaboration
• d) Better understanding
Answer: b) Faster execution
• a) Code comments
• b) User manuals
• c) Inline documentation
• d) Variable documentation
Answer: b) User manuals
• a) Decision
• b) Input/output
• c) Process
• d) Flow of control
Answer: c) Process
• a) Rectangle
• b) Diamond
• c) Oval
• d) Circle
Answer: b) Diamond
• b) A table that lists all possible decisions and their corresponding actions
• a) Sequence
• b) Selection
• c) Goto statement
• d) Iteration
Answer: c) Goto statement
22. In structured programming, which of the following statements is used for selection?
• a) for loop
• b) if-else statement
• c) while loop
• d) print statement
Answer: b) if-else statement
• a) To reduce complexity
• c) To execute faster
• a) if statement
• b) while loop
• c) switch statement
• d) break statement
Answer: b) while loop
25. What type of programming is based on the concept of dividing a program into smaller,
manageable modules?
• a) Procedural programming
• b) Object-oriented programming
• c) Functional programming
• d) Structured programming
Answer: d) Structured programming
Programming Methodologies: Top-down and Bottom-up
• a) Object-oriented programming
• c) Functional programming
• d) GOTO-based programming
Answer: a) Object-oriented programming
• a) External libraries
• b) Functions and procedures
• c) Classes
• d) Conditional statements
Answer: b) Functions and procedures
31. Which of the following is the correct extension for a Python file?
• a) .txt
• b) .py
• c) .java
• d) .pyp
Answer: b) .py
32. What is the first line of a Python program typically used for?
• a) Importing libraries
• b) Printing output
• c) Writing comments
• d) Declaring variables
Answer: c) Writing comments
33. Which of the following is the correct way to print "Hello, World!" in Python?
• b) printf("Hello, World!")
• c) print("Hello, World!")
• a) Compiled structure
• b) Linear structure
• c) Object-oriented structure
• d) Modular structure
Answer: d) Modular structure
• a) Parentheses
• b) Curly braces
• c) Indentation
• d) Square brackets
Answer: c) Indentation
• a) MemoryAllocator
• b) GarbageCollector
• c) pymalloc
• d) PyMem
Answer: c) pymalloc
• a) To delete files
• c) To delete functions
• d) To delete comments
Answer: b) To delete variables and free memory
Miscellaneous
• a) High-level language
• b) Compiled language
• c) Interpreted language
• d) Object-oriented
Answer: b) Compiled language
42. What is the main advantage of Python over low-level programming languages?
• a) size()
• b) length()
• c) len()
• d) count()
Answer: c) len()
44. What will be the output of the following Python code: print(type(10))?
• a) <class 'int'>
• b) <class 'float'>
• c) Integer
• d) Number
Answer: a) <class 'int'>
45. What type of error is produced by the following Python code? print(10/0)
• a) SyntaxError
• b) ZeroDivisionError
• c) ValueError
• d) TypeError
Answer: b) ZeroDivisionError
• a) define
• b) func
• c) def
• d) lambda
Answer: c) def
47. What will be the output of the following Python code: print(2**3)?
• a) 5
• b) 8
• c) 6
• d) 9
Answer: b) 8
• a) catch
• b) exception
• c) try
• d) error
Answer: c) try
• a) To compare values
• d) To declare a variable
Answer: b) To compare memory locations
• a) import library_name
• b) module library_name
• c) include library_name
• d) from library_name
Answer: a) import library_name
Unit 2:
o a) print 2 + 3
o b) print(2 + 3)
o c) output(2 + 3)
o d) cout << 2 + 3
Answer: b) print(2 + 3)
o a) Using braces { }
o b) Using parentheses ( )
o c) Using colons :
o a) 5 * 2
o b) 5 # 2
o c) 5 **
o d) 5 @ 2
Answer: a) 5 * 2
o a) 2nd_variable
o b) firstVariable
o c) @variable
o d) None
Answer: b) firstVariable
o a) if
o b) elif
o c) true
o d) return
Answer: c) true (correct form is True)
o a) A type of function
o c) A variable name
o d) An operator
Answer: b) A fixed value like a number or string
o a) 'Hello'
o b) Hello
o c) 123Hello
o d) "123
Answer: a) 'Hello'
o a) *
o b) **
o c) ^
o d) ~
Answer: b) **
o a) ==
o b) =
o c) &
o d) !
Answer: a) ==
o a) |
o b) and
o c) or
o d) &&
Answer: a) |
o a) &&
o b) &
o c) and
o d) |
Answer: c) and
o b) True
o c) 0
o d) None
Answer: b) True
15. What does the following Python expression return: 5 > 3 if True else 3 > 5?
o a) True
o b) False
o c) SyntaxError
o d) None
Answer: a) True
o a) ==
o b) =
o c) ->
o d) :=
Answer: b) =
o a) +=
o b) ++
o c) -=
o d) **
Answer: b) ++
o a) |
o b) ^
o c) ~
o d) &
Answer: b) ^
o a) ++
o b) //
o c) **
o d) %
Answer: a) ++
Creating Python Programs: Input and Output Statements, Control Statements, Defining
Functions, Errors and Exceptions
21. Which of the following functions is used to take input from the user in Python?
o a) input()
o b) raw_input()
o c) get_input()
o d) read()
Answer: a) input()
22. What will be the output of the following code: print("Hello", "World")?
o a) Hello,World
o b) Hello World
o c) HelloWorld
o d) Hello-World
Answer: b) Hello World
23. Which of the following control structures is used for looping in Python?
o a) if
o b) for
o c) else
o d) elif
Answer: b) for
o b) To skip the current iteration of the loop and continue with the next
26. What is the output of the following code: print(1 == 1 and 2 == 2)?
o a) True
o b) False
o c) None
o d) 0
Answer: a) True
o b) 3.33
o c) 3.3333333333333335
o d) None
Answer: c) 3.3333333333333335
28. Which of the following functions can be used to exit a Python program?
o a) sys.exit()
o b) exit()
o c) quit()
29. What is the difference between the break and continue statements in Python?
o a) break terminates the loop, while continue skips the current iteration
o b) continue terminates the loop, while break skips the current iteration
o d) An infinite loop
Answer: a) A function that calls itself
32. What is the output of the following code: print(5 if 4 > 2 else 10)?
o a) 5
o b) 10
o c) None
o d) SyntaxError
Answer: a) 5
o a) break
o b) return
o c) exit
o d) continue
Answer: b) return
o a) for
o b) if
o c) elif
o d) else
Answer: a) for
35. What is the output of the following Python code: for i in range(3): print(i)?
o a) 0 1 2
o b) 1 2 3
o c) 1 2 3 4
o d) None
Answer: a) 0 1 2
o d) Recursive functions
Answer: a) Conditional statements inside other conditional statements
37. Which of the following is the correct syntax for a recursive function?
o a) Recursion
o c) Calling a function
o d) Importing a module
Answer: b) Looping through a list
40. What is the output of the following Python code: while True: break print('Hello')?
o a) Hello
o b) True
o c) None
o d) No output
Answer: d) No output
o a) Stack
o b) Queue
o c) Tree
o d) List
Answer: c) Tree
42. What is the output of the following Python code: if 4 > 5: print('A') elif 4 < 5: print('B')
else: print('C')?
o a) A
o b) B
o c) C
o d) None
Answer: b) B
o a) if
o b) elif
o c) else
o a) if
o b) for
o c) else
o d) while
Answer: a) if
45. What is the output of the following Python code: def f(): return 1 print(f())?
o a) None
o b) 1
o c) True
o d) False
Answer: b) 1
o b) if x > 0: print(x)
o c) else: print(x)
47. Which of the following will stop the recursion in a recursive function?
o a) Base condition
o b) Loop
o c) return statement
o d) break statement
Answer: a) Base condition
o a) return
o b) break
o c) exit
o d) continue
Answer: a) return
49. What is the output of the following Python code: x = [1, 2, 3] for i in x: print(i)?
o a) 1 2 3
o b) 1
o c) None
o d) 0
Answer: a) 1 2 3
o a) if
o b) elif
o c) else
o d) while
Answer: d) while
Unit 3:
3. In recursion, the function calls are stored in a stack. What does the stack store?
o a) Function names
o c) Variables only
o d) Loops
Answer: b) Parameters and return values
6. Which data structure is used internally by the system to store recursive function calls?
o a) Queue
o b) Stack
o c) List
o d) Dictionary
Answer: b) Stack
7. In a stack diagram for a recursive function, what does each frame represent?
o a) Sorting an array
o c) Traversing a list
10. What is the correct base case for a recursive function calculating the factorial of a
number n?
o a) if n == 0: return 1
o b) if n == 1: return 1
o c) if n == 2: return 2
o d) if n == 10: return 10
Answer: a) if n == 0: return 1
Multiple Assignment
o a) x = 1, 2, 3
o b) a, b, c = 1, 2, 3
o c) a = b = c = 3
o d) Both b and c
Answer: d) Both b and c
12. What will the following code output: a, b = 5, 10; print(a, b)?
o a) 5 10
o b) 10 5
o c) 15
o d) SyntaxError
Answer: a) 5 10
o b) It assigns y to x
o c) It assigns x to y
o d) It raises a SyntaxError
Answer: a) It swaps the values of x and y
o a) a, b = 1, 2
o b) x = y = z = 0
o c) p, q = (1, 2)
o d) m, n, o = 4, 5
Answer: d) m, n, o = 4, 5 (requires 3 values)
o a) Tuple unpacking
o b) Multiple assignment
o c) List assignment
o d) Both a and b
Answer: d) Both a and b
The while Statement
o a) while(condition):
o b) for(condition):
o c) loop(condition):
o d) if(condition):
Answer: a) while(condition):
17. What will the following code output: x = 0; while x < 3: print(x); x += 1?
o a) 0 1 2
o b) 1 2 3
o c) 3 2 1
o d) None
Answer: a) 0 1 2
o a) break
o b) continue
o c) exit
o d) return
Answer: a) break
19. What will happen if the condition in a while loop never becomes False?
20. What is the difference between break and continue in a while loop?
o a) A list of lists
o b) A dictionary of lists
o c) A set of tuples
o d) A tuple of dictionaries
Answer: a) A list of lists
22. How can you access the element at the second row and third column in a 2D list table?
o a) table[2][3]
o b) table[1][2]
o c) table[2, 3]
o d) table(1, 2)
Answer: b) table[1][2]
23. Which method can be used to create an empty 2D table with 3 rows and 4 columns in
Python?
o a) [[0]*4]*3
o b) [[0]*3]*4
o d) [[4]*3]
Answer: c) [[0 for _ in range(4)] for _ in range(3)]
o c) Deleting a column
25. What is the output of table = [[1, 2], [3, 4]]; print(table[1][1])?
o a) 1
o b) 3
o c) 4
o d) 2
Answer: c) 4
o a) 4
o b) 5
o c) 6
o d) SyntaxError
Answer: b) 5
o a) for loop
o b) while loop
o c) Both a and b
o a) ell
o b) Hel
o c) lo
o d) llo
Answer: a) ell
o a) Using ==
o b) Using !=
o c) Using is
o d) Both a and b
Answer: d) Both a and b
o a) ace
o b) bdf
o c) abc
o d) None
Answer: a) ace
o a) 1
o b) 2
o c) -1
o d) 0
Answer: a) 1
33. Which function is used to check if one string contains another string?
o a) in
o b) contains
o c) find
o d) search
Answer: a) in
34. What does the find function return if the substring is not found in the string?
o a) -1
o b) 0
o c) None
o d) False
Answer: a) -1
o a) 6
o b) 5
o c) 0
o d) 1
Answer: a) 6
o a) list()
o b) split()
o c) join()
o d) None
Answer: a) list()
o a) HELLO
o b) hello
o c) Hello
o d) Error
Answer: a) HELLO
o a) True
o b) False
o c) None
o d) Error
Answer: a) True
o a) yth
o b) pyt
o c) tho
o d) Error
Answer: a) yth
40. Which method removes leading and trailing whitespaces from a string?
o a) strip()
o b) remove()
o c) replace()
o d) delete()
Answer: a) strip()
Additional Topics on Lists and Strings
o a) list1 + list2
o b) list1.append(list2)
o c) list1.join(list2)
o d) concatenate(list1, list2)
Answer: a) list1 + list2
o a) list()
o b) []
o c) Both a and b
o b) ['hello']
o c) ['h', 'hello']
o d) Error
Answer: a) ['h', 'e', 'l', 'l', 'o']
o a) append()
o b) add()
o c) extend()
o d) insert()
Answer: a) append()
o a) [1, 2, 3, 4]
o b) [1, 2]
o c) [3, 4]
o d) None
Answer: a) [1, 2, 3, 4]
o a) list.append()
o b) list.pop()
o c) list.insert()
o d) list.trim()
Answer: d) list.trim()
o b) [1, 2, 3]
o c) ["123"]
o d) Error
Answer: a) ['1', '2', '3']
o a) join()
o b) str()
o c) split()
o d) format()
Answer: a) join()
49. Which method returns the index of the first occurrence of a value in a list?
o a) find()
o b) index()
o c) locate()
o d) search()
Answer: b) index()
50. How can you remove an element from a list by its index in Python?
o a) del list[index]
o b) list.remove(index)
o c) list.pop(index)
o d) Both a and c
Answer: d) Both a and c
Unit 4:
o a) while
o b) for
o c) loop
o c) Prints 5
o a) lst[3]
o b) lst(3)
o c) lst[2]
4. What is the output of the following code: lst = [10, 20, 30, 40]; print(lst[1])?
o a) 10
o b) 20
o c) 30
o d) 40 Answer: b) 20
o a) length()
o b) size()
o c) len()
o a) 3
o b) 4
o c) 5
o d) 2 Answer: b) 4
o a) find()
o b) contains()
o c) in
o d) check() Answer: c) in
o a) True
o b) False
o c) Error
9. Which of the following is the correct syntax for a for loop that iterates over a list lst?
o a) for i in lst:
o a) {1, 2, 3}
o b) (1, 2, 3)
o c) [1, 2, 3]
o a) list.append()
o b) list.add()
o c) list.concat()
12. How can you remove an element from a list by its value?
o a) remove()
o b) delete()
o c) pop()
o a) [1, 3]
o b) [2, 3]
o c) [1, 2]
o a) pop()
o b) remove()
o c) clear()
o a) remove()
o b) clear()
o c) discard()
17. What is the output of lst = [1, 2, 3]; del lst[0]; print(lst)?
o a) [1, 2, 3]
o b) [2, 3]
o c) [1, 2]
18. What happens when you try to remove an element from an empty list using pop()?
o a) Nothing
o c) An IndexError is raised
19. Which of the following can be used to delete multiple elements from a list by slicing?
o a) del lst[start:end]
o b) remove(start:end)
o c) pop(start:end)
20. What will be the result of lst = [1, 2, 3]; lst.clear(); print(lst)?
o a) []
o b) None
o c) 1, 2, 3
o d) Error Answer: a) []
o a) lst.copy()
o b) list(lst)
o c) lst[:]
22. What is the result of lst1 = [1, 2, 3]; lst2 = lst1[:]; lst1.append(4); print(lst2)?
o a) [1, 2, 3]
o b) [1, 2, 3, 4]
o c) None
23. What is the output of lst1 = [1, [2, 3]]; lst2 = lst1[:]; lst2[1].append(4); print(lst1)?
o c) [2, 3, 4]
24. Which function is used to create a deep copy of a list (including nested lists)?
o a) copy.deepcopy()
o b) list.copy()
o c) deepcopy()
o a) [1, 2, 3]
26. How can you access the value 2 in the list lst = [[1, 2], [3, 4]]?
o a) lst[0][1]
o b) lst[1][1]
o c) lst[0, 1]
27. What will be the output of lst = [[1, 2], [3, 4]]; print(len(lst))?
o a) 2
o b) 4
o c) 6
o d) 1 Answer: a) 2
o a) 4
o b) 2
o c) 3
o d) Error Answer: a) 4
o b) def ClassName():
o c) object ClassName():
o a) __init__
o b) __new__
o c) __create__
o d) They are only callable inside the class Answer: a) They must have at least one
argument (self)
o a) Dog()
o b) new Dog()
o c) create Dog()
33. Which of the following creates an object obj of the class Car?
o b) obj = Car()
o c) obj = Car.create()
o b) :
o c) ->
o d) ; Answer: a) .
o a) __str__()
o b) __repr__()
o c) __string__()
36. Which of the following is the correct way to define a method inside a class?
o a) def methodName(self):
o b) def methodName():
o c) method methodName(self):
o a) def __init__(self):
o b) def init(self):
o c) class __init__(self):
python
CopyEdit
class Dog:
self.name = name
obj = Dog("Buddy")
print(obj.name)
o a) Dog
o b) Buddy
o c) None
o a) self.attr = value
o b) attr = value
o c) class.attr = value
o a) __del__()
o b) delete()
o c) remove()
Standard Libraries
o a) os
o b) math
o c) random
o a) random
o b) math
o c) os
o a) randint()
o b) random()
o c) randrange()
45. How can you get the current working directory using the os module?
o a) os.getcwd()
o b) os.pwd()
o c) os.directory()
o d) Selects the largest element from a list Answer: a) Selects a random element
from a list
47. Which method from the datetime module returns the current date and time?
o a) datetime.now()
o b) datetime.today()
o c) datetime.current()
o a) 6
o b) 8
o c) 9
o d) 4 Answer: b) 8
49. Which method from the time module makes the program sleep for a given number of
seconds?
o a) time.sleep()
o b) time.delay()
o c) time.wait()
o a) json.load()
o b) json.dumps()
o c) json.loads()
Unit 5:
Data Structures
• A) Stack
• B) Queue
• C) Array
• D) Linked List
Answer: B) Queue
• B) Graph
• C) Queue
• C) Random Access
• D) Ordered
Answer: A) Last In First Out (LIFO)
• A) Set
• B) Stack
• C) Queue
• D) Both B and C
Answer: D) Both B and C
5. In which data structure is the insertion and deletion performed at opposite ends?
• A) Stack
• B) Queue
• C) Linked List
• D) Array
Answer: B) Queue
• A) O(n)
• B) O(log n)
• C) O(1)
• D) O(n log n)
Answer: C) O(1)
• A) Queue
• B) Stack
• C) Array
• D) Tree
Answer: B) Stack
• A) 2h2h
• B) 2h+1−12h+1−1
• C) h2h2
• D) h+1h+1
Answer: B) 2h+1−12h+1−1
• A) Array
• B) Stack
• C) Queue
• D) Tree
Answer: D) Tree
Searching Algorithms
11. What is the time complexity of linear search in the worst case?
• A) O(1)
• B) O(log n)
• C) O(n)
• D) O(n log n)
Answer: C) O(n)
• A) Unsorted array
• B) Sorted array
• C) Linked list
• A) O(1)
• B) O(n)
• C) O(log n)
• D) O(n log n)
Answer: C) O(log n)
14. Which of the following searching algorithms is not efficient for large datasets?
• A) Linear Search
• B) Binary Search
• C) Jump Search
• D) Interpolation Search
Answer: A) Linear Search
Sorting Algorithms
• A) O(n)
• B) O(n log n)
• C) O(n^2)
• D) O(log n)
Answer: C) O(n^2)
• A) Quick Sort
• B) Heap Sort
• C) Merge Sort
• D) Selection Sort
Answer: C) Merge Sort
• A) O(n^2)
• B) O(n log n)
• C )O(1)
– D )O(n)
**Answer: **D )O(n)
19. Which sorting algorithm divides the dataset into smaller sub-arrays to sort them
recursively?
- A )Bubble Sort
- B )Insertion Sort
- C )Quick Sort
- D )Selection Sort
**Answer: **C )Quick Sort
20. Selection sort works by repeatedly selecting which element?
- A )The largest
- B )The smallest
- C )The middle
- D )The first
**Answer: **B )The smallest
21. Which sorting algorithm has a time complexity of O(n log n)?
- A )Bubble Sort
- B )Insertion Sort
- C )Merge Sort
- D )Selection Sort
**Answer: **C )Merge Sort
22. What type of sorting does not require additional memory space?
- A )Merge Sort
- B )Quick Sort
- C )Bubble Sort
- D )Heap Sort
**Answer: **C )Bubble Sort
23. Which algorithm sorts by repeatedly swapping adjacent elements if they are in the
wrong order?
- A )Insertion Sort
- B )Selection Sort
- C )Bubble Sort
- D )Merge Sort
**Answer: **C )Bubble Sort
26. The time complexity for deleting an element from a linked list is:
–A )O(1)
–B )O(n)
–C )O(log n)
–D )O(n log n)
–Answer: B) O(n).
27. In which data structure can you implement a priority queue efficiently?
–A )Array
–B )Linked List
–C )Heap
–D )Stack
–Answer: C) Heap.
28. Which type of search algorithm uses divide and conquer strategy?
–A )Linear Search
–B )Binary Search
–C )Jump Search
–D )Interpolation Search
–Answer: B) Binary Search.
29. In which case would you prefer insertion sort over other algorithms?
–A )When the dataset is large.
–B )When the dataset is small and almost sorted.
–C )When memory space is limited.
–D )None of the above.
–Answer: B) When the dataset is small and almost sorted.
33. What type of data structure would you use to implement depth-first search (DFS)?
–A )(Queue.)
–B )(Stack.)
–C )(Array.)
–D )(Linked List.)
—Answer: B) Stack.
34. In which scenario would you use a hash table instead of an array?
—A )(When you need to maintain order.)
—B )(When you need fast lookups.)
—C )(When you have limited memory.)
—D )(When you need to store duplicate values.)
—Answer: B) When you need fast lookups.
35. For which operation does a doubly linked list provide better performance than a singly
linked list?
—A )(Insertion at head.)
—B )(Deletion at tail.)
—C )(Traversal from head to tail.)
—D )(Accessing middle elements.)
—Answer: B) Deletion at tail.
36. Which sorting algorithm has a best-case performance that can be linear (O(n)) under
certain conditions?
—A )(Bubble sort.)
—B )(Insertion sort.)
—C )(Selection sort.)
—D )(Merge sort.)
—Answer: B) Insertion sort.
37. In a binary search tree, what property must hold true for each node's left and right
children?
—A )(Left child < parent < right child.)
—B )(Left child > parent > right child.)
—C )(Left child = parent = right child.)
—D )(Left child < parent > right child.)
—Answer: A) Left child < parent < right child.
38. Which searching algorithm can be used on both sorted and unsorted lists but performs
better on sorted lists?
—A )(Linear search.)
—B )(Binary search.)
—C )(Jump search.)
—D )(Exponential search.)
—Answer: C) Jump search.
39. What kind of data structure would you use to implement breadth-first search (BFS)?
—A )(Stack.)
—B )(Queue.)
—C )(Array.)
—D )(Linked List.)
—Answer: B) Queue.
41. For which operation do hash tables provide average-case constant time complexity
(O(1))?
—A)(Insertion.)
—B)(Search.)
—C)(Deletion.)
—D)(All of the above.)
—Answer: D) All of the above.
42. In quicksort, what happens if all elements are identical during partitioning?
—A)(The algorithm will run efficiently.)
—B)(It will lead to maximum recursion depth.)
—C)(It will always choose one element as pivot.)
—D)(None of the above.)
—Answer: B) It will lead to maximum recursion depth.
43. How does heap sort achieve its efficiency compared to other algorithms like bubble or
selection sort?
—A)(By using less memory.)
—B)(By maintaining a balanced tree structure.)
—C)(By performing fewer comparisons.)
—D)(By using randomization.)
—Answer: B) By maintaining a balanced tree structure.
44. What type of data structure allows for fast insertion and deletion from both ends but
not random access?
—A)(Array.)
—B)(Linked List.)
—C)(Deque.)
—D)(Hash Table.)
—Answer: C) Deque.
45. What happens when an attempt to insert an element into a full stack occurs?
--A)(The stack overflows.)
--B)(The stack shrinks.)
--C)(The stack becomes empty.)
--D)(Nothing happens; it remains full.)
--Answer: A) The stack overflows.
47. What type of tree allows for efficient searching, insertion, and deletion?
--A)(Binary Tree.)
--B)(Binary Search Tree.)
--C)(AVL Tree.)
--D)(Both B and C.)
--Answer: D) Both B and C.
48. Which data structure would you use to implement undo functionality in applications?
--A)(Queue.)
--B)(Stack.)
--C)(ArrayList.)
--D)(Hash Table.)
--Answer: B) Stack.
49. Which type of sorting algorithm divides data into two parts, sorts them separately, and
then merges them?
--A)(QuickSort.)
--B)(MergeSort.)
--C)(HeapSort.)
--D)(BubbleSort.)
--Answer: B) MergeSort.