Search_Benchmarks.cpp

# Search_Benchmarks.cpp - Alex Chapman ID S02084651 Binary...

• Homework Help
• 3

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

//****************************************** // Alex Chapman ID: S02084651 // Binary and Sequential search // 2017-04-09 //****************************************** #include <iostream> // header #include <cstdlib> // header using namespace std; // using standard library void bubbleSort (int[], int); // function prototype void originalOrder (int[], int); // function prototype int binarySearch(int[], int, int); // function prototype int sequentialSearch(int[], int, int); // function prototype int i; // global i for loops const int ZERO = 0; // constant const int ONE = 1; // constant const int TWO = 2; // constant int main () // main entry pont { const int SIZE = 20; // constant int array[SIZE] = {26, 45, 56, 12, 78, 74, 39, 22, 5, 90, 87, 32, 28, 11, 93, 62, 79, 53, 22, 51}; // initilize list int searchNumber, index, index_b, n; originalOrder(array, SIZE); // call cout << endl; cout << endl; bubbleSort(array, SIZE); // call string again = "Y"; while (again == ("Y") || again == ("y")) { // Get the name to search for. cout << "Enter a number to search for: " << endl; cin >> searchNumber; index = binarySearch(array, searchNumber, SIZE); index_b = sequentialSearch(array, SIZE, n); if (index != -1) { // Display the number. cout << "The position of the number is " << array[index] << endl; } else { // The number was not found in the array.

Subscribe to view the full document.

{[ snackBarMessage ]}

Upload your study materials now and get free access to over 25 million documents.

Upload now for FREE access Or pay now for instant access
###### "Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern