Binary Trees
A binary tree is a specialized Tree ADT where there can be at most two children(left and right). The main purpose for this type of Tree is for easy traversal of the nodes to allow for efficient searches by comparing vlues.
For example, let's suppose we have a sorted binary tree with root 1 and children, 5 and 29, who each have more children. We are searching for a specific value x, first we compare x to 29, is x less than or equal to 29? If no, then x must be strictly greater than 29 and must be in one of the children of 29.
This sort of logic is used in Binary Searches, by dividing an array in two parts continuously, we reduce the amount of searches from a linear to a logarithmic amount.Truthfully, the coding of binary tree structure and binary search algorithms is something I am anxious about. Also, I am not certain of the purpose of pre-order, in-order, and post-order traversals for binary trees. I hope to solve these problems in the near-future, because they appear to be fundamental to understanding linked-lists at a deeper level. Another goal is to gain a better understanding of the wrapper class, and how to modify linked-lists efficiently.
No comments:
Post a Comment