What are some practical applications of binary search trees?
-
-
Answer:
Binary search trees are collections that can efficiently maintain a dynamically changing dataset in sorted order, for some "sortable" type.*Having a sorted array is useful for many tasks because it enables binary search to be used to efficiently locate elements. The problem with a sorted array is that elements can't be inserted and removed efficiently.The binary search tree is a different way of structuring data so that it can still be binary searched (or a very similar procedure can be used), but it's easier to add and remove elements. Instead of just storing the elements contiguously from least to greatest, the data is maintained in many separate chunks, making adding an element a matter of adding a new chunk of memory and linking it to existing chunks.Binary search trees support everything you can get from a sorted array: efficient search, in-order forward/backwards traversal from any given element, predecessor /successor element search, and max /min queries, with the added benefit of efficient inserts and deletes. With a self-balancing binary search tree (BST), all of the above run in logarithmic time.* It can store any type that has a total order defined on it. A total order means a binary comparison operation between elements has been defined, and the elements can be arranged in a unique sequence from smallest to greatest based on this operation. For example, integers or reals with the typical ("natural") order.
Eugene Yarovoi at Quora Visit the source
Other answers
Binary trees are a good way to express arithmetic expressions. The leaves are operands and the other nodes are operators. The left and right sub-trees of an operator node represent sub-expressions that must be evaluated before applying the operator at the root of the sub-tree. See https://en.wikipedia.org/wiki/Binary_expression_tree for more details.BST used in Unix kernels for managing a set of virtual memory areas (VMAs). Each VMA represents a section of memory in a Unix process. VMAs vary in size from 4KB to 1GB. Also want to support range queries to determine which VMAs overlap a given range. http://www.stanford.edu/~blp/papers/libavl-abstract.pdfEach IP packet sent by an Internet host is stamped with a 16-bit id that must be unique for that source-destination pair. Linux kernel uses an AVL tree(height balanced) indexed by IP address. Hashing would be faster, but want to avoid attacker sending IP packets with worst-case inputs. http://www.stanford.edu/~blp/papers/libavl-abstract.pdfSource: Algorithms(Sedgewick)
Mohit Modi
Std::map in C++ and TreeMap in java are implemented as height balanced binary search tree, more specifically as a red black tree.
Aditya Saurabh
Saloni Verma has already covered many aspects. In addition to that, Binary Search Tree can be used for keeping data sorted. With height balancing the running time for the same can be reduced. Moreover they can provide the hierarchical structure for a file system.
Keshav Sharma
Related Q & A:
- What is going on with my yahoo search?Best solution by Yahoo! Answers
- What ranking factors are used for international search?Best solution by Quora
- What online site can I use to search for a job?Best solution by Yahoo! Answers
- What are practical applications of Queues?Best solution by Quora
- What's a practical car repair you should know if you drive a jalopy?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.