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

  Find the two closest points from the list

Show how the algorithm would proceed to find the two closest points from the list [(1,2),(1,11),(7,8),(9,9),(12,13),(13,4) ,(20,8),(22,3),(23,12),(25,14),(26,7)(31,10)].

  Describe a method for combining t1 and t2 into a binary tree

Describe a method for combining T1 and T2 into a binary tree T, whose nodes hold the union of the entries in T1 and T2 and also satisfy the heap-order property.

  Implementation of various methods to store data

SDFD202 Data Structures And Algorithms Assignment - Efficient Sorting. Discuss the use and implementation of various methods to store data

  Write a program that implements dijkstras algorithm

Write a program that implements Dijkstra's algorithm

  Write a program to find average marks

Write a program to find average marks obtained by 10 students in a test along with algorithm and write a menu driven program using function to perform following operations on 1 d array?

  1 for a 77t truck with gross vehicle weight gvw of 136078

1. for a 77t truck with gross vehicle weight gvw of 136078 kg with dual rear tyres and a tyre inflation pressure is 120

  Determine the transmission rate

Assume two TCP connections are available over some bottleneck link of rate R bps. Both connections have a huge document to send in the similar direction over the bottleneck link

  Write down the data list which results from the

question 1. what numbers are compared to 72 if sequential search is used 2 5 7 9 11 17 18 21 28 30 45 54 65 69 72. also

  Algorithm to keep track of sufficient information

Your algorithm must keep track of sufficient information so that, for any computer Cb it is possible to retrieve in O(n) time a sequence of communications by which Cb could have become infected.

  Show that an algorithm for election in planar networks exist

Show that an O(N log N) algorithm for election in planar networks exists. Show that there exists an O(N log N) election algorithm for tori without a sense of direction.

  Function to swap all the left-right subtrees of binary tree

Write a function, swapSubTrees, that swaps all of the left and right subtrees of a binary tree. write a method singleParent, that returns the number of nodes in a binary tree that have only one child.

  Describe greedy algorithm to make change consisting of dimes

Describe a greedy algorithm to make change consisting of quarters, dimes, nickels, and pennies. Prove that your algorithm yields an optimal solution.

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