CS6515 EXAM 3 NEWEST VERSION 2026 COMPLETE 46+ QUESTIONS AND
CORRECT DETAILED ANSWERS (VERIFIED ANSWERS) |ALREADY GRADED A+.
Course
CS6515
1. What is the time complexity of binary search on a sorted array of size n?
A. O(1)
B. O(log n)
C. O(n)
D. O(n²)
Answer: B. O(log n)
Explanation:
Binary search repeatedly divides the search space in half. After k divisions:
n/2k=1n/2^k = 1n/2k=1
which gives:
k=log2nk = log_2 nk=log2n
Therefore, the running time is O(log n).
2. Which algorithm design technique solves a problem by breaking it into smaller
independent subproblems?
A. Greedy method
B. Divide and conquer
C. Backtracking
D. Branch and bound
Answer: B. Divide and conquer
Explanation:
Divide-and-conquer algorithms:
1. Divide the problem into smaller subproblems.
2. Solve each recursively.
3. Combine solutions.
Examples:
Merge sort
, Quick sort
Binary search
3. What is the worst-case time complexity of merge sort?
A. O(n)
B. O(log n)
C. O(n log n)
D. O(n²)
Answer: C. O(n log n)
Explanation:
Merge sort divides the array log n times and performs n work during each merge step.
T(n)=2T(n/2)+O(n)T(n)=2T(n/2)+O(n)T(n)=2T(n/2)+O(n)
Using the Master Theorem:
T(n)=O(nlogn)T(n)=O(nlogn)T(n)=O(nlogn)
4. Which data structure is typically used for implementing Breadth-First Search (BFS)?
A. Stack
B. Queue
C. Heap
D. Hash table
Answer: B. Queue
Explanation:
BFS explores nodes level-by-level. A queue maintains the order in which vertices are discovered.
5. What is the main purpose of asymptotic analysis?
A. Measure exact execution time
B. Compare algorithm efficiency as input size grows
C. Calculate memory addresses
D. Eliminate recursion
Answer: B
, Explanation:
Asymptotic analysis describes algorithm growth rate independent of hardware or programming
language.
Common notations:
O(g(n)): upper bound
Ω(g(n)): lower bound
Θ(g(n)): tight bound
6. Which sorting algorithm has an average-case complexity of O(n log n)?
A. Bubble sort
B. Selection sort
C. Quick sort
D. Linear search
Answer: C
Explanation:
Quick sort:
Average case: O(n log n)
Worst case: O(n²)
Worst case occurs when the pivot creates extremely unbalanced partitions.
7. Dynamic programming is most useful when a problem has:
A. Random inputs only
B. Overlapping subproblems and optimal substructure
C. No recursion
D. Only one solution
Answer: B
Explanation:
Dynamic programming stores solutions to repeated subproblems.
Examples:
Fibonacci sequence
CORRECT DETAILED ANSWERS (VERIFIED ANSWERS) |ALREADY GRADED A+.
Course
CS6515
1. What is the time complexity of binary search on a sorted array of size n?
A. O(1)
B. O(log n)
C. O(n)
D. O(n²)
Answer: B. O(log n)
Explanation:
Binary search repeatedly divides the search space in half. After k divisions:
n/2k=1n/2^k = 1n/2k=1
which gives:
k=log2nk = log_2 nk=log2n
Therefore, the running time is O(log n).
2. Which algorithm design technique solves a problem by breaking it into smaller
independent subproblems?
A. Greedy method
B. Divide and conquer
C. Backtracking
D. Branch and bound
Answer: B. Divide and conquer
Explanation:
Divide-and-conquer algorithms:
1. Divide the problem into smaller subproblems.
2. Solve each recursively.
3. Combine solutions.
Examples:
Merge sort
, Quick sort
Binary search
3. What is the worst-case time complexity of merge sort?
A. O(n)
B. O(log n)
C. O(n log n)
D. O(n²)
Answer: C. O(n log n)
Explanation:
Merge sort divides the array log n times and performs n work during each merge step.
T(n)=2T(n/2)+O(n)T(n)=2T(n/2)+O(n)T(n)=2T(n/2)+O(n)
Using the Master Theorem:
T(n)=O(nlogn)T(n)=O(nlogn)T(n)=O(nlogn)
4. Which data structure is typically used for implementing Breadth-First Search (BFS)?
A. Stack
B. Queue
C. Heap
D. Hash table
Answer: B. Queue
Explanation:
BFS explores nodes level-by-level. A queue maintains the order in which vertices are discovered.
5. What is the main purpose of asymptotic analysis?
A. Measure exact execution time
B. Compare algorithm efficiency as input size grows
C. Calculate memory addresses
D. Eliminate recursion
Answer: B
, Explanation:
Asymptotic analysis describes algorithm growth rate independent of hardware or programming
language.
Common notations:
O(g(n)): upper bound
Ω(g(n)): lower bound
Θ(g(n)): tight bound
6. Which sorting algorithm has an average-case complexity of O(n log n)?
A. Bubble sort
B. Selection sort
C. Quick sort
D. Linear search
Answer: C
Explanation:
Quick sort:
Average case: O(n log n)
Worst case: O(n²)
Worst case occurs when the pivot creates extremely unbalanced partitions.
7. Dynamic programming is most useful when a problem has:
A. Random inputs only
B. Overlapping subproblems and optimal substructure
C. No recursion
D. Only one solution
Answer: B
Explanation:
Dynamic programming stores solutions to repeated subproblems.
Examples:
Fibonacci sequence