Hello guys...I need help wth a c# program(Console plz) where im asked to show bubble sort in these conditions: the array is of 5000 int elements,reverse sorted,already sorted and randomly sorted. The output shud show:number of comparisons and how many swaps were performed. I need the same for insertion and selection sort but I just need help wth one of them il figure out the rest.
Thanks
Loading
VulpesPosted Aug 30, 2011, 6:34 AM
Avuya MxoliPosted Sep 2, 2011, 12:13 AM
Sam HobbsPosted Sep 1, 2011, 5:37 PM
The challenge is to do a binary sort. That is a little more complicated and more efficient. Something even more challenging is to do binary sort and update the array with new entries when they are encountered. The one I wrote like that was written in about 1974 using COBOL. I re-wrote a program to do a dynamically-built array and binary sort as I described and improved the efficiency of the program significantly. I appreciate however that modern languages such as C# and databases have very efficient sorting functions.
So in other words, read a file and do a binary search and when the item is not found, add it to the array in the proper sort order. Most binary search algorithms do not include the dynamic update such as taht.
For studying sorting Sorting and Searching Algorithms is a very interesting site. On that page, click in the "InsertSort" box then the "ShellSort" box then the "QuickSort" box. You will see each of the three algorithms in action. I don't know if an InsertSort is the same as a bubble sort but it looks like it is.
For doing a look-up of data that needs to also be dynamically updated, a b-tree would be useful.
Avuya MxoliPosted Sep 1, 2011, 4:26 PM
Avuya MxoliPosted Sep 1, 2011, 4:23 PM
Sam HobbsPosted Aug 30, 2011, 12:33 PM
I know this is a class assignment because a bubble sort is so inefficient that its use is impractical for real-world problems.