WGU DSA1 C949 V3 EXAM MULTIPLE CHOICE NEW EXAM
QUESTIONS AND CORRECT ANSWERS FOR TOP
PERFORMANCE
1. What is the time complexity of accessing an element in an array by
index?
• A) O(n)
• B) O(log n)
• C) O(n²)
• D) O(1)
Answer: D) O(1) - Array access by index is constant time because the memory
address can be calculated directly.
2. Which data structure uses LIFO (Last In First Out) ordering?
• A) Queue
• B) Stack
• C) Linked List
• D) Hash Table
Answer: B) Stack - Stacks follow LIFO principle where the last element added
is the first one removed.
3. What is the worst-case time complexity for searching in an unsorted
array?
• A) O(1)
• B) O(log n)
• C) O(n)
, • D) O(n²)
Answer: C) O(n) - You may need to check every element in the worst case
(linear search).
Sorting Algorithms
4. Which sorting algorithm has the best average-case time complexity?
• A) Bubble Sort - O(n²)
• B) Selection Sort - O(n²)
• C) Merge Sort - O(n log n)
• D) Insertion Sort - O(n²)
Answer: C) Merge Sort - Merge sort consistently performs at O(n log n) in all
cases.
5. What is the space complexity of Quicksort?
• A) O(1)
• B) O(log n)
• C) O(n)
• D) O(n²)
Answer: B) O(log n) - Due to the recursive call stack in the average case.
6. Which sorting algorithm is stable?
• A) Quicksort
• B) Heapsort
• C) Merge Sort
• D) Selection Sort
Answer: C) Merge Sort - Maintains relative order of equal elements.
Hash Tables
,7. What is the primary advantage of a hash table?
• A) Sorted data storage
• B) O(1) average-case insertion and retrieval
• C) Minimal memory usage
• D) Sequential access
Answer: B) O(1) average-case insertion and retrieval - Hash tables provide
constant-time operations on average.
8. What is a collision in a hash table?
• A) When the table is full
• B) When two keys hash to the same index
• C) When a key is not found
• D) When the hash function fails
Answer: B) When two keys hash to the same index - Multiple keys mapping
to the same location.
Trees
9. In a binary search tree, what is true about the left subtree?
• A) All values are greater than the root
• B) All values are less than the root
• C) All values are equal to the root
• D) Values are randomly distributed
Answer: B) All values are less than the root - BST property for the left
subtree.
10. What is the maximum number of nodes in a binary tree of height h?
• A) h
• B) 2h
, • C) 2^h - 1
• D) 2^(h+1) - 1
Answer: D) 2^(h+1) - 1 - A complete binary tree with height h (0-indexed).
11. What traversal visits nodes in the order: left, root, right?
• A) Preorder
• B) Inorder
• C) Postorder
• D) Level-order
Answer: B) Inorder - Inorder traversal: left subtree → root → right subtree.
Graphs
12. Which data structure is commonly used to implement a graph?
• A) Array only
• B) Adjacency matrix or adjacency list
• C) Stack only
• D) Queue only
Answer: B) Adjacency matrix or adjacency list - Both are standard graph
representations.
13. What is the time complexity of Breadth-First Search (BFS)?
• A) O(V)
• B) O(E)
• C) O(V + E)
• D) O(V * E)
Answer: C) O(V + E) - Where V is vertices and E is edges.
14. Which algorithm finds the shortest path in a weighted graph?
QUESTIONS AND CORRECT ANSWERS FOR TOP
PERFORMANCE
1. What is the time complexity of accessing an element in an array by
index?
• A) O(n)
• B) O(log n)
• C) O(n²)
• D) O(1)
Answer: D) O(1) - Array access by index is constant time because the memory
address can be calculated directly.
2. Which data structure uses LIFO (Last In First Out) ordering?
• A) Queue
• B) Stack
• C) Linked List
• D) Hash Table
Answer: B) Stack - Stacks follow LIFO principle where the last element added
is the first one removed.
3. What is the worst-case time complexity for searching in an unsorted
array?
• A) O(1)
• B) O(log n)
• C) O(n)
, • D) O(n²)
Answer: C) O(n) - You may need to check every element in the worst case
(linear search).
Sorting Algorithms
4. Which sorting algorithm has the best average-case time complexity?
• A) Bubble Sort - O(n²)
• B) Selection Sort - O(n²)
• C) Merge Sort - O(n log n)
• D) Insertion Sort - O(n²)
Answer: C) Merge Sort - Merge sort consistently performs at O(n log n) in all
cases.
5. What is the space complexity of Quicksort?
• A) O(1)
• B) O(log n)
• C) O(n)
• D) O(n²)
Answer: B) O(log n) - Due to the recursive call stack in the average case.
6. Which sorting algorithm is stable?
• A) Quicksort
• B) Heapsort
• C) Merge Sort
• D) Selection Sort
Answer: C) Merge Sort - Maintains relative order of equal elements.
Hash Tables
,7. What is the primary advantage of a hash table?
• A) Sorted data storage
• B) O(1) average-case insertion and retrieval
• C) Minimal memory usage
• D) Sequential access
Answer: B) O(1) average-case insertion and retrieval - Hash tables provide
constant-time operations on average.
8. What is a collision in a hash table?
• A) When the table is full
• B) When two keys hash to the same index
• C) When a key is not found
• D) When the hash function fails
Answer: B) When two keys hash to the same index - Multiple keys mapping
to the same location.
Trees
9. In a binary search tree, what is true about the left subtree?
• A) All values are greater than the root
• B) All values are less than the root
• C) All values are equal to the root
• D) Values are randomly distributed
Answer: B) All values are less than the root - BST property for the left
subtree.
10. What is the maximum number of nodes in a binary tree of height h?
• A) h
• B) 2h
, • C) 2^h - 1
• D) 2^(h+1) - 1
Answer: D) 2^(h+1) - 1 - A complete binary tree with height h (0-indexed).
11. What traversal visits nodes in the order: left, root, right?
• A) Preorder
• B) Inorder
• C) Postorder
• D) Level-order
Answer: B) Inorder - Inorder traversal: left subtree → root → right subtree.
Graphs
12. Which data structure is commonly used to implement a graph?
• A) Array only
• B) Adjacency matrix or adjacency list
• C) Stack only
• D) Queue only
Answer: B) Adjacency matrix or adjacency list - Both are standard graph
representations.
13. What is the time complexity of Breadth-First Search (BFS)?
• A) O(V)
• B) O(E)
• C) O(V + E)
• D) O(V * E)
Answer: C) O(V + E) - Where V is vertices and E is edges.
14. Which algorithm finds the shortest path in a weighted graph?