Discuss how to incorporate the algorithm

Assignment Help Data Structure & Algorithms
Reference no: EM132264344

Question 1. Define a sequence of numbers Sn (for integers n ≥ 0) recursively as follows:

1794_sequence.jpg

(a) Prove by induction that Σni=3Si-3 = Sn - 3 for all integers n ≥ 3. No credit will be given for a different method of proof.

(b) Prove by induction that Sn+3 ≥ Φn for all integers n > 0, where Φ ∈ (1, 2) is a root of the equation x3 - x2 - 1 = 0. No credit will be given for a different method of proof.

(Remark: Such Φ exists and here is an argument to show why: If we let f (x) = x3 - x2 - 1, we have f (1) < 0 and f (2) > 0, and thus the equation 1 (x) = 0 has a solution (root) in the range (1, 2) and we call this root Φ - this is just a background information and you do not need to worry about this part.)

Question 2. What is wrong with the following purported proof that all horses have the same color?

Proof by induction on the number of horses:
Basis Step. There is only one horse. Then clearly all horses have the same color.
Induction Hypothesis. In any group of up to n horses, all horses have the same color.
Induction Step. Consider a group of n + 1 horses. Discard one horse; by the induction hypoth-esis, all the remaining horses have the same color. Now put that horse back and discard another; again all the remaining horses have the same color. So all the horses have the same color as the ones that were not discarded either time, and so they all have the same color.

Question 3. Consider the following sequence of items

10, 36, 25, 54, 37, 12, 75, 68, 42, 86, 72, 90.

Insert these items in the order above, into an initially empty implicit binary max-heap. Show the heap after every 3 INSERTO operations. (Just hand-simulate the behavior of the standard implicit binary max-heap, and draw the resulting heap after every 3 INSERT() operations.

Draw them in the form of a tree rather than an array.)

Question 4.

Consider the implicit binary heap with the array representation where the root is indexed by 1. Prove that when there are n elements in the heap, the leaves are the nodes indexed by [n/2] + 1, [n/2] + 2, .... , n.

Question 5.

Consider an implicit binary max-heap A storing n items in an array, where A[1] is the root and stores the maximum item. Assume that all keys stored in A are distinct.

(a) Suppose we want to support an additional operation SEARCH(A, k): for a given key k, return the index i such that A[i] = k, or report "none" if no such key k is stored in A. Give an example to show that in the best case, SEARCH() can be performed in 0(1) time. Also, give an example to show that in the worst case, SEARCH() needs C2(n) time. Finally, give a simple algorithm to carry out SEARCH() in 0(n) worst-case time (which is thus optimal).

(b) Suppose we want to support another operation DELETE(A, i): given an integer i e [1, n], delete the item A[i] (and still maintain A to be an implicit binary max-heap after the deletion). Give a direct algorithm (i.e., not using any existing operations) to carry out the task, and analyze its run-ning time. Your algorithm should run in 0 (log n) worst-case time. (8 points)

Question 6.

Implicit binary heap implemented by an array is simple and efficient, except that at some point when the array is full and an INSERT() operation comes in, we need to re-allocate a larger array (allocating a new, larger memory space, copying the data items over, and releasing the old memory space), which is expensive. A natural alternative is to implement a binary heap as a binary tree where each node has pointers to its parent, left child and right child. Again, it is a complete binary tree except for the lowest level, which is filled from the left up to some point. Now the key task here is to be able to find the last node efficiently.

(a) We can represent a path from the root to a node of a binary tree by means of a binary string (e.g., "01101"), where 0 means "go to the left child" and 1 means "go to the right child." Based on this representation, design and analyze an algorithm to find the last node of an n-node binary heap in 0 (log n) time.

(Hint: Look at small examples to derive your algorithm and also to check whether your algorithm is correct or not.)

(b) Discuss how to incorporate the algorithm in part (a) into the operations EXTRACT_MIN(Q) (extracting the minimum element from Q) and INSERT(Q, x) (inserting an element x into Q) for a binary min-heap Q.

Question 7.
Given an implicit binary max-heap A in an array (where the root A[1] stores the maximum item), a real number x and a positive integer k, design and analyze an algorithm to decide whether the k-th largest item in A is ≥ x. Your algorithm should run in O(k) worst-case time and use at most O(k) extra space, independent of the size of A.

Note: Your algorithm does not need to report the k-th largest item in A; only its relationship with x needs to be decided, to be able to answer "yes" or "no".

Reference no: EM132264344

Questions Cloud

Degree price discrimination : A Monopolist selling a cell phone in two separate markets. They must decide how much to sell in each market in order to maximize their total profits.
Problems 3.14-3.33 require that you convert the given : Problems 3.14-3.33 require that you convert the given pressure from gage to absolute pressure or from absolute to gage pressure as indicated. The value of the atmospheric pressure is given.
Conditions required for a competitive market : Suppose that the (inverse) demand curve for Cranberries is given by P = 40 - 6Q and TC = $4Q + $3Q2
Define effects of low moisture on microbial growth : Write a one page summary of the following learning objectives: the history of drying foods for preservation including early methods using sun, wind or fire.
Discuss how to incorporate the algorithm : CS6033 Design and Analysis of Algorithms - Analyze an algorithm to decide whether the k-th largest item in A is = x. Your algorithm should run in O(k)
Define what we mean by the scientific process : Define what we mean by the scientific process. Provide any one biological observation in your environment that can be used to support your definition.
What do all living organisms have in common : What do all living organisms have in common? What distinguishes a living organism from a nonliving thing? How can we get life from something that isn't alive?
How do bacteria develop resistance : Based on what you learned from the Videos and what you have learned about antimicrobial resistance from your text book, discuss the following in two paragraphs.
Who do you believe to be more effective : Who do you believe to be more effective? Why is delivery so important in getting your message across? Please discuss some of the things your book discusses.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd