Difference in the number of comparisons become significant

Assignment Help Basic Computer Science
Reference no: EM131076863

The Shell sort (named for its inventor, Donald Shell) is an improved insertion sort. Rather than always exchanging adjacent items-as in an insertion sort-the Shell sort can exchange items that are far apart in the array. The Shell sort arranges the array so that every hth item forms a sorted subarray in a decreasing sequence of values. For example, if h is 5, every fi fth item forms a sorted subarray. Ultimately, if h is 1, the entire array will be sorted. One possible sequence of h 's begins at n / 2 and halves n until it becomes 1. By using this sequence, and by replacing 1 with h and 0 with h - 1 in insertion Sort, we get the following function for the Shell sort:

528_3b713dcd-1768-4348-a59d-4e82c6cdc6bd.png

Add a counter to the functions insertion Sort and shell Sort that counts the number of comparisons that are made. Run the two functions with arrays of various sizes. At what size does the difference in the number of comparisons become significant?

Reference no: EM131076863

Questions Cloud

What caused the dramatic changes to the american family : Why is the family considered the most important agent of socialization? What caused the dramatic changes to the American family? What are those changes?
What is the rate of change of the radius : I blow up a spherical balloon at a rate of 10 cm3 per second.  What is the rate of change of the radius when the balloon has radius 5 cm
List and describe the key agents of socialization : Identify and describe Kohlberg's three stages of moral development and explain how each stage applies to your own personality formation. Do you agree with Kohlberg, who suggested that the third stage is difficult for many people in our society to ..
Draw the inductor voltage and current waveforms : Problem 1. Calculate the rms value of the following waveforms (1) v(t) =15 sin(2g600
Difference in the number of comparisons become significant : Add a counter to the functions insertion Sort and shell Sort that counts the number of comparisons that are made. Run the two functions with arrays of various sizes. At what size does the difference in the number of comparisons become significant?
What would the minimum required annual savings : If the annual operating cost increases by 20%, from $2,750 to $3,300, what would the minimum required annual savings to get the 10% return on investment?
Determine whether set is empty will require nonconstant time : An advantage of choosing this implementation of "set of integers" is that adding an element to a set is a contact time operation. Which of the following is a disadvantage of this implementation? Adding elements to a very small sets could cause err..
List the calls to merge sort and to merge : Trace the merge sort algorithm as it sorts the following array into ascending order. List the calls to merge Sort and to merge in the order in which they occur
Change in velocity of the scooter : A motor scooter travels east at a speed of 9 m/s. The driver then reverses direction and heads west at 20 m/s. What was the change in velocity of the scooter?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Set the character variable r=0

Write a small program that will set the character variable R=0

  Gaussian elimination

The solution should be the vector x and flag which takes a value of 0 if the algorithm was executed completely and 1 if it wasn't.

  Synthesizing a picture of an area

Synthesizing a picture of an area, its relevance, structure and core ideas; and identifying what problems they are trying to solve and issues that need further exploration.

  Which of the following is a feature of .net framework

Which of the following is a feature of .net framework

  How is it different from other projects

If the actual termination of a project becomes a project in itself, what are the characteristics of this project?

  Error on a typical public telephone line

The probability that a single bit will be in error on a typical public telephone line using 4800 bps modem is 10 to the power -3. If no error detection mechanism is used, the residual error rate for a communication line using 9-bit frames is approxim..

  Find the sum of the 1st and the 31 term.

how many jackets must he have so that if he wore a different set of shirts and jeans each day, he could continue for 140 days before he would have to repeat a set.

  What do you understand by communication

What do you understand by Communication? Draw the Basic Block Diagram of Communication System.

  Defend role of it department strategic and operational

Defend the role of the IT department as both a strategic and operational asset for the company.

  Calculate total time spent by an employee on the job

1.Rearrange the Program. 2.Ask the user to enter employee's name, arrival time and departure time.

  Describe basic computer system and typical components

Describing the basic computer system and the typical components that perform input, output, processing, storage, and control functions.

  How implement memory allocation with strings

how implement memory allocation with strings.

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