How will you get to the middle index

Assignment Help Computer Engineering
Reference no: EM132178526

Q. If you have a sorted array you can use a very efficient (in terms of time!) algorithm to find any element of your interest in the array.

The array is sorted so you begin your search by comparing the search number with the middle index of the array. How will you get to the middle index?

Since the array is sorted if the search number is smaller than the middle index value then it can only be in the first half of the array and you need not look at any element in the last half of the array.

Again you compare the search number with the middle index of the first half of the array and check if it is larger or smaller. You repeat these steps, discarding one half of the array everytime. You will stop this algorithm only when either you have found the number you are looking for OR when the portion of the array you are searching from is only the size of a single element.

You may look at youtube for a pictorial explanantion of the binary search algorithm. You are expected to implement Binary Search Algorithm over a sorted list.

Reference no: EM132178526

Questions Cloud

How would you describe active directory domain services : How would you describe Active Directory Domain Services? How do you think an administrator benefits from implementing Active Directory Domain Services?
Media play many different roles in health service delivery : Social media play many different roles in health service delivery. Explain any three such health service delivery with examples?
Am working on evaluation of discipline : Am working on evaluation of discipline, profession and growth of project management and wanted guide on how to go about it
Understand strategic requirements : Why is it important for a supply professional to understand strategic requirements?
How will you get to the middle index : The array is sorted so you begin your search by comparing the search number with the middle index of the array. How will you get to the middle index?
Identification and defining commercial equivalents : What are some differences between needs identification and defining commercial equivalents? Please also explain why it is preferable to separate into two stages
How do i round the number to the nearest inch : Now how do I round the number to the nearest inch without using 'round' function??
Write code to find tuesdays average temperature : A weather analysis program uses the following array to store the temperature for each hour of the day on each day of a week int temp[7][24];
What types of data are collected by retail stores : What differences are there be between online and in-person sales data? How does this data give them a business advantage?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Discuss the benefits of having a computer security incident

discuss the benefits of having a computer security incident response team within your enterprise. Also discuss the major steps involved

  Simulate your design and then print and turn in the circuit

Use full adders (FAs) and logic gates to build a device to compute y-3z, where y and z are 4-bit unsigned inputs.

  How does frame relay compare to sending data over internet

What happens when a user transmits data faster than the agreed-upon committed information rate? How does frame relay compare to sending data over the Internet?

  The ajax extensions tab of the toolbox

Inside the ContentTemplate element of the UpdatePanel server control add the standard RadioButtonList server control, Label server control and Button server control.

  Define the hash of m as y

Let X be a specified constant and let M be a message consisting of a single block, where the block size is the size of the key in the block cipher.

  How can we break the string into smaller strings

Consider the task of removing all punctuation marks from a string. How can we break the string into smaller strings that can be processed recursively?

  Discuss how the three levels of management hierarchy

Discuss how the three levels of management hierarchy: strategic, management, and operational relates to the mission of a business.

  Write down a two page proposal for the backhaul connecting

write a two page proposal for the backhaul connecting several campuses for your company in one metropolitan area. all

  Design and write a python program that converts a date

Write a program that defines and calls a function called has_no_e() that returns the value 'True' if the received word does not have an "e" in it.

  What are requirements specifications for a program

What are requirements specifications for a program? Name at least six phases of the software life cycle and state what each is.

  Declare a string variable myname and assign your name to it

Declare an integer variable named numStates and assign a value of 50 to it. Declare a string variable myName and assign your name to it.

  Develop an activity diagram based on the following

Develop an activity diagram based on the following narrative. Note any ambiguities or questions that you have as you develop the model.

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