Explain binary searching, Fibinocci search.

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Mention the advantages of representing stacks using linked lists than arrays?

484


You are given a singly linked list. How would you find out if it contains a loop or not without using temporary space?

683


What is the need for extendible hashing?

540


Name two algorithms two find minimum spanning tree?

534


How would you implement two stacks using a single array?

548






What is the use of data structure in real life?

489


How do you use the sort function?

471


How does dynamic memory allocation help in managing data?

1057


Which sorting algorithm is best for small data?

456


Which is faster treemap or hashmap?

477


Define degree of the node?

556


Why is null not allowed in concurrenthashmap?

455


How do you solve a selection sort?

499


How to copy an array into another array?

493


Is a hashset ordered?

490