




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which programming paradigm emphasizes the use of objects encapsulating data and behaviors? A) Procedural programming B) Functional programming C) Object-oriented programming D) Logic programming Answer: C Explanation: Object-oriented programming (OOP) centers around objects that combine data (attributes) and behaviors (methods), promoting encapsulation and modularity. Question 2. Which phase in the program development life cycle involves translating the design into executable code? A) Problem understanding B) Implementation C) Testing D) Maintenance Answer: B
Explanation: Implementation is the phase where the actual coding occurs based on the design specifications. Question 3. Which characteristic is NOT typical of an efficient algorithm? A) Correctness B) High time complexity in the best case C) Finite steps D) Produces a solution within resource constraints Answer: B Explanation: High time complexity in the best case indicates inefficiency; efficient algorithms aim for low time and space complexity. Question 4. Which of the following is an advantage of using flowcharts to represent algorithms? A) They provide a step-by-step pseudocode description B) They visually depict process flow and decision points C) They automatically generate code D) They are only useful for recursive algorithms Answer: B
Explanation: Algorithm design often involves balancing speed (execution time) and memory usage, as optimizing one can adversely affect the other. Question 7. Which statement correctly describes structured programming? A) It uses only object-oriented concepts B) It involves breaking programs into sequence, selection, and iteration structures C) It relies solely on recursion D) It requires dynamic memory allocation Answer: B Explanation: Structured programming emphasizes clear control flow using sequence, selection (if/else, switch), and loops, avoiding goto statements. Question 8. Which mechanism allows a function to modify the actual argument passed to it? A) Pass by value B) Pass by reference C) Call by name D) Call by value-result
Answer: B Explanation: Pass by reference allows the function to directly modify the argument's original memory location, unlike pass by value. Question 9. What is a key disadvantage of recursion? A) It simplifies code B) It can lead to stack overflow if not properly controlled C) It always runs faster than iteration D) It doesn't require a base case Answer: B Explanation: Recursive calls consume stack space; without proper base cases or with excessive recursion depth, it can cause stack overflow. Question 10. Which of the following best describes encapsulation in OOP? A) Deriving classes from a base class B) Hiding internal object data and exposing only necessary parts through public methods C) Overloading functions for different data types D) Creating multiple constructors in a class
D) Abstraction Answer: C Explanation: Polymorphism allows objects of derived classes to be treated as objects of the base class, supporting method overriding at runtime. Question 13. What is the primary purpose of a constructor in a class? A) To delete objects B) To initialize new objects of the class C) To define class attributes D) To handle exceptions Answer: B Explanation: Constructors initialize an object upon creation, setting initial values for data members. Question 14. Which data structure is best suited for implementing a stack? A) Array or linked list B) Queue C) Tree D) Graph
Answer: A Explanation: Arrays and linked lists are common implementations for stacks, supporting push and pop operations efficiently. Question 15. Which operation is NOT typically associated with a stack? A) Push B) Pop C) Enqueue D) Peek Answer: C Explanation: Enqueue is associated with queues; stacks use push, pop, and peek for their operations. Question 16. In a queue, which operation removes the element at the front? A) Enqueue B) Dequeue C) Peek D) Insert Answer: B
Explanation: Doubly linked lists have pointers to both previous and next nodes, enabling bidirectional traversal. Question 19. Which operation is characteristic of a doubly linked list but not a singly linked list? A) Insertion at the beginning B) Deletion from the end C) Traversal in both directions D) Searching for a value Answer: C Explanation: Doubly linked lists support traversal in both forward and backward directions due to two pointers per node. Question 20. Which is an advantage of using a linked list over an array? A) Constant-time access to any element by index B) Dynamic memory allocation allows flexible size growth C) Easier to implement binary search D) Better cache performance Answer: B
Explanation: Linked lists can grow dynamically without reallocation, unlike arrays that require resizing. Question 21. Which traversal method visits nodes in the order: root, left subtree, right subtree? A) Inorder B) Preorder C) Postorder D) Level order Answer: B Explanation: Preorder traversal visits root first, then left subtree, then right subtree. Question 22. Which binary tree traversal is best suited for copying the tree structure? A) Inorder B) Preorder C) Postorder D) Level order
D) Traversing the tree Answer: A Explanation: Deletion of a node with two children requires replacement with the inorder successor (minimum in right subtree), which involves additional steps. Question 25. Which property does a min-heap satisfy? A) Parent node is always less than or equal to its children B) Parent node is always greater than or equal to its children C) All levels are fully filled D) It is a complete binary tree with no specific heap property Answer: A Explanation: In a min-heap, each parent is less than or equal to its children, ensuring the minimum element is at the root. Question 26. Which operation maintains the heap property after insertion? A) Heapify-up (percolate up) B) Heapify-down (percolate down) C) Bubble sort
D) Binary search Answer: A Explanation: Heapify-up restores the heap property after inserting a new element at the bottom. Question 27. Which graph representation uses a two-dimensional matrix? A) Adjacency list B) Incidence matrix C) Adjacency matrix D) Edge list Answer: C Explanation: An adjacency matrix uses a 2D array to represent edges between vertices. Question 28. Which graph traversal algorithm is suitable for finding the shortest path in an unweighted graph? A) Depth-First Search (DFS) B) Breadth-First Search (BFS) C) Dijkstra's algorithm
C) Linked list D) Stack Answer: B Explanation: Heaps efficiently implement priority queues, allowing quick access to the highest or lowest priority element. Question 31. Which search algorithm requires the data to be sorted beforehand? A) Linear search B) Binary search C) Hashing D) Sequential search Answer: B Explanation: Binary search operates efficiently only on sorted data, dividing the search interval each step. Question 32. What is the worst-case time complexity of binary search? A) O(1) B) O(log n)
C) O(n) D) O(n log n) Answer: B Explanation: Binary search halves the search space each iteration, resulting in O(log n) time complexity. Question 33. Which sorting algorithm is based on repeatedly swapping adjacent elements to sort the list? A) Bubble Sort B) Merge Sort C) Quick Sort D) Heap Sort Answer: A Explanation: Bubble Sort compares and swaps adjacent elements, bubbling the largest to the end each pass. Question 34. Which sorting algorithm is considered the most efficient in average cases for large datasets? A) Bubble Sort
B) Indexed sequential organization C) Direct access organization D) Hash organization Answer: A Explanation: Sequential file organization stores records one after another, suitable for batch processing. Question 37. Which external sorting technique is used when data exceeds the main memory size? A) Bubble sort B) Merge sort (external variant) C) Selection sort D) Radix sort Answer: B Explanation: External merge sort efficiently sorts large datasets by dividing into manageable chunks and merging sorted runs. Question 38. Which algorithmic technique involves breaking a problem into smaller subproblems, solving them independently, and combining solutions?
A) Divide and Conquer B) Greedy C) Dynamic Programming D) Backtracking Answer: A Explanation: Divide and Conquer splits the problem, solves subproblems recursively, and combines results to form a solution. Question 39. Which approach is characteristic of greedy algorithms? A) Always finding the global optimum by making locally optimal choices B) Considering all possible solutions before choosing C) Solving subproblems recursively with overlapping substructures D) Exhaustively searching the solution space Answer: A Explanation: Greedy algorithms make the best local choice at each step with the hope of finding a global optimum. Question 40. Which dynamic programming technique is used to solve problems with overlapping subproblems efficiently?