• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 12 pages
Exam (elaborations)

Computer Science Data Structures and Algorithms - CSDSA-102

Document preview thumbnail
Preview 2 out of 12 pages

Computer Science Data Structures and Algorithms - CSDSA-102

Content preview

1. Which of the following is a stable sorting algorithm?
A. Quick Sort
B. Merge Sort
C. Heap Sort
D. Selection Sort
Answer: b) Merge Sort
Rationale: Merge Sort is stable because it preserves the relative order of equal
elements.

2. What is the time complexity of accessing an element in an array?
A. O(n)
B. O(log n)
C. O(1)
D. O(n^2)
Answer: c) O(1)
Rationale: Arrays provide constant-time access to elements via indexing.

3. Which data structure is most suitable for implementing a depth-first search (DFS)?
A. Stack
B. Queue
C. Linked List
D. Array
Answer: a) Stack
Rationale: DFS uses a stack to explore nodes, either explicitly or via recursion (which
uses the call stack).

4. Which of the following algorithms has the best average-case time complexity for
sorting?
A. Quick Sort
B. Merge Sort
C. Insertion Sort
D. Bubble Sort
Answer: a) Quick Sort
Rationale: Quick Sort has an average time complexity of O(n log n), making it one of
the fastest in practice.

5. Which of the following is not a type of binary tree?
A. AVL Tree
B. Red-Black Tree
C. B-Tree
D. Complete Binary Tree
Answer: c) B-Tree
Rationale: A B-Tree is a self-balancing tree data structure used primarily for database
indexing and is not a binary tree.

6. What is the time complexity of binary search?
A. O(n)
B. O(log n)

, C. O(n log n)
D. O(1)
Answer: b) O(log n)
Rationale: Binary search divides the search space in half each time, resulting in
logarithmic time complexity.

7. Which of the following is a non-linear data structure?
A. Array
B. Stack
C. Queue
D. Tree
Answer: d) Tree
Rationale: Trees are non-linear structures, while arrays, stacks, and queues are linear.

8. Which algorithm is used to find the shortest path in a graph with non-negative edge
weights?
A. Bellman-Ford
B. Dijkstra's Algorithm
C. Floyd-Warshall
D. Prim’s Algorithm
Answer: b) Dijkstra's Algorithm
Rationale: Dijkstra’s algorithm is used to find the shortest path in graphs with non-
negative edge weights.

9. What is the worst-case time complexity of Quick Sort?
A. O(n log n)
B. O(n^2)
C. O(log n)
D. O(n)
Answer: b) O(n^2)
Rationale: Quick Sort’s worst-case time complexity occurs when the pivot elements are
poorly chosen, leading to unbalanced partitions.

10. In which type of tree is the height of two child subtrees of every node differ by at
most one?
A. AVL Tree
B. Red-Black Tree
C. Binary Search Tree
D. B-Tree
Answer: a) AVL Tree
Rationale: An AVL tree is a self-balancing binary search tree where the height
difference between the left and right subtrees of every node is at most one.

11. Which sorting algorithm has the worst time complexity of O(n^2)?
A. Merge Sort
B. Bubble Sort
C. Heap Sort
D. Quick Sort
Answer: b) Bubble Sort
Rationale: Bubble Sort has a worst-case time complexity of O(n^2) when the input list

Document information

Uploaded on
March 11, 2025
Number of pages
12
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$9.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
douglasmugwe82
5.0
(1)
Sold
2
Followers
0
Items
4215
Last sold
1 year ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions