What is the minimum number of comparisons needed to sort

Assignment Help Basic Computer Science
Reference no: EM131245364

Here is a variation on sorting. The problem is to sort a collection of n nuts and n bolts by size. It is assumed that for each bolt in the collection, there is a corresponding nut of the same size, but initially we do not know which nut goes with which bolt. The differences in size between two nuts or two bolts can be too small to see by eye, so you cannot rely on comparing the sizes of two nuts or two bolts directly. Instead, you can only compare the sizes of a nut and a bolt by attempting to screw one into the other (assume this comparison to be a constant time operation). This operation tells you that either the nut is bigger than the bolt, the bolt is bigger than the nut, or they are the same size. What is the minimum number of comparisons needed to sort the nuts and bolts in the worst case?

Reference no: EM131245364

Questions Cloud

Pay particular attention to the stability of the growth rate : We measure economic growth by the percentage change in real GDP. In general terms outline the course of the U.S. output growth rate in recent decades, both in terms of its trend and its changes around trend. Pay particular attention to the stability ..
Devise an algorithm to sort three numbers : Devise an algorithm to sort eight numbers. It should make as few comparisons as possible. How many comparisons and swaps are required in the best, worst, and average cases?
Supply of yen for sale and equilibrium value of the yen : The US relaxes its controls on imports by Japanese companies. Other things being equal, how should this affect the (a) U.S. demand for Japanese yen, (b) supply of yen for sale, and (c) equilibrium value of the yen?
Compare and contrast the three types of unemployment : Compare and contrast the three types of unemployment. Discuss how these three types of unemployment demystify a common myth that "unemployment would not exist if the economy were operating efficiently."
What is the minimum number of comparisons needed to sort : This operation tells you that either the nut is bigger than the bolt, the bolt is bigger than the nut, or they are the same size. What is the minimum number of comparisons needed to sort the nuts and bolts in the worst case?
Explain the concept of the market equilibrium : Explain the effect on demand caused by the following: Why do supply curves slope upward? Explain? What is the difference between a change in supply and a change in demand? Explain the concept of the market equilibrium. What happens when price is set ..
What are three situation that might prompt early termination : What are three situations that might prompt early termination and why? What are the minimum activities (at least three) that need to be performed to properly terminate a project early?
The current dollar-pound exchange rate : You are given the following information. The current dollar-pound exchange rate is $2 per pound. A U.S. basket that costs $100 would cost $120 in the United Kingdom. How much is the dollar overvalued/ undervalued? What do you predict the U.S. real ex..
What is the asymptotic complexity of this algorithm : To solve the problem, compute the distance between each pair of points, using the equivalence processing algorithm to merge clusters whenever two points are within the specified distance. What is the asymptotic complexity of this algorithm? Where ..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  What is bios

What is BIOS?Just need 2 pages description of BIOS and put reference where you got stuff from.

  Types of discounts offered in a trading business

Highlight the various types of discounts offered in a trading business. State the various types of cash books and briefly state the merits and demerits of each.

  What is the cost of joining r and s using a hash join

What is the cost of joining R and S using a sort-merge join? What is the minimum number of buffer pages required for this cost to remain unchanged?

  Calculate the oil production rate

Calculate the oil production rate and calculate the well skin effect - Calculate oil rates of two wells in an undersaturated oil reservoir using generalized Vogel's equation.

  Algorithm using pseudocode

Design a greedy algorithm using pseudocode that solves this optimization problem of transferring files to disk while minimizing unused storage. The inputs to this algorithm are the number of files n, corresponding sizes (in MBs) s1, ... sn, m the n..

  Explain why a company would choose to monitor its network

Explain why a company would choose to monitor its network.

  Write a recurrence relation together with initial conditions

Write a recurrence relation together with the initial condition

  Write a program that prompts the user to enter expenses

Write a program that prompts the user to enter expenses in various expense categories they have (e.g., housing, food, clothing, transportation, education, health care, vacations), then prints the estimated FairTax that person would pay.

  The game of nim is played with a collection of piles of stic

The game of Nim is played with a collection of piles of sticks. In one move a player may remove any nonzero number of sticks from a single pile. The players alternately take turns making moves. The player who removes the very last stick loses. Say..

  Output rate for the henderson family

The Henderson family and the Clark family each used their sprinklers last summer. The water output rate for the Henderson family's sprinkler was 30L per hour. The water output rate for the Clark family's sprinkler was 35L per hour.

  Regular expression and regular sets that is not solvable

Give an example of a problem about FSAs, Regular Expression and Regular Sets that is not solvable?

  Stock an opinion or based on fact

Is the value of a stock an opinion or based on fact, please cite specific examples?

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