Binary Tree can be Represented using Array Representation or Linked List RepresentationÁlvaro Dias*
Received: 31-Jan-2022, Manuscript No. TOCOMP-23-91881; Editor assigned: 02-Feb-2023, Pre QC No. TOCOMP-23-91881 (PQ); Reviewed: 16-Feb-2023, QC No. TOCOMP-23-91881; Revised: 21-Feb-2023, Manuscript No. TOCOMP-23-91881 (R); Published: 28-Feb-2023
A threaded binary tree is a type of binary tree data structure where the empty left and right child pointers in a binary tree are replaced with threads that link nodes directly to their in-order predecessor or successor, thereby providing a way to traverse the tree without using recursion or a stack. Threaded binary trees can be useful when space is a concern, as they can eliminate the need for a stack during traversal. However, they can be more complex to implement than standard binary trees. In the linked representation of binary trees, more than one half of the link fields contain NULL values which results in wastage of storage space. If a binary tree consists of n nodes then n+1 link fields contain NULL values. So in order to effectively manage the space, a method was devised by Perlis and Thornton in which the NULL links are replaced with special links known as threads. Such binary trees with threads are known as threaded binary trees. Each node in a threaded binary tree either contains a link to its child node or thread to other nodes in the tree. In two-way threaded Binary trees, the right link field of a node containing NULL values is replaced by a thread that points to nodes in order successor and left field of a node containing NULL values is replaced by a thread that points to nodes in order predecessor.
A binary tree can be represented using array representation or linked list representation. When a binary tree is represented using linked list representation, the reference part of the node which doesn’t have a child is filled with a NULL pointer. In any binary tree linked list representation, there are a number of NULL pointers than actual pointers. Generally, in any binary tree linked list representation, if there are 2N number of reference fields, then N+1 number of reference fields are filled with NULL (N+1 are NULL out of 2N). This NULL pointer does not play any role except indicating that there is no link (no child). Threaded binary trees are specialized data structures that are optimized for specific types of traversal. While they can be more efficient than regular binary trees for these types of operations, they may not be as useful in other scenarios. For example, they cannot be easily modified e.g. inserting or deleting nodes without breaking the threading. Threaded binary trees can be used to evaluate arithmetic expressions in a way that avoids recursion or a stack. The tree can be constructed from the input expression, and then traversed in-order or pre-order to perform the evaluation. Threaded binary trees can be used in disk-based data structures to improve performance. By threading the tree, it can be traversed in a way that minimizes disk seeks and improves locality of reference. In certain applications, threaded binary trees can be used to navigate hierarchical data structures, such as file systems or web site directories.
The tree can be constructed from the hierarchical data, and then traversed in-order or pre-order to efficiently access the data in a specific order. In a database, threaded binary trees can be used to index data based on a specific. The tree can be constructed with the indexed values as keys, and then traversed in-order to retrieve the data in sorted order.
Conflict of Interest
The author has nothing to disclose and also state no conflict of interest in the submission of this manuscript.
Copyright: This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.