19-SOFT-A1 Algorithms & Data Structures Exam C, Exams of Technology

Covers graph algorithms (BFS, DFS, Dijkstra’s, Kruskal’s, Prim’s), dynamic programming, greedy methods, and backtracking. Includes NP-completeness, approximation algorithms, and practical problem-solving in computational complexity.

Typology: Exams

2024/2025

Available from 06/05/2025

nicky-jone
nicky-jone 🇮🇳

2.9

(44)

28K documents

1 / 127

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
19-SOFT-A1 Algorithms & Data
Structures Exam C
Question 1. Which property best characterizes an algorithm?
A) It must be expressed in a programming language
B) It provides a step-by-step procedure to solve a specific problem
C) It is always recursive in nature
D) It can only be used for numerical problems
Answer: B
Explanation: An algorithm is a finite set of well-defined instructions that
provides a step-by-step procedure to solve a specific problem, regardless of
implementation language or problem type.
Question 2. Which of the following is NOT a characteristic of a good
algorithm?
A) Correctness
B) Efficiency
C) Ambiguity
D) Finite execution time
Answer: C
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download 19-SOFT-A1 Algorithms & Data Structures Exam C and more Exams Technology in PDF only on Docsity!

Structures Exam C

Question 1. Which property best characterizes an algorithm? A) It must be expressed in a programming language B) It provides a step-by-step procedure to solve a specific problem C) It is always recursive in nature D) It can only be used for numerical problems Answer: B Explanation: An algorithm is a finite set of well-defined instructions that provides a step-by-step procedure to solve a specific problem, regardless of implementation language or problem type. Question 2. Which of the following is NOT a characteristic of a good algorithm? A) Correctness B) Efficiency C) Ambiguity D) Finite execution time Answer: C

Structures Exam C

Explanation: A good algorithm must be unambiguous, correct, efficient, and terminate in finite time; ambiguity contradicts the clarity requirement. Question 3. Which data structure is classified as a primitive data structure? A) Array B) Stack C) Integer variable D) Linked list Answer: C Explanation: Primitive data structures are basic data types like integers, floats, characters; complex structures like arrays and lists are non-primitive. Question 4. What distinguishes an abstract data type (ADT) from a concrete data structure? A) ADT is implementation-specific B) ADT defines operations and behavior independent of implementation C) Concrete data structures cannot be implemented in C or C++ D) ADTs contain data but no operations Answer: B

Structures Exam C

D) O(1)

Answer: C Explanation: Dominant term is 3n^2, so the time complexity is O(n^2), representing quadratic growth. Question 7. Which is an example of a recursive recurrence relation? A) T(n) = T(n/2) + n B) T(n) = 2T(n-1) + 1 C) T(n) = n + 1 D) Both A and B Answer: D Explanation: Both A and B are recurrence relations defining T(n) in terms of smaller instances, suitable for recursive analysis. Question 8. What is the primary use of the master theorem? A) To solve linear equations B) To analyze the time complexity of divide-and-conquer algorithms C) To implement recursive functions D) To optimize memory usage in algorithms

Structures Exam C

Answer: B Explanation: The master theorem provides a direct way to determine the asymptotic bounds of recurrence relations typical in divide-and-conquer algorithms. Question 9. Which C/C++ construct allows dynamic memory allocation? A) malloc() and calloc() B) static variables C) automatic variables D) #define directive Answer: A Explanation: malloc() and calloc() are functions used for dynamic memory allocation on the heap; static and automatic variables are stack allocated. Question 10. Which statement correctly describes recursion? A) It is a process where a function calls itself directly or indirectly B) It always leads to iterative solutions C) It replaces the need for base cases D) It is only useful for mathematical calculations

Structures Exam C

D) Heap (not binary) Answer: B Explanation: Arrays are linear, contiguous memory structures. Trees and graphs are non-linear, heaps are specialized tree structures. Question 13. What is a key disadvantage of arrays compared to linked lists? A) Fixed size and contiguous memory requirement B) Dynamic resizing is easy C) Insertion and deletion at arbitrary positions are efficient D) They use pointers for navigation Answer: A Explanation: Arrays are fixed in size and require contiguous memory, making dynamic resizing and insertion/deletion at arbitrary positions less efficient. Question 14. In a singly linked list, which operation is most complicated? A) Traversal B) Insertion at the beginning C) Deletion of a node given only its pointer D) Reversing the list

Structures Exam C

Answer: C Explanation: Deletion of a node given only its pointer involves updating the previous node's pointer, which requires traversal to find the predecessor if only the node's pointer is available. Question 15. Which linked list type allows for efficient insertion and deletion from both ends? A) Singly linked list B) Doubly linked list C) Circular linked list D) Array Answer: B Explanation: Doubly linked lists have pointers to both previous and next nodes, enabling efficient insertion/deletion at both ends. Question 16. What is an advantage of circular linked lists over singly linked lists? A) They do not require pointers B) They allow for continuous traversal without null termination

