Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A number k > 1 is called humble if the only prime factors of k are 3 and 5. Consider the task of, on input

image text in transcribed

A number k > 1 is called humble if the only prime factors of k are 3 and 5. Consider the task of, on input n, outputting the n smallest humble numbers and the following algorithm to do it: HUMBLE n): count 0, prevOutput HEAP. INSERT(3) HEAP.INSERT (5) while (count n) 0 cur = HEAP. EXTRACT,MIN if cur pret,Output then output cur HEAP.INSERT(3*cur) HEAP.INSERT(5*cur) count count + 1 prevOutput-cuir (a) (4 points) Argue that the algorithm above (1) outputs numbers in increasing order, (2) does not output any number twice, (3) only outputs humble numbers, and (4) outputs all of the first n humble numbers (b) (2 points) Derive an eract (i.e., no O-notation) bound on the number of times HEAP.INSERT (c) (2 points) Bound exactly the nuinber of times HEAP.EXTRACTMIN s called. (d) (2 points) Use the answers to (b) and (c) above to argue that HuMBLE runs in O(nlog n) is called. (Hint: Use (b).) time. Assume that arithmetic can be performed in O(1) time

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

If there were no law against it, would it be OK to blind someone?

Answered: 1 week ago