Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to test the function binarySearch. Using bubbleSort to sort the

ID: 3652629 • Letter: W

Question

Write a program to test the function binarySearch. Using bubbleSort to sort the list before the search #include #include using namespace std; void bubblesort (int list[],int length); int binarySearch(const int list[], int listLength, int searchItem); void main(); int list [20],n,i; int search; int searchItem; cout<<"Enter the size of the list: "; cin>>n; cout<<"Enter the searchItems: "; for(i=0;i>list[i]; } cout<<"Enter items to be searched: "; cin>>searchItem; bubblesort(list,n); search=binarysearch(list,n,searchItem); if(search==-1) { cout<<" Search is not successful "; } else cout<<" item found at : "<<search; system("pause"); } void bubblesort (int list[], int size) { int temp,i,j; for (i=0; ilist[j+1]) { temp=list[j]; list[j]=list[j+1]; list[j+1]=temp; } } }; } { int first = 0; int last = listLength - 1; int mid; bool found = false; while (first <= last && !found) { mid = (first + last) / 2; if (list[mid] == searchItem) found = true; else if (list[mid] > searchItem) last = mid - 1; else first = mid + 1; } if (found) return mid; else return -1; }

Explanation / Answer

can you please repost the question with proper formatting. It is very difficult to read your question properly

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote