Write a program that sorts an array of random numbers

Assignment Help Data Structure & Algorithms
Reference no: EM131159004

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

Reference no: EM131159004

Questions Cloud

Report for cyber shopping project : A report for project which is cyber shopping. you just need to do references and citations for project.
Optical microscopy has mediocre resolution : Why is it nevertheless used to image small objects, instead of electron microscopes? By numerically deconvoluting optical images to cancel out the effects of diffraction (point spread function, PSF), we can gain in resolution. What "price" must be..
Write an algorithm that applies the incremental idea : Write an algorithm that applies the incremental idea of the shell sort to a selection sort. The algorithm first applies the straight section sort to items n / 2 elements apart (first, middle, and last).
What is the difference in the analysed sample volume : what is the difference in the analysed sample volume (i.e. volume of the sample from which the signal comes)?
Write a program that sorts an array of random numbers : 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.
Draw a wait-for-graph for the data above : Draw a wait-for-graph for the data above and find whether the transactions are in a deadlock or not?
What might be a concern about the use of nanotechnology : Nanotools, like the Atomic Force Microscope, allow us to build atom by atom.
What was the population of germany : What was the population of Germany in 1942? What was the population of Berlin in the same year?
What medium may be chosen for a ferrofluid for a high-vacuum : Can an aqueous solution be used? Justify...1. Give a way to confer hydrophilic behaviour to a self-assembled monolayer (SAM) coating. Or hydrophobic?

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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