Binary search algorithm

Assignment Help Data Structure & Algorithms
Reference no: EM13158721

1. Write a program to find the number of comparisons using the binary search and sequential search algorithms as follows:

Suppose list is an array of 1,000 elements.

a. Use a random number generator to fill list.

b. Use any sorting algorithm to sort list. Alternatively, you can use the function insert0rd to initially insert all the elements in the list.

c. Search the list for some items, as follows:
     i. Use the binary search algorithm to seach the list. (You might need to modify the algorithm given in this chapter to count the number of comparisons.)
     ii. Use the binary search algorithm to search the list, switching to a sequential search when the size of the search list reduces to less than 15. (Use the sequential search algorithm for a sorted list).

d. Print the number of comparisons for Steps c.i and c.ii. If the item is found in the list, then print its position.

Reference no: EM13158721

Questions Cloud

What is the new pressure of the gas : At constant volume the temperature of 2.0atm was 325K. The temperature is increased to 400K. What is the new pressure of the gas?
What about whale fins compared to fish fins : Are the limbs modified into wings of bats and the wings of birds examples of evolutionary analogy or homology? What about whale fins compared to fish fins?
Mature age a protected class : There is much debate today concerning the possibility of adding the aged as a sixth protected class. What arguments pro and con exist for making advanced or mature age a protected class?
Do you think this pattern of trade is consistent : Do you think this pattern of trade is consistent with the principle of comparative advantage?
Binary search algorithm : Use the binary search algorithm to seach the list. (You might need to modify the algorithm given in this chapter to count the number of comparisons.)
Calculate the equilibrium concentrations of ch3cl : In a basic aqueous solution, chloromethane undergoes a substitution reaction in which Cl- is replaced by OH-: CH3Cl(aq)+OH-(aq) CH3OH(aq) + Cl-(aq)
Share to common stockholders : Orchard Corporation's common stock was selling at $52 per share at the end of its fiscal year. All dividends for the year had been paid, including $4.80 per share to common stockholders.
What are the main orders of placental mammals : What are the main orders of placental mammals? What are some representative species and distinguishing features of each of those orders?

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd