Write a program to find the number of comparisons

Assignment Help Basic Computer Science
Reference no: EM13306565

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 1000 elements.
a. Use a random number generator to fill list.
b. Use any sorting algorithm to sort list. Alternatively, you can use the function insertOrd 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 search 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.)
III. Use the sequential search algorithm to search the list
d. Print the number of comparisons for Steps c.i, c.ii, and c.iii. If the item is found in the list, then print its position.

Reference no: EM13306565

Questions Cloud

What needs to be done to avoid such problem : Based on our class discussion regarding E-R Diagrams, if an attribute is appearing in a number of entity sets does this situation lead to the issue of data redundancy? If yes, what needs to be done to avoid such problem?
Decision analysis : Decision Analysis
Determine the delays of the carry out bit c48 : Determine the delays of the carry out bit c48 and the gate complexity, i.e, the numbers of AND, OR and XOR gates needed for implementing the following 48-bit adders.
Find the capacitance of the two circular metal plates : Two circular metal plates with diameter 18 cm and separated by a distance of 2mm are connected in series with a 10 cm long cylindrical piece of material with diameter 1 mm and a 10 v battery. FIND the capacitance of the two circular metal plates wi..
Write a program to find the number of comparisons : 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 1000 elements.
Merit system principles and prohibited personnel practices : Merit system principles and prohibited personnel practices are actually fairly complicated to understand and far from obvious in their logical restrictions. Depending on one's government affiliation either as a local
Suppose the person lives for two periods : Suppose the person lives for two periods, U = u(c1) + bu(c2), and can acquire an asset at price q, with c1 = w1 – qa and c2 = (d + q*)a + w2, where d = dividend and q* = selling price.
Do they differ from nation to nation : Who regulates research into such things as stem cell research? Is legislation the only form of control for biomedical research? Are there economic or cultural processes that could control these activities? Do they differ from nation to nation? Why..
What are some other uses for the break statement : How about using a break in a switch statement, show how you can really have a problem if you skip the break statement in a switch.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Design of e-business applications

With that in mind, how do you think the Americans with Disabilities Act affects website design and design of E-business applications?

  Follow-up actions for making decisions

What are the things you should consider in making this decision, and based on your choice, what would be your follow-up actions?

  K-map to simplify output function using don-t care

Use K-map to simplify output function of x by don't care conditions.

  Discuss benefits of working with shell scripts

Discuss the benefits and provide examples of working with shell scripts.

  When merge sorting you could recursively

Suppose when merge sorting you could recursively sort four sub-lists instead of two and still merge them all in linear time. Give the recurrence relation that describes this.

  Create an applet to draw a digit using the method fillrect

In Java Programming, Create an applet to draw a digit using the method fillRect of the class Graphics. For instance, if the input is 4, the applet will display the digit 4. I will also need the HTML code along with the code

  Implement the stack and queue with a single class

Implement the stack and queue with a single class interfaces with a unique class that is derived from class LinkedDeque (Code Fragment 5.21)

  Kinds of support and tools are available with visual basic

What kinds of support and tools are available with Visual Basic? Sum-up your research, and make sure to reply to each of the questions.

  Identify organizations that may be susceptible to each type

Identify organizations that may be susceptible to each type of attack and explain what the perpetrators might hope to gain by infiltrating their systems.

  Create an application that generates a quiz

Create an application that generates a quiz. Prompt for the user's first and last name, college major, and confidence in test taking (high, medium, or low). The quiz should contain at least five true/false questions about horticulture.

  Find an article that describes a computerized database

Find an article that describes a computerized database system that is in use in the field in which you work

  The concept of global and scope of variables

Having looked at what happens to variables within functions and the concept of global and scope of variables, reflect on why Vectors are such a useful data structure. Explain your reasoning and provide examples to support it.

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