Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

The implementation of a (non-recursive) binary search of an array. The assumption is that a given array is sorted. We want to see if a particular value, that we'll call the target value, is in that array and, if so, where. In a binary search one checks the value in the middle of the array, i.e., if there are N elements in the array, one checks if the element with index (int)N/2 matches the target. (Note that if there are an even number of elements in the array, there is no true mid-point. The element with an index of (int)N/2 has one more element "below" it than it does "above" it.) If the value in the middle of the array is less than the target, then the function searches the portion of the array that is above the current middle, i.e., the new array to be searched starts with the element above the current middle and there are N - (int)N/2 - 1 elements in that. If the value in the middle of the array is greater than the target, then the function searches the portion of the array that is below the current middle. In this case the new array to be search starts where the original array started but now it is considered to have N - (int)N/2 elements. When the function is given an array of one element and if there is no match, the function returns NULL. (Or, if there is nothing left to search, e.g., there are no more elements "above" the current mid-point of a two-element array, the function returns NULL.) If there is a match, the function returns the address of the element that matches the target. Write a function called bin search() that takes three arguments: an integer pointer, the number of elements, and the value to be searched for (the target value). As indicated above, if the target is found in the array, the function returns the address (i.e,. an integer pointer) where the target was found. If the value is not found, it returns NULL.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9619696

Have any Question?


Related Questions in Computer Engineering

The business model for jpmorgan chase was change in 2008

The business model for JPMorgan Chase was change in 2008. Could the upside of the strategy have been achieved without exposing JPMorgan Chase the bank?

Lucinda buys a new gaming system fornbsp500 she receives

Lucinda buys a new gaming system for? $500. She receives consumer surplus of? $175 from the purchase. How much does Lucinda value her GPS? system? Please provide the explanation

Question 500-700 wordsoperations management involves

Question: 500-700 words Operations management involves various activities, such as process design, selection, management of information technology, work systems, planning and development, and quality assurance (Slack, Ch ...

Answer the following question what is the subnet mask of a

Answer the following Question : What is the subnet mask of a prefix of 26? How you obtain that subnet mask? Describe a prefix length and its used to identify networks. Descibe the ISP Tiers, classification and purposes.

Short answer essaygiven a requirement to integrate wdas

Short answer essay Given a requirement to integrate WDAs into an Enterprise Intranet, what are 2 applications that would be candidates for that, and illustrate strategies/methodologies to accomplish that.

Wat are three 3 major categories of cyber terrorism and

What are three (3) major categories of cyber terrorism and / or information warfare. Among the chosen categories, determine the one (1) that should be the top priority for the federal government to address.

Take the input of numbers and reverse the order of elements

Take the input of numbers and reverse the order of elements in that vector using recursion.

As the school year begins what trends are taking place with

As the school year begins, what trends are taking place with Educational Technology in schools?

Suppose a firm is employing all its inputs so that the mrp

Suppose a firm is employing all its inputs so that the MRP per dollar spent on each sentence is the same. this suggest that: a) amount of each resource employed will depend on both its price and its productivity b) price ...

Savings account balance write a program that calculates the

Savings Account Balance Write a program that calculates the balance of a savings account at the end of a period of time. It should ask the user for the annual interest rate, the starting balance, and the number of months ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As