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

Introduces fundamental data structures such as arrays, stacks, queues, linked lists, and trees. Covers algorithmic techniques including recursion, iteration, searching, and sorting (bubble, selection, insertion, merge, quick sort). Emphasis on algorithm analysis (Big-O, time/space complexity).

Typology: Exams

2024/2025

Available from 06/05/2025

nicky-jone
nicky-jone 🇮🇳

2.9

(44)

28K documents

1 / 126

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
19-SOFT-A1 Algorithms & Data
Structures Exam A
Question 1. Which property of a good algorithm ensures that it terminates
after a finite number of steps?
A) Definiteness
B) Finiteness
C) Input/output
D) Generality
Answer: B
Explanation: Finiteness guarantees that an algorithm terminates after a finite
number of steps, which is essential for an algorithm to be considered correct
and practical.
Question 2. Which data structure abstracts the behavior of "list" with
dynamic memory allocation?
A) Array
B) Linked list
C) Stack
D) Graph
Answer: B
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 A and more Exams Technology in PDF only on Docsity!

Structures Exam A

Question 1. Which property of a good algorithm ensures that it terminates after a finite number of steps? A) Definiteness B) Finiteness C) Input/output D) Generality Answer: B Explanation: Finiteness guarantees that an algorithm terminates after a finite number of steps, which is essential for an algorithm to be considered correct and practical. Question 2. Which data structure abstracts the behavior of "list" with dynamic memory allocation? A) Array B) Linked list C) Stack D) Graph Answer: B

Structures Exam A

Explanation: A linked list abstracts a list with dynamic memory allocation, allowing efficient insertion and deletion operations without the need for contiguous memory. Question 3. Which asymptotic notation describes the worst-case performance of an algorithm? A) Big-O (O) B) Omega (Ω) C) Theta (Θ) D) Little-o (o) Answer: A Explanation: Big-O notation describes the upper bound on the worst-case performance, providing an upper limit on the time or space complexity. Question 4. If a recursive algorithm has the recurrence relation T(n) = 2T(n/2)

  • n, which method is most suitable for solving it? A) Substitution method B) Master Theorem C) Recursion tree method

Structures Exam A

Answer: B Explanation: Sparse matrices are characterized by most elements being zero, which motivates specialized storage techniques for efficiency. Question 7. Which linked list variation allows traversal in both directions? A) Singly linked list B) Doubly linked list C) Circular linked list D) Array list Answer: B Explanation: Doubly linked lists have pointers to both the previous and next nodes, enabling traversal in both directions. Question 8. Which operation is typically more efficient in a singly linked list than an array? A) Random access B) Insertion at beginning C) Binary search D) Indexing

Structures Exam A

Answer: B Explanation: Inserting at the beginning of a singly linked list is efficient because it involves only changing pointers, whereas arrays require shifting elements. Question 9. Which data structure follows the Last-In, First-Out (LIFO) principle? A) Stack B) Queue C) Priority queue D) Graph Answer: A Explanation: Stacks operate on the LIFO principle, where the last element inserted is the first to be removed. Question 10. Which operation on a stack does the "Peek" or "Top" function perform? A) Remove the top element B) Insert a new element at the top

Structures Exam A

B) Graph C) Array D) Queue Answer: A Explanation: Trees naturally model hierarchical relationships, with parent- child connections. Question 13. In a binary tree, the "height" of a node is defined as: A) The number of edges on the longest path from the node to a leaf B) The number of children of the node C) The number of ancestors of the node D) The number of sibling nodes Answer: A Explanation: The height of a node in a binary tree is the length of the longest path from that node down to a leaf. Question 14. Which traversal method visits nodes in the order: root, left subtree, right subtree? A) In-order

Structures Exam A

B) Pre-order C) Post-order D) Level-order Answer: B Explanation: Pre-order traversal visits the root first, then recursively traverses the left and right subtrees. Question 15. Which property is characteristic of a Binary Search Tree (BST)? A) Nodes are in complete binary tree shape B) Left child contains smaller values, right child contains larger values C) All leaves are at the same level D) Nodes only have two children Answer: B Explanation: A BST maintains the property that for each node, values in the left subtree are smaller, and in the right subtree are larger. Question 16. What is the primary advantage of balanced search trees like AVL trees? A) Simplified implementation

Structures Exam A

A) Heapify process B) Bubble sort C) Quick sort D) Merge sort Answer: A Explanation: The heapify process converts an unordered array into a heap efficiently, typically in O(n) time. Question 19. Which graph representation uses a 2D matrix to indicate the presence or absence of edges? A) Adjacency matrix B) Adjacency list C) Incidence matrix D) Edge list Answer: A Explanation: An adjacency matrix uses a 2D array where each cell indicates whether an edge exists between vertices.

Structures Exam A

Question 20. Which algorithm is suitable for finding the shortest path in an unweighted graph? A) Dijkstra's algorithm B) Bellman-Ford algorithm C) Breadth-First Search (BFS) D) Floyd-Warshall algorithm Answer: C Explanation: BFS finds the shortest path in unweighted graphs efficiently by exploring neighbors level by level. Question 21. Which algorithm is most appropriate for finding a Minimum Spanning Tree in a weighted graph? A) Kruskal's algorithm B) Bellman-Ford algorithm C) Depth-First Search D) Dijkstra's algorithm Answer: A Explanation: Kruskal's algorithm constructs an MST by adding edges in order of increasing weight, avoiding cycles.

Structures Exam A

Question 24. Which hashing collision resolution technique involves probing sequentially for an empty slot? A) Separate chaining B) Linear probing C) Double hashing D) Quadratic probing Answer: B Explanation: Linear probing resolves collisions by checking subsequent slots sequentially until an empty slot is found. Question 25. Which sorting algorithm is most efficient (O(n log n)) on average and uses divide-and-conquer? A) Bubble sort B) Merge sort C) Selection sort D) Insertion sort Answer: B Explanation: Merge sort uses divide-and-conquer and achieves O(n log n) average and worst-case time complexity.

Structures Exam A

Question 26. Which sorting algorithm is stable and in-place, often preferred for small datasets? A) Merge sort B) Quick sort C) Bubble sort D) Heap sort Answer: C Explanation: Bubble sort is stable and in-place but inefficient for large datasets; it is simple and suitable for small data. Question 27. Which non-comparison sorting technique is suitable for sorting integers within a limited range? A) Counting sort B) Radix sort C) Merge sort D) Quick sort Answer: A Explanation: Counting sort is efficient for integers with limited range, counting occurrences for sorting.

Structures Exam A

Question 30. Which problem is a classic example of backtracking? A) N-Queens problem B) Shortest path problem C) Minimum spanning tree D) Sorting array Answer: A Explanation: The N-Queens problem involves placing queens on a chessboard without conflicts, typically solved via backtracking. Question 31. Which complexity class contains decision problems that can be solved in polynomial time? A) P B) NP C) NP-complete D) NP-hard Answer: A Explanation: P includes decision problems that can be solved efficiently (in polynomial time).

Structures Exam A

Question 32. Which statement best describes NP-complete problems? A) They are the easiest problems in NP B) They are problems that can be verified quickly but not necessarily solved quickly C) They are problems that are solvable in polynomial time D) They are problems with no known solution Answer: B Explanation: NP-complete problems are verifiable in polynomial time but no known polynomial-time solutions exist for all instances. Question 33. Which data structure is most suitable for implementing a priority queue? A) Array B) Heap C) Linked list D) Graph Answer: B Explanation: A heap provides efficient insertion and deletion of the highest (or lowest) priority element, making it ideal for priority queues.

Structures Exam A

Question 36. Which property must a graph have to be a Directed Acyclic Graph (DAG)? A) Contains cycles B) No directed cycles C) Undirected D) Fully connected Answer: B Explanation: A DAG must have no directed cycles, which allows for topological sorting. Question 37. Which traversal order is used in topological sorting of a DAG? A) BFS (Level order) B) DFS (Post-order) C) In-order D) Breadth-first search only Answer: B Explanation: Topological sort uses DFS post-order traversal to linearize nodes respecting dependencies.

Structures Exam A

Question 38. Which algorithm is used to check for cycles in a directed graph? A) Dijkstra's algorithm B) DFS-based cycle detection C) Kruskal's algorithm D) Bellman-Ford algorithm Answer: B Explanation: DFS-based cycle detection identifies back edges indicating cycles in directed graphs. Question 39. In the context of algorithm analysis, the "best-case" performance refers to: A) The maximum amount of time an algorithm takes B) The minimum amount of time an algorithm takes for some input C) The average performance over all inputs D) The performance when input size is zero Answer: B Explanation: Best-case performance is the minimum time or space an algorithm requires for particular input.