Sorting and Searching

Sorting and Searching - Sorting and Searching Dr. David...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Sorting and Searching Dr. David Gaitros Department of Computer Science
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sorting The arrangement of items in either ascending or descending order. Requires that two items can be compared and that some aspect or key portion of the items can be compared and that a relationship of less than, greater than, or equal to exists.
Background image of page 2
Example Let’s say that I have an array defined as below and that it has been loaded with numbers. The number of items in the array is defined by the variable ArraySize. double LargeArray[MAXSIZE]; int ArraySize; BubbleSort(LargeArray,ArraySize);
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
// *********************************************************************** // Swap to double numbers. Used in the sorting routine twice. // ************************************************************************ void swap(double *num1,double *num2) { double temp = *num1; *num1 = *num2; *num2=temp; } // ************************************************************************ // Bubble Sort . // Go through the list until no exchanges are made.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

Sorting and Searching - Sorting and Searching Dr. David...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online