Question
QUESTIONS TO BE ANSWERED? WHAT IS THE NUMBER OF COMPARISONS MADE BY SEQUENTIAL SEARCH WHILE SEARCHING FOR 45000? HOW MANY COMPARISONS WERE MADE IN BINARY
QUESTIONS TO BE ANSWERED? WHAT IS THE NUMBER OF COMPARISONS MADE BY SEQUENTIAL SEARCH WHILE SEARCHING FOR 45000?
HOW MANY COMPARISONS WERE MADE IN BINARY SEARCH WHILE SEARCHING FOR 45000?
IN C++"In this exercise you will explore the performance difference between sequential search and binary search. To do so write a program that performs the following tasks:
Prompt the user for a file containing 100,000 unsorted integers
Read those integers into an array
Prompt the user for a search item
Search for that item (using sequential search) and report the number of comparisons required.
Sort the array. Note that this will take about a minute.
Search for that item again (using binary search) and report the number of comparisons required.
You will need to modify both of the search functions to report the number of comparisons that were made during the search.
Use your program and the file of 100,000 integers provided here to answer the six questions in the quiz."
My problem is, the code gave me the correct answer for the first two questions, but not the last two. Please help.
QUESTION 1: Was search item 20000 found? ANSWER IS YES
QUESTION 2: How many comparisons did the sequential search make while searching the list for the value 20000?
Answer: 92102 ANSWER IS CORRECT
Question 3:
How many comparisons did the binary search report in the search for 20000?
Answer: 17 Answer is correct
QUESTION 4: Was the value 45000 found in this list? Answer is false, which is correct
QUESTION 5:
How many comparisons were made by sequential search while searching for 45000?
Answer: 0 ANSWER IS INCORRECT, THIS IS WHAT I GOT WHEN I INPUT 45000 NUMBER INTO THE CODE
How many comparisons were made by binary search while searching for 45000?
Answer: 0 ANSWER IS INCORRECT, THIS IS WHAT I GOT WHEN I INPUT 45000 NUMBER INTO THE CODE
HERE IS THE CODE I USED:
#include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started