Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

10. (a) Given an unordered array of n distinct positi to find some element of the array that w if it were sorted in ascending

image text in transcribed
10. (a) Given an unordered array of n distinct positi to find some element of the array that w if it were sorted in ascending order, i.e. one ed array of n distinct positive integers a[1], a[2], ... an], we wish element of the array that would be in the middle third of the array ted in ascending order, i.e. one that would be between positions n/3 3. The original array must not be changed and only a constant amount of additional space, i.e. not dependent on n, may be used. ithout writing any code, describe how you could construct an algorithm to do this, and state the order of magnitude of the time complexity of your suggested algorithm. (4 marks) (b) Now suppose that the algorithm may change the array and may use any amount of additional space. Construct an algorithm to solve this problem that would run significantly faster than your original algorithm by making use of the function partition(a, L,U) that is used in the implementation of Quicksort. You do not have to provide code for the function partition. What do you think the average time complexity of your algorithm would be? (Hint: Write a recursive function find(a, L, U) that returns some element a[p] where 1

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

Database Systems For Advanced Applications 17th International Conference Dasfaa 2012 Busan South Korea April 2012 Proceedings Part 1 Lncs 7238

Authors: Sang-goo Lee ,Zhiyong Peng ,Xiaofang Zhou ,Yang-Sae Moon ,Rainer Unland ,Jaesoo Yoo

2012 Edition

364229037X, 978-3642290374

More Books

Students also viewed these Databases questions

Question

(2) f YZ (y, z).

Answered: 1 week ago