Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Text Book - Algorithm Design by Jon Kleinberg and Eva Tardos

Chapter 5 - Divide and Conquer

Exercises-

Q1. You are interested in analyzing some hard-to-obtain data from two separate databases. Each database contains n numerical values-so there are 2n values total-and you may assume that no two values are the same. You'd like to determine the median of this set of 2n values, which we will define here to be the nth smallest value.

However, the only way you can access these values is through queries to the databases. In a single query, you can specify a value k to one of the two databases, and the chosen database will return the kth smallest value that it contains. Since queries are expensive, you would like to compute the median using as few queries as possible.

Give an algorithm that finds the median value using at most O(log n) queries.

Q2. Recall the problem of finding the number of inversions. As in the text, we are given a sequence of n numbers a1,..., an, which we assume are all distinct, and we define an inversion to be a pair i < j such that ai > aj.

We motivated the problem of counting inversions as a good measure of how different two orderings are. However, one might feel that this measure is too sensitive. Let's call a pair a significant inversion if i < j and ai > 2aj. Give an O(n log n) algorithm to count the number of significant inversions between two orderings.

Q3. Suppose you're consulting for a bank that's concerned about fraud detection, and they come to you with the following problem. They have a collection of n bank cards that they've confiscated, suspecting them of being used in fraud. Each bank card is a small plastic object, containing a magnetic stripe with some encrypted data, and it corresponds to a unique account in the bank. Each account can have many bank cards corresponding to it, and we'll say that two bank cards are equivalent if they correspond to the same account.

It's very difficult to read the account number off a bank card directly, but the bank has a high-tech "equivalence tester" that takes two bank cards and, after performing some computations, determines whether they are equivalent.

Their question is the following: among the collection of n cards, is there a set of more than n/2 of them that are all equivalent to one another? Assume that the only feasible operations you can do with the cards are to pick two of them and plug them in to the equivalence tester. Show how to decide the answer to their question with only O(n log n) invocations of the equivalence tester.

Q4. You've been working with some physicists who need to study, as part of their experimental design, the interactions among large numbers of very small charged particles. Basically, their setup works as follows. They have an inert lattice structure, and they use this for placing charged particles at regular spacing along a straight line. Thus we can model their structure as consisting of the points {1, 2, 3, . . . , n} on the real line; and at each of these points j, they have a particle with charge qj. (Each charge can be either positive or negative.)

They want to study the total force on each particle, by measuring it and then comparing it to a computational prediction. This computational part is where they need your help. The total net force on particle j, by Coulomb's Law, is equal to

1419_Img.png

It's not hard to analyze the running time of this program: each invocation of the inner loop, over i, takes O(n) time, and this inner loop is invoked O(n) times total, so the overall running time is O(n2). The trouble is, for the large values of n they're working with, the program takes several minutes to run. On the other hand, their experimental setup is optimized so that they can throw down n particles, perform the measurements, and be ready to handle n more particles within a few seconds. So they'd really like it if there were a way to compute all the forces Fj much more quickly, so as to keep up with the rate of the experiment. Help them out by designing an algorithm that computes all the forces Fj in O(n log n) time.

Q5. Hidden surface removal is a problem in computer graphics that scarcely needs an introduction: when Woody is standing in front of Buzz, you should be able to see Woody but not Buzz; when Buzz is standing in front of Woody,... well, you get the idea.

The magic of hidden surface removal is that you can often compute things faster than your intuition suggests. Here's a clean geometric example to illustrate a basic speed-up that can be achieved. You are given n non vertical lines in the plane, labeled L1,..., Ln, with the ith line specified by the equation y = aix + bi. We will make the assumption that no three of the lines all meet at a single point. We say line Li is uppermost at a given x-coordinate x0 if its y-coordinate at x0 is greater than the y-coordinates of all the other lines at x0: aix0 + bi > ajx0 + bj for all j ≠ i. We say line Li is visible if there is some x-coordinate at which it is uppermost-intuitively, some portion of it can be seen if you look down from "y =∞."

Give an algorithm that takes n lines as input and in O(n log n) time returns all of the ones that are visible. Figure 5.10 gives an example.

Q6. Consider an n-node complete binary tree T, where n = 2d - 1 for some d. Each node v of T is labeled with a real number xv. You may assume that the real numbers labeling the nodes are all distinct. A node v of T is a local minimum if the label xv is less than the label xw for all nodes w that are joined to v by an edge.

You are given such a complete binary tree T, but the labeling is only specified in the following implicit way: for each node v, you can determine the value xv by probing the node v. Show how to find a local minimum of T using only O(log n) probes to the nodes of T.

Q7. Suppose now that you're given an n × n grid graph G. (An n × n grid graph is just the adjacency graph of an n × n chessboard. To be completely precise, it is a graph whose node set is the set of all ordered pairs of natural numbers (i, j), where 1≤ i ≤ n and 1≤ j ≤ n; the nodes (i, j) and (k, l) are joined by an edge if and only if |i - k|+|j - l|= 1.)

1716_Img1.png

We use some of the terminology of the previous question. Again, each node v is labeled by a real number xv; you may assume that all these labels are distinct. Show how to find a local minimum of G using only O(n) probes to the nodes of G. (Note that G has n2 nodes.)

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91962236
  • Price:- $90

Guranteed 48 Hours Delivery, In Price:- $90

Have any Question?


Related Questions in Computer Engineering

Assume a normal distribution for n 300 how many cases

Assume a normal distribution for N = 300. How many cases would one expect to find between +1 and -1 standard deviations around the mean?

Question you are responsible for managing multiple exchange

Question : You are responsible for managing multiple Exchange organizations, and you need to apply identical configurations to servers in all organizations. Since you are just starting out with Exchange Server 2013, and ...

Suppose that you have a database of three-dimensional

Suppose that you have a database of three-dimensional galaxy coordinates x; y; z that covered a large volume of, say, 3 Gpc 3 Gpc 3 Gpc. Using your skill and judgement, suggest how you might use the data to test whether ...

A helium filled water balloon is launched from the ground

A helium filled water balloon is launched from the ground where the pressure is 752mmHg and temperature is 21c. Under these conditions it's volume is 75L. When it has climbed to an altitude where the pressure is 89mmHg a ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

What are the assumptions of linear regression analysis and

What are the assumptions of linear regression analysis and ,How do we interpret the regression coefficients ,can u give a real life example of how linear regression is used in statistical research

The freezing point depression constant forwater is -186 cm

The freezing point depression constant forwater is -1.86 C/m. If 5.00 g Na2SO4 is dissolved in 45.0 g H2O, the freezing point is changed by -3.82 C. Calculate the van't Hofffactor for Na2SO4.

What is a good analogy of subnetting whats a break down of

What is a good analogy of Subnetting? What's a break down of how it is used within a company?

In the scenario activity operating systems and forensics

In the scenario activity Operating Systems and Forensics, which forensic tools would you utilize to recover and process evidence found on the hard drive and what is the objective of recovering data from the USB drive tha ...

Write a matlab code to solve thisit seems that the math

Write a matlab code to solve this It seems that the Math department at a rival university has once again dropped the ball, and forgotten the value of n. You are to write a script which consumes a number that specifies th ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As