DOC PREVIEW
Saddleback CS 1B - Searching & Sorting

This preview shows page 1-2 out of 7 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Chapter 10 Searching Sorting 10 1 Sequential Search list does not need to be ordered Sequential Search index 0 found false F while found index size T F if a index key index T found true end MEMORIZE THIS ALGORITHM 10 2 Binary Search ordered lists only BinarySearch found false bott 0 top size 1 while found bott top F T mid bott top 2 F F top mid 1 if a mid key if a mid key T found true T bott mid 1 end 10 3 Selection Sort SelectionSort i size 1 i 1 i large a 0 index 0 j 1 j i j if a j large F T large a j index j a index a i a i large end 10 4 InsertionSort i size 1 i 1 i index i j 0 j i 1 j if a j a index F T index j temp a i a i a index a index temp end 10 5 Name s Text File Bubble Sort Lab Enter the following in a file called mydata dat Al Average 2 5 Sue Smart 3 98 Phil Physics 3 75 Lucy Lost 1 5 Wally Workshard 3 02 Ruth Returningwoman 4 0 Write a program containing three functions called LoadArrays BubbleSort and PrintArrays LoadArrays will open the above file and load the arrays declared in the main an array of strings to hold the names and an array of floats to hold the grade point averages The arrays will be sent to function BubbleSort and you will use the bubble sort flowchart done in class to sort from the highest grace point average to the lowest Don t forget to move the names too The PrintArrays function outputs the contents of the two arrays in table format main declare necessary variables call LoadArrays call PrintArrays call BubbleSort call PrintArrays end main 10 6 Name Date Lab Exercise Create the following array int intArray 8 4 1 7 12 8 13 9 21 Implement the sequential search as a void function and as a value returning function Test both versions by sending a key that is in the list and a key that is not Think carefully about the parameters and local declarations if any for each version 10 7


View Full Document

Saddleback CS 1B - Searching & Sorting

Download Searching & Sorting
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Searching & Sorting and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Searching & Sorting and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?