Structures Exam C

B) Stack C) Hash table D) Graph Answer: B Explanation: Stacks naturally support undo/redo operations because of their LIFO property, allowing last action to be reversed easily. Question 19. In a queue, which operation removes the element at the front? A) enqueue() B) dequeue() C) pop() D) push() Answer: B Explanation: The dequeue() operation removes and returns the element at the front of a queue, adhering to FIFO principle. Question 20. Which queue implementation provides better space utilization in fixed-size arrays? A) Simple Queue with linear array

Structures Exam C

B) Circular Queue C) Deque D) Priority Queue Answer: B Explanation: Circular queues reuse space freed by dequeued elements, avoiding the problem of wasted space at the front in linear queues. Question 21. What is a key advantage of a deque (double-ended queue)? A) Insertion and deletion only at the front B) Insertion and deletion at both ends C) Cannot be implemented with arrays D) Only supports FIFO operations Answer: B Explanation: Deques support insertion and deletion operations at both ends, providing greater flexibility. Question 22. Which is an application of a priority queue? A) Implementing a stack B) Operating system process scheduling based on priority

Structures Exam C

D) All nodes are at the same depth Answer: C Explanation: BSTs maintain the property that left descendants are less than the node, and right descendants are greater, enabling efficient search. Question 25. Which operation in a BST can cause the tree to become unbalanced? A) Insertion of nodes in sorted order B) Deletion of leaf nodes C) Search for a node D) Traversal in inorder sequence Answer: A Explanation: Inserting nodes in sorted order can create skewed trees, degrading performance, which balanced trees aim to prevent. Question 26. What is the primary purpose of AVL trees? A) To implement priority queues B) To maintain a balanced binary search tree for efficient operations C) To store data in a heap structure

Structures Exam C

D) To perform graph traversal Answer: B Explanation: AVL trees are self-balancing BSTs that maintain a height difference (balance factor) to ensure efficient operations. Question 27. Which rotation is used to restore balance after an insertion that causes imbalance in an AVL tree? A) Left rotation B) Right rotation C) Single or double rotations (left-right or right-left) D) No rotation needed Answer: C Explanation: Depending on the imbalance pattern, AVL trees perform single or double rotations to restore balance after insertions or deletions. Question 28. Which self-adjusting binary search tree algorithm moves recently accessed elements closer to the root? A) AVL Tree B) Red-Black Tree

Structures Exam C

D) All of the above Answer: D Explanation: Insertions, deletions, and heapify operations in heaps are performed in O(log n) due to the height of the complete binary tree. Question 31. Which graph representation is more space-efficient for sparse graphs? A) Adjacency matrix B) Adjacency list C) Incidence matrix D) Adjacency table Answer: B Explanation: Adjacency lists are more space-efficient for sparse graphs, storing only existing edges, unlike adjacency matrices which allocate space for all possible edges. Question 32. Which graph traversal algorithm can detect cycles in a graph? A) Breadth-First Search (BFS) B) Depth-First Search (DFS)

Structures Exam C

C) Dijkstra's Algorithm D) Topological Sort Answer: B Explanation: DFS can detect cycles by checking back edges during traversal, indicating cycles in directed or undirected graphs. Question 33. What is the main purpose of topological sorting in a directed acyclic graph (DAG)? A) Find the shortest path B) Detect cycles C) Linearize nodes respecting dependency order D) Find the minimum spanning tree Answer: C Explanation: Topological sort arranges nodes linearly such that for every directed edge u→v, u appears before v, respecting dependencies. Question 34. Which algorithm is used to find the minimum spanning tree in a weighted graph? A) Dijkstra's algorithm

Structures Exam C

A) Queue B) Min-priority queue (heap) C) Stack D) Hash table Answer: B Explanation: Dijkstra's algorithm uses a min-priority queue (often implemented as a min-heap) to efficiently select the vertex with the smallest tentative distance. Question 37. In a hash table, which collision resolution technique involves probing sequentially for the next available slot? A) Separate chaining B) Linear probing C) Double hashing D) Quadratic probing Answer: B Explanation: Linear probing handles collisions by checking subsequent slots in a linear sequence until an empty slot is found.

Structures Exam C

Question 38. Which sorting algorithm is based on divide and conquer and guarantees stability? A) Bubble sort B) Merge sort C) Quick sort D) Heap sort Answer: B Explanation: Merge sort divides the array recursively and merges sorted subarrays, maintaining stability by preserving equal element order. Question 39. Which sorting algorithm generally performs the best on average for large datasets? A) Bubble sort B) Selection sort C) Quick sort D) Insertion sort Answer: C Explanation: Quicksort has an average-case time complexity of O(n log n) and performs well on large datasets, though its worst case is O(n^2).