Cs Sorting Analysis Essay, Research Paper
For this lab I tested ten different sorting methods by comparing the time it took to sort ordered, reverse ordered, and random ordered arrays of Integer objects of different sizes. I had to write a Timer class that started the timer before the sorting method was called and stopped the timer when the method was finished sorting the array. The elapsed time was calculated by another method in the Timer class so that the actual run time could be printed once the method completed. My test program contained methods to run all of the sorting methods given the size, type of array (ordered, reverse or random), and the number times to run the sorting method (all entered by the user) before the timer was stopped.
For my timing experiment I carried out tests on an array of size 1,000 run 100 times through the method before printing the time (since it would be relatively fast for one iteration), an array of size 10,000 run 10 times, an array of size 25,000 run 1 time, and an array of 50,000 run 1 time. For the arrays of 1,000, 10,000, and 25,000 I did five trials for ordered, reverse, and random arrays to get a good average of the time it took since each run varied slightly. Since the array of 50,000 took a long time to run I conducted only two trials for each size on the three different types of arrays and found the average. The run times are included at the end of this report. I then calculated the time it would take to do one iteration through each of the different sizes for the different types of arrays (i.e I divided the average time it took to run the ordered array of 1,000 100 times by 100 to get the average time it would take to run it once). This data is also available at the end of this report.
The outcome of the experiments proved to be very similar to what was expected. As seen in the many graphs provided one can see that there may or may not be a best case or worse case for each of the sorts. Below are brief descriptions of the results for each sort on average
Selection Sort: As seen the first graph, Sort Comparisons, selection sort does not really have a best-case scenario. All three types of arrays took approximately the same amount of time. This is what was expected from the theoretical results.
Insertion Sort: On the contrary, it can be seen that insertion sort does indeed have a best case and a worse case. The worse case (a reverse ordered list) ends up being roughly like selection sort but when given an already sorted list the method does not take hardly any time at all to run. Given a random array for insertion sort ended up being about the average of the two. This sort also performed as the theoretical results predicted.
All of the methods tested between insertion sort and bubble sort (simple quick sort, improved quick sort, merge sort recursive, heap sort, shell sort, and non recursive merge sort) all were approximately the same for all cases, which as seen in the graph is significantly less time than selection or insertion sort.
Simple Quick Sort: When given either the reverse or ordered array the middle pivot was always the middle most value so the times were very much alike. When given a random array it is not likely that the middle element will be the exact middle value of all those in the array so the time to complete the sort takes a little longer. This was true for all of the different sizes of arrays tested.
Improved Quick Sort: Improved quick sort was fastest for the ordered list by a small amount for each of the sizes. Reverse and random were roughly the same. Overall the times for improved quick sort were slightly faster than simple quick sort, especially noticeably with the random list since there was a better chance to find a pivot closer to the middle valued element. Both quick sorts performed as thought.
Merge Sort: Since merge sort divides and conquers regardless of the order of the array (it makes all comparisons anyway even if ordered) all three tests were about the same. The theoretical results predicted that each would be the same so the experimental results do match.
Heap Sort: Surprisingly heap sort, which should be equal to the quick sorts and merge sort was about the same if not a little slower in all cases. This is not quite as predicted by the theoretical results. The difference is probably due to having to build the heap each time which can be O(n log n) or O(n).
Shell Sort: Shell sort was significantly faster than insertion sort even though the worse case is still O(n2). All cases were approximately as fast as the O(n log n) methods but started to deviate more as the size increased. This is consistent with predicted results.
Merge Sort Non Recursive: This sort performed about at the same speed as the other middle methods . The tests on random, reverse and ordered arrays were all about the same and very comparable to the recursive merge sort.
Bubble Sort: Of all the sorts bubble sort was definitely the worst. Its best case was on the reverse ordered list, worse case was the ordered list and average was the random list. Due to all the comparisons it has to do it is no surprise that is runs the slowest.
Radix Sort: Radix sort ran a lot slower than expected. This is probably due to having to build the heaps every time and by using a linked queue instead of an array-based queue. All of the sizes took about an equal amount of time since each element was composed of a maximum of 4 digits.
In my opinion the best sort depends on what kind of list you are wanting to sort. If given an almost ordered list it is clear from the experiments that insertion sort would be the best bet because it would do the least amount of work. If given an almost reverse ordered list simple quick sort would be the best. In all cases it ran slightly faster than improved quick sort on reverse ordered lists. If given a totally random list improved quick sort instead of simple quick sort since it gives the best chance of finding the element that will be closest to the middle.
Since there is no significant difference between ordered and reverse ordered lists for the two quick sorts and improved quick sort runs faster on random lists I would say the best sort of the ten tested would be improved quick sort. Though there are sorts that run faster on ordered lists improve quick sort runs the best across the board and it is not slow on lists even of size 50,000. It is an in place method so it does not use any significant extra space like merge sort does.
Другие работы по теме:
Apa Crit Essay Research Paper APA Critical
Apa Crit Essay, Research Paper APA Critical Analysis: Teaching Students How to Learn Vol. 31, No. 6, June 2000 In ?Teaching Students How to Learn? it showed the correlation between high-achieving students and their self monitoring in classes. The article goes on to say that unlike high school, college students do not have the regulation in their classes.
Cheers A Semiotic Analysis By Berger Essay
, Research Paper Cheers : A Semiotic Analysis by Berger In Arthur Asa Berger s essay, he conducts a semiotic analysis of the comedy television show Cheers. In his analysis of the show he points out many characteristics that refer to semiotics. Even though one could not agree with all of his findings, many of them are reasonable.
Carreer Essay Research Paper Ahsan ZamanPer1 Mrs
Carreer Essay, Research Paper Ahsan Zaman Per.1 Mrs. Posin I learned a lot from going to my mother?s work. I learned how mainframe computer work through a system of chips called central units. I learned that they print out everything by sorting files and using terminals to occupy the source and then print. I got a tour of my mom?s department the data entry basically my mom has to key in different kind of information and data on to spread sheets and then she transfer the files so they can be printed out.
Waterford Crystal A Case Analysis Essay Research
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
Kive Essay Research Paper
# a b c d e f g h i j k l m n o p q r s t u v w x y Grapes of Wrath, The – Book Summary and Analysis Grapes of Wrath, The – Book Analysis Grapes of Wrath, The – Joads’ Journey Great Expectations – Powerful Themes in the Novel
Writing Technique Essay Research Paper Chapter five
Writing Technique Essay, Research Paper Chapter five, Writing as Healing and the Rhetorical Tradition: Sorting Out Plato, Postmodernism, Writing Pedagogy, and Post-Traumatic Stress Disorder written by T.R. Johnson of the University of New Orleans describes the different views of how language helps a person who has encountered a traumatic experience overcome and heal.
Technology Factor Analysis Essay Research Paper The
Technology Factor Analysis Essay, Research Paper The main function of my project is to provide a means by which I can measure progress.? It will therefore have to provide resistance when it is used, and have an indicator,
Long Term Analysis Essay Research Paper Analysis
Long Term Analysis Essay, Research Paper Analysis by a Long Term Creditor The interest a long term creditor is currently receiving is 5.6%. A long term creditor could receive as much as 22.7% working somewhere else in the same industry. So, currently the industrial average is giving 17.1% more interest than workingat Cameco Corporation, which is quite a big difference.
Anaylsis Paper Essay Research Paper Analysis Paper
Anaylsis Paper Essay, Research Paper Analysis Paper 1 The EIA predicted Midwestern Illinois families to be spending as much as 40% more on heating this year compared to last year because of higher natural gas prices. The increase in price is largely due to the reduction of natural gas supplied.
Physics Lab Essay Research Paper III ResultsAnalysisMy
Physics Lab Essay, Research Paper III. Results/Analysis: My lab partner and I worked diligently in this experiment to be as accurate and as precise in our measurements and calculations with the technology provided. In part one of the experiment, we calculated the amount of force on the planet at the closest distance to be approximately 18 F.
Antony Speech Analysis Essay Research Paper Emotional
Antony Speech Analysis Essay, Research Paper Emotional Speech Analysis William Shakespeare?s ?Julius Caesar? is a well-written stage play. Shakespeare included many good speeches in his plays; one of the best was the one delivered by Antony. Antony?s speech came very shortly after Julius Caesar?s death, and the city was in much chaos.
Antony Analysis Essay Research Paper Antony Analysis
Antony Analysis Essay, Research Paper Antony Analysis Short Essay The beauty of William Shakespeare s writing does not lie in his actual writing, but the themes in which his plays suggest. Almost all of his plays can be connected to a higher theme, one that most people can relate. In the play, Antony and Cleopatra, the theme of manipulation runs ramped.
Get In Essay Research Paper Click Here
Get In Essay, Research Paper Click Here If YOU Have Friends! Can’t find the paper you need? Try Collegiate Care Comparing Casablanca to 1984 Charlie Parker at Storyville
Changes In Writing Essay Research Paper Changes
Changes In Writing Essay, Research Paper Changes in Writing My last day of high school was January 21, which was my first day at UWM. I graduated early from high school and decided to jump right into college. I was not too worried because I figured that I would catch on. I came into English 102 and found out what an analysis paper was.
Cells Essay Research Paper CellsCells are the
Cells Essay, Research Paper Cells Cells are the basic unit of all life. Even though they are the smallest unit of life they are highly complex. Each cell has enough parts to it to
The Old Man And The Sea An
Analysis Essay, Research Paper The Old Man and The Sea: An Analysis I read this book for the first time in high school and I remembered it just as well as if I had read it yesterday. As I read it again I remembered some of the
Special Relativity Essay Research Paper ESPECIALLY 2
Special Relativity Essay, Research Paper ESPECIALLY … … of Hardy’s Poems as Seen through the characters” is a study concerning Hardy’s capability of presenting irony of situation in his poetry. The analysis deals …
Vision Essay Research Paper Literary analysis Vision
Vision Essay, Research Paper Literary analysis: Vision Out of the Corner of One Eye. The main character of “Vision out of the Corner of One Eye “, a short story by Luisa Valezuela, goes through a complete one hundred-eighty degree change over the course of the story.
Athlete Dying Young Essay Research Paper The
Athlete Dying Young Essay, Research Paper The Critical Analysis & Summarization of "To An Athlete Dying Young", by A.E Housman This poem is telling the reader that you can not
Antigone Essay Research Paper Analysis on the
Antigone Essay, Research Paper Analysis on the conflict men v. women found in Antigone Many conflicts can be found within various plays. In Sophocles’ Antigone one of the many conflicts found is men versus women. The king of Thebes, Creon, has a problem with women. But not only the king, Ismene, Antigone’s sister as well refers to herself and her sister as being inferior to men.
Immigration 3 Essay Research Paper Analysis of
Immigration 3 Essay, Research Paper Analysis of a Disagreement over Immigration The authors of the 3 articles on immigration reform all seem to agree that the 1990 immigration law is inadequate, but they agree on little else. They find different impacts on the workforce, positive and negative. And they differ sharply over whether recent levels of immigration help or hurt the economy: one writer suggesting higher levels of immigrants and the other two suggesting a reduced level.
Othello Act 5 Analysis Essay Research Paper 2
Othello: Act 5 Analysis Essay, Research Paper Othello: Act 5 Analysis Iago’s intelligence causes the self destruction of Othello. He appears to be the most intelligent person in the play, Othello, by the way he acts and
Analysis Of A Newspaper Articl Essay Research
Paper 131-81 Analysis of The Union Racket There is an article in the April 24,2000 issue of The Detroit News called The Union Racket . This article explains how the International Brotherhood of Teamsters currently stands with its lawsuit against its former president. Though the essay dose communicate many useful points, is dose a poor job of not meeting the seven failure requirements for any writing as established by Orwell.
Arrest Analysis Essay Research Paper Arrest
Arrest Analysis Essay, Research Paper Arrest: – An arrest is the act of depriving an individual of his liberty by legal authority. This is to inform you the two procedures of arrest. The procedures of arrest are warrant and non-warrant.
Soil Analysis Report Essay Research Paper Soil
Soil Analysis Report Essay, Research Paper Soil Analysis Within the next few paragraphs, I will tell you all about the soil sample I collected and did tests on. I got some soil from out of one of my mom’s gardens. This one had a lot of flowers from Florida. This is a summary of what all I did to work on finding everything about my soil.
An Analysis Of From Silence To Words
Essay, Research Paper An Analysis of From Silence to Words: Writing as Struggle Through this essay, Min-zhan Lu depicts the struggles she faced growing up in China while speaking English. I feel the paragraph that best exemplifies this struggle is one found on page 239. In this one paragraph, Lu expresses her fear of losing command over the two languages that she speaks, English and Chinese.
A Critical Analysis Essay Research Paper A
A Critical Analysis Essay, Research Paper A Critical Analysis of Evelyn Waugh’s “Bella Fleace Gave a Party” In the introduction to “Bella Fleace Gave a Party”, extensive background is revealed to help the reader understand the times in which the character lived. It is a time of enormous change in the political and social structure of these people’s lives.
Robert Bunsen Essay Research Paper Robert Wilhelm
Robert Bunsen Essay, Research Paper Robert Wilhelm Bunsen s name was famous for a a few discoveries in the field of chemistry. For example you might recognize Bunsen from the lab device, the Bunsen Burner . He also helped invent the spectroscope and discovered spectrum analysis. And at the beginning of his career, he discovered that iron oxide is an antidote for arsenic.
How To Writing A Research Essay Essay
, Research Paper How To Writing A Research Essay The toughest part of the essay, for me, was taking all the information I had gained and reduce it to a mere few pages essay. After all, quality is better
Critical Analysis Essay Research Paper The case
Critical Analysis Essay, Research Paper The case involving the hog mega-farms in Tatnall County raises interesting questions as to who has proper jurisdiction over such cases. While all sides, federal, state, and local, can claim that they should have jurisdiction, the state has the most power in this situation.