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

 A number k > 1 is called humble if the only

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

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!