Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Write a program that sorts an array of random numbers, using the shell sort and the quick sort. Both sorts should use the same data. Each sort should be executed twice. For the first sort, fill the array with random numbers between 1 and 999. For the second sort, fill the array with a nearly ordered list. Construct your nearly ordered list by reversing elements 19 and 20 in the sorted random-number list. For each sort, count the number of comparisons and moves necessary to order this list.

Run the program three times, once with an array of 100 items, once with an array of 500 items, and once with an array of 1000 items. For the first execution only (100 elements), print the unsorted data followed by the sort data in 10-by-10 matrixes (10 rows of 10 numbers each). For all runs print the number of comparisons and the number of moves required to order the data.

To make sure your statistics are as accurate as possible, you must analyze each loop limit condition test and each selection statement in your sort algorithms. The following notes should help with this analysis:

a. All loops require a count increment in their body.

b. Pretest loops (while and for) also require a count increment either before (recommended) or after the loop to count the last test.

c. Remember that C uses the shortcut rule for evaluating Boolean and/or expressions. The best way to count them is with a comma expression, as shown below. Use similar code for the selection statements.

while ((count++, a) && (count++, b))

Analyze the statistics you generated and write a short report (less than one page) concerning what you discovered about these two sorts. Include the data in Table, one for the random data and one for the nearly ordered data. Calculate the ratio to one decimal place.

List Size

Shell

Quick

Ratio (shell/quick)

Compares

 

 

 

100

 

 

 

500

 

 

 

1000

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Moves

 

 

 

100

 

 

 

500

 

 

 

1000

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Table: Sorting Statistics Format for Project

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91914450

Have any Question?


Related Questions in Computer Engineering

Question suppose you transferred three packets each

Question : Suppose you transferred three packets each containing 1000 bytes of data from one system to another. The entire process took 1 minute and 20 seconds. What is the data rate (bits/sec) of this transmission? Can ...

1 the economy is in a recession with high unemployment and

1) The economy is in a recession with high unemployment and low output (i.e. the output currently is lower than the natural level of output) a) Draw a graph of aggregate demand and aggregate supply to illustrate the curr ...

Discuss the impact of the market on well-diversified

Discuss the impact of the market on well-diversified portfolios. What does this suggest about the performance of mutual funds? Include real-world examples in your explanation.

Select one of the methods that makes the most sense to you

Select one of the methods that makes the most sense to you, and list the steps in detail. Imagine that you're tutoring another student in how to calculate subnets, and be sure to include enough detail that the steps woul ...

A streaming company needs to measure the average time

A streaming company needs to measure the AVERAGE time spread for users who watch video on their platform in a session. Each user has one time spread, which is the difference between her longest session streaming video an ...

Question suppose an algorithm requires cn2nbspoperations

Question : Suppose an algorithm requires cn 2  operations when performed with an input of size n (where c is a constant). a. How many operations will be required when the input size is increased from m to 2m (where m is ...

Question set up geometric data tables for a unit cube using

Question ; Set up geometric data tables for a unit cube using only vertex and polygon tables and a single polygon table. Compare the two methods for representing the unit cube with a representation using three data table ...

Question suppose you had to design a wired ethernet network

Question : Suppose you had to design a wired Ethernet network for a 4-story office building containing 20 users per floor. Each floor is 90 meters in length and 5 meters in height. Draw a network topology of your propose ...

Question suppose a destination computer receives several

Question : Suppose a destination computer receives several packets from a source. How can it be sure that the fragments belonging to a datagram are not mixed with the fragments belonging to another datagram?

System analysis project can you answer the 4 questions at

System Analysis project: can you answer the 4 questions at the task section. Personal Trainer, Inc. owns and operates fitness centers in a dozen Midwestern cities. The centers have done well, and the company is planning ...

  • 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