Question: Problem 1 . ( 2 0 points ) Consider the following array which needs to be sorted in ascending order using Quicksort: [ 4 5

Problem 1.(20 points) Consider the following array which needs to be sorted in ascending order
using Quicksort:
[4571623]
(a)(10 points) Explain which pairs of elements are swapped during the 1st partitioning. Also,
show the content of the array at the end of the 1st partitioning.
(b)(10 points) Explain which pairs of elements are swapped during the 2nd partitioning. Also,
show the content of the array at the end of the 2nd partitioning.
Problem 2.(20 points) Consider the following sorted array:
[0123456]
(a)(10 points) List the elements of the array that the binary search algorithm accesses when it
searches for 2. Briefly justify your answer.
(b)(10 points) List the elements of the array that the binary search algorithm accesses when it
searches for 7. Briefly justify your answer.
Problem 3.(20 points) Determine whether or not each of the following statement is true. Also,
justify your answer rigorously using the Big-O, Big-Omega, and/or Big-Theta definitions.
(a)(10 points)2n 4 is O(n
2
).
(b)(10 points)42n
2
is \Theta (n
2
).
1
Problem 4.(37 points) Express the time complexity (in Big-O notation) of each of the following
cases assuming that the size of the input data (i.e., the length of the given array) is N. Briefly
justify your answer. You do not need to apply the Big-O definition (i.e., f(n) is O(g(n)) if there
exist positive constants c and n0 such that f(n)<= c g(n) for all n >= n0) to justify your expression
in Big-O notation.
(a)(10 points) Best case of binary search
(b)(10 points) Worst case of selection sort
(c)(8 points) Best case of insertion sort
(c)(5 points) Worst case of insertion sort
(d)(4 points) Worst case of Quicksort (assume that, when a portion of the array is partitioned,
the first element in that portion is chosen as the pivot)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!