***data in the file are in ascending order. load them from inputfile into an arr
ID: 3638699 • Letter: #
Question
***data in the file are in ascending order. load them from inputfile into an array containing 5000 elements***implement the search such that it will be called 3 times, each with a different "size" array. The 3 "sizes" will be 1,000 elements to search, 2500 elements to search, 5000 elements to search. When you implement the algorithm, include a “search” counter that will keep track of how many comparisons were performed to find a number. After a search is performed, display and/or write to file two pieces of information.
1.Whether or not the searched-for number was found.
2.How many comparisons were made in the process. Show the number of comparisons made even if the searched-for number has not been found!
Explanation / Answer
#include #include using namespace std; void search(int[],int,int); int main() { int num[5000],i,key,max=5000; ifstream in; in.open("input.txt"); //open file if(in.fail()) //is it ok? { coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.