Location number of an array is used to store the size of the tree. When the data item of the tree is sorted in an array, the number appearing against the node will work as indexes of the node in an array. Value of the root node index is always -1 as there is no parent for root. Even empty nodes are numbered.Īrray index is a value in tree nodes and array value gives to the parent node of that particular index or node. Representation of Binary Tree using ArrayBinary tree using array represents a node which is numbered sequentially level by level from left to right. Each children have one child namely D and E respectively. The above tree represents binary tree in which node A has two children B and C. "A tree in which every node can have maximum of two children is called as Binary Tree." It is a method of placing and locating the records in a database, especially when all the data is known to be in random access memory (RAM). In binary tree, every node can have a maximum of 2 children, which are known as Left child and Right Child. Binary tree is a special type of data structure.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |