Write a c program to implement scan sort for contiguous


Problem

There is an even easier sorting method, which, instead of using two pointers to scan sort move through the list, uses only one. We can call it scan sort, and it proceeds by starting at one end and moving forward, comparing adjacent pairs of keys, until it finds a pair out of order. It then swaps this pair of entries and starts moving the other way, continuing to swap pairs until it finds a pair in the correct order. At this point it knows that it has moved the one entry as far back as necessary, so that the first part of the list is sorted, but, unlike insertion sort, it has forgotten how far forward has been sorted, so it simply reverses direction and sorts forward again, looking for a pair out of order. When it reaches the far end of the list, then it is finished.

(a) Write a C++ program to implement scan sort for contiguous lists. Your program should use only one position variable (other than the list's count member), one variable of type entry to be used in making swaps, and no other local variables.

(b) Compare the timings for your program with those of insertion_sort.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a c program to implement scan sort for contiguous
Reference No:- TGS02643122

Expected delivery within 24 Hours