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

Write a program in C++ to implement two different searching techniques: - Linear

ID: 3817597 • Letter: W

Question

Write a program in C++ to implement two different searching techniques:
- Linear search
- Binary search
on a set of integer values stored in a single dimension array. The user will provide as input the set of the integer values and the number they did like to search for, and the option for the search technique they did like to use. Based on these three inputs provided by the user, your program will output a success prompt and the array index at which the value was found; if the search was successful. Or it should prompt a "not found" message and an option to re-try the search.

Your program must be written using functions (worth 10 points).

Input case:

7,2,5,67,89,11,23,6,18,43

option: Linear Search
Search value: 16

option: Binary Search

Search Value: 11

Explanation / Answer

Ans. full C++ codes have been provided for the program,review it.

cout<<"input 1 if want to search again "; //choice for again searching a new element

cin>>cho;

if(cho==1)

{

cout<<"enter the element to be searched ";

cin>>e;

Lsearch( L,x,e); //Lsearch function called again with new element 'e'

}

}

void Bsearch(int B[50],int y,int ele) //function for binary search algorithm

{

int z,chi;

cout<<"input 1 if want to search again ";

cin>>chi;

if(chi==1) //choice for again searching an element

{

cout<<"enter the element to be searched ";   

cin>>z;

Bsearch( B,y,z); // Bsearch function will be called with new element 'z'

}

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