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

  Create incident response policy covers development-response

Policy to reduce network down-time if future incidents happen. Create incident response policy which covers development of incident response team, disaster recovery process and business continuity planning.

  Create and validate html documents

Describe the structure of the World Wide Web as interconnected hypertext documents and create and validate HTML documents.

  Discuss the costs and support considerations of the web

Based on your research, write a 6-8 page paper that researches the use, adoption, and implementations of two different Web server technologies. The paper should also discuss the costs and support considerations of the Web server applications.

  Write a flowchart with single alternative decision structure

Write a flowchart with a single alternative decision structure that assigns 0 to the variable b and assigns 1 to the variable c it the variable a is less than 10

  Decryption algorithm: reverse the encryption algorithm

Decryption algorithm: Reverse the encryption algorithm. The permutation, however, should (circular) shift the bit pattern by 1 bit to the right

  What are areas addressed in cbk

What are the areas addressed in the CBK? Was policy explicitly listed? If not, where do you feel it is addressed in the CBK?

  Forest point construction at forest point construction

Forest Point Construction At Forest Point Construction, your boss says that he can estimate the total project time based on his personal experience. You are trying to convince him that he should use project management techniques to handle a comple..

  Create an object-oriented java web application

Create an object-oriented Java Web application that: a. displays the entire product inventory to the screen, including the product ID, name, description, and quantity. b. allows for a product to be searched by the product ID or product name.

  Update columns orderplaced subtotal shipping tax and totel

After a shopper completes an order, a procedure is called to update the following columns in the Basket table: orderplaced, subtotal, shipping, tax and total.

  Write a statement that assigns true to recalled

A bool variable named recalled has been declared. Given an int variable modelYear write a statement that assigns true to recalled if the value of modelYear falls within the recall range and assigns false otherwise. Do not use an if statement in th..

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Construct the work breakdown structure

Construct the Work Breakdown Structure, define all of the activities and sequence these, schedule the project and then resource and budget the project using Microsoft Office Project.

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