DSA FINAL EXAM TIME
COMPLEXITIES QUESTIONS &
ANSWERS
search operation in a BST - Correct Answers -best: O(log N)
worst: O(N)
insert operation (BST) - Correct Answers -best: O(log N)
worst: O(N)
remove operation (BST) - Correct Answers -best: O(log N)
worst: O(N)
linear search - Correct Answers -best case: O(1)
worst case: O(N)
which sorting algorithms have the same best and worst case run time - Correct Answers
-selection and merge sort
if the algorithm has only a single loop that loops n time, complexity is - Correct Answers
-O(N)
if the algorithm has a nested loop that iterates n and n times, complexity is.. - Correct
Answers -O(N^2)
binary search - Correct Answers -best case: O(1)
worst case: O(log N)
selection sort - Correct Answers -best case: O(n^2)
worst case: O(n^2)
insertion sort - Correct Answers -best case: O(N)
worst case: O(N^2)
merge sort - Correct Answers -best case and worst case: O (n log n)
quick sort - Correct Answers -best case: O(n log n)
worst case: O(n^2)
COMPLEXITIES QUESTIONS &
ANSWERS
search operation in a BST - Correct Answers -best: O(log N)
worst: O(N)
insert operation (BST) - Correct Answers -best: O(log N)
worst: O(N)
remove operation (BST) - Correct Answers -best: O(log N)
worst: O(N)
linear search - Correct Answers -best case: O(1)
worst case: O(N)
which sorting algorithms have the same best and worst case run time - Correct Answers
-selection and merge sort
if the algorithm has only a single loop that loops n time, complexity is - Correct Answers
-O(N)
if the algorithm has a nested loop that iterates n and n times, complexity is.. - Correct
Answers -O(N^2)
binary search - Correct Answers -best case: O(1)
worst case: O(log N)
selection sort - Correct Answers -best case: O(n^2)
worst case: O(n^2)
insertion sort - Correct Answers -best case: O(N)
worst case: O(N^2)
merge sort - Correct Answers -best case and worst case: O (n log n)
quick sort - Correct Answers -best case: O(n log n)
worst case: O(n^2)