Explain binary searching, Fibinocci search.

Answers were Sorted based on User's Feedback



Explain binary searching, Fibinocci search...

Answer / 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

Explain binary searching, Fibinocci search...

Answer / kamal.r

Searching a binary tree for a value that matches a key value
is FAST, especially for tightly packed trees (a tightly
packed tree contains about twice as many elements as the
previous level)
o Therefore at most log(2)n comparisons are required either
to find a match or determine that no match exists.
o For example, searching a tightly packed 1000-element
binary search tree requies at most 10 comparisons because 2
o a binary search tree with n elements has a minimum of
log(2)n levels
o in-order: 0. if parameter node is null then return; 1.
recursive traverse left subtrees entirely 2. display data 3.
recursive traverse right subtrees entirely
o pre-order: 0 if param node is null return 1. display data
2. recursive traverse left subtrees entirely 3. recursive
traverse right subtree entirely.
o post-order: 0 if param node is null then return; 1.
recursive traverse left subtrees entirely 2. recursive
traverse right subtree entirely 3. display data
o to keep it efficient you must make sure to keep tree
balanced. Best way is to ensure the inputted data is coming
in with random values...If they are sorted in
ascending/descending order the tree will definitely become
unbanlanced

Fibnacci search

The Fibonacci Sequence is defined such that the first two
numbers of
the sequence are 0 and 1. subesequent numbers are the sum of the
previous two. e.g.

0, 1, 1, 2, 3, 5, 8, 13 ......

Is This Answer Correct ?    18 Yes 5 No

Explain binary searching, Fibinocci search...

Answer / vinoth kumar.r

Hey guys its fibonacci search not fibonacci sequence.
Its is efficient when locality of reference is plays a
greater role.
Go here:
http://en.wikipedia.org/wiki/Fibonacci_search_technique

Is This Answer Correct ?    10 Yes 6 No

Explain binary searching, Fibinocci search...

Answer / bharath

finally a sensible answer.........
fibonacci search is based on fibonacci heaps.
it is advanced structure tugher to implement and even more
efficient than BSTs , latest kernels used it fr app handles...

Is This Answer Correct ?    2 Yes 2 No

Explain binary searching, Fibinocci search...

Answer / saroj kumar satapathy

In case of fibonacii search, themain difference is that we
neednot the division of no of element in an array. Because
the febonacii element is the addition of previous two
numbers.

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More Data Structures Interview Questions

Can we give size to arraylist?

0 Answers  


Difference between hashset and treeset?

0 Answers  


What is a circular singly linked list?

0 Answers  


Is arraylist a list?

0 Answers  


Why is reflection slower?

0 Answers  






What are common data structures?

0 Answers  


Explain what is a spanning tree?

0 Answers  


Why is sorting important?

0 Answers  


How is a queue works?

0 Answers  


Which time complexity is best?

0 Answers  


Differentiate between the singly linked list and doubly linked list.

0 Answers  


What is a simple graph?

0 Answers  


Categories