Explain binary searching, Fibinocci search.

Answer Posted / nipesh.....janghel....bca..2nd

Binary Search
The binary search is the standard method for searching
through a sorted array. It is
much more efficient than a linear search, where we pass
through the array elements in
turn until the target is found. It does require that the
elements be in order.
The binary search repeatedly divides the array in two, each
time restricting the search to
the half that should contain the target element.
In this example, we search for the integer 5 in the 10-
element array below:

2 : 5 : 6 : 8 : 10 : 12 : 15 : 18 : 20 : 21

Loop 1 - Look at whole array
Low index = 0, high index = 9
Choose element with index (0+9)/2 = 4
Compare value (10) to target
10 is greater than 5, so the target must be in the lower
half of the array
Set high index = (4-1) = 3
Loop 2
Low index = 0, high index = 3
Choose element with index (0+3)/2 = 1
Compare value (5) to target
5 is equal to target
Target was found, index = 1

Is This Answer Correct ?    23 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by 2-3 tree?

505


How does insertion sort works?

504


Explain what is the type of the algorithm used in solving the 8 queens problem?

465


How does a heap sort work?

460


When would you use a hashmap?

450






List some applications of multilinked structures?

505


What are basic algorithms?

450


Is array part of collection framework?

475


What is array and its types with example?

497


Write an algorithm to show the reverse of link list?

462


write a program to show the insertion and deletion of an element in an array using the position

492


What are the advantages of array?

464


What is vector and types of vector?

479


What is two-dimensional array?

514


What is a stable sorting algorithm?

567