STARTING OUT W/PROGRAM.LOGIC...-TEXT
STARTING OUT W/PROGRAM.LOGIC...-TEXT
5th Edition
ISBN: 2810022369454
Author: GADDIS
Publisher: PEARSON
Question
Book Icon
Chapter 9, Problem 7PE
Program Plan Intro

Search Benchmarks

Program Plan:

  • Include the required header files.
  • Declare the necessary function prototype and constants.
  • Define the main () function.
    • Declare the necessary variables.
    • Declare and define the array values.
    • Get the number that is to be searched from the user.
    • Call the function “searchlinear()” to perform linear search and count the number of comparisons made during  the search.
    • Display the number of comparison made by the linear search.
    • Call the function “searchbinary()” to perform binary search and count the number of comparisons made during  the search.
    • Display the number of comparison made by the binary search.
  • Define the “searchlinear()” method,
    • Declare the necessary variables
    • Use a loop that iterates for the elements that is present in the array.
    • A counter variable that gets incremented is used inside the loop to count the number of comparison made to find the target element.
    • A condition statement is used to compare the values of the array and the search element.
    • Return the count of the comparisons made.
  • Define the “searchbinary()” method,
    • Declare the necessary variables.
    • A loop that iterates to search the elements those are present in the array.
    • A counter variable that gets incremented to count the number of comparison that is being made.
    • A condition statement that validates the position of the search element in the array.
    • Based on the position of the array the search is performed with the count of the comparison that is made.
    • Return the count of the comparison made.

Blurred answer
Students have asked these similar questions
a database with multiple tables from attributes as shown above that are in 3NF, showing PK, non-key attributes, and FK for each table? Assume the tables are already in 1NF. [Hint: 3 tables will result after deducing 1NF -> 2NF -> 3NF]
If a new entity Order_Details is introduced, will it be a strong entity or weak entity? If it is a weak entity, then mention its type (ID or Non-ID, also Justify why)?
Which one of the 4 Entities mention in the diagram can have a recursive relationship? Order, Product, store, customer.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning