954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

What do you think? BS tree or AVL tree for fast searching?

Hello :)

Umm I have a small question :)

Which do you recommend for fast searching BST or AVL tree?

My answer: It might be the BST because it'll be noticed that in the right subtree all the numbers greater than the root will be there

also for the smaller numbers will be left

so we can search it easily by just knowing the number that we want to search for if it is greater than the root or smaller!


WHAT do you think? Is my answer right?


thanks in advance :)

Q8iEnG
Junior Poster
171 posts since Jun 2008
Reputation Points: 10
Solved Threads: 2
 

http://www.nist.gov/dads/HTML/avltree.html

If you pick your root unwisely, your BST may resemble a linked list.

Also consider
- the cost of constructing the tree in the first place
- the cost of keeping it balanced
- the number of searches performed
- the distribution of search results.

You need the whole program scenario to make an accurate judgement.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

Well, I guess I found that the AVL is much more faster than BST because if we use AVL we'll get the smallest tree by obtaining it balanced all the way

so the answer would be AVL tree is more faster in search from BST

thanks my friend :)

Q8iEnG
Junior Poster
171 posts since Jun 2008
Reputation Points: 10
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You