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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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