Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 3. You are given an unsorted array A[1:n] of n distinct positive integers. Design an algorithm that in O(n+M) worst-case time, where M is

image text in transcribed

Problem 3. You are given an unsorted array A[1:n] of n distinct positive integers. Design an algorithm that in O(n+M) worst-case time, where M is the maximum possible integer within A finds the h-index of A. The h-index is defined as the maximum integer h such that A[1:n] has at least h indices whose entry is at least h. ( 25 points) Remember to separately write your algorithm (10 points), the proof of correctness ( 10 points), and runtime analysis ( 5 points). Example. For n=8 and A=[9,8,70,30,2,7,4,5] the correct answer is 5 (because the largest integer, h, such that h of the integers in A are at least h is 5 ). Bonus part. If instead of an O(n+M) worst-case time algorithm, you design an algorithm with worst-case runtime of O(n), i.e., with no dependence on M, you receive +5 extra credit points

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

OpenStack Trove

Authors: Amrith Kumar, Douglas Shelley

1st Edition

1484212215, 9781484212219

More Books

Students also viewed these Databases questions