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

  Describe the requirement for complex data structures

Describe the requirement for complex data structures and how they are utilized. Describe the design and application of arrays and how the array simplifies program development.

  Design analgorithm that decides for each node

Design an O(n) algorithm that decides (schedules) for each node at which time slot to start sending data such that the total number of time (slots) is minimized.

  Describe algorithm that finds maximum feasible flow in graph

Describe an algorithm that finds a maximum feasible flow in G. Denote by MF(|V|, |E|) the worst-case running time of an ordinary maximum flow algorithm.

  Determine the relative record number in the sector

Assume a direct access file consists of sectors with 1024 byte capacity. Assume also that records are thirty-two bytes long.

  Create world database using mysql

create World database using MySQL and write a Java or C# or program to access the DB

  Create algorithm which will prompt for-accept four numbers

Create an algorithm which will prompt for and accept four numbers, sort them into ascending sequence and display them to the screen. Your algorithm is to include a module

  Describe a fair coin algorithm to returns either 0 or 1

Describe a FAIRCOIN algorithm that returns either 0 or 1 with equal probability, using ONEINTHREE as your only source of randomness.

  Linear-time algorithm to find odd-length cycle in graph

Give a linear-time algorithm to find an odd-length cycle in a directed graph. You may not suppose that graph is strongly connected.

  Write an algorithm to count nodes in a linked list

storage pool and that there is a special null value. Write an algorithm to count the nodes in a linked list with first node pointed to by first."

  Creating a chart for it system

Make a chart that demonstrate the breakdown of the overall IT systems at a big corporation or breakdown a particular aspect of the IT systems such as the network or the business applications systems.

  Finding time taken to send packet from source to destination

Think about sending a document of F bytes over a path of Q links. Each link transmits at R bps. The network is lightly loaded so that there are no queuing delays.

  Currency conversion development

Currency Conversion Development

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