Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I want a visual studio c++ programming code for the following task. Q1. If you have a sorted array you can use a very efficient

I want a visual studio c++ programming code for the following task.

Q1. 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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions

Question

Explain the nature of human resource management.

Answered: 1 week ago

Question

Write a note on Quality circles.

Answered: 1 week ago

Question

Describe how to measure the quality of work life.

Answered: 1 week ago