Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

6. Explain the strengths of a dialectical approach.

Answered: 1 week ago