DBMS Concepts

DBMS Tutorial Components of DBMS. Applications of DBMS The difference between file system and DBMS. Types of DBMS DBMS Architecture DBMS Schema Three Schema Architecture. DBMS Languages.

DBMS ER Model

ER model: Entity Relationship Diagram (ERD) Components of ER Model. DBMS Generalization, Specialization and Aggregation.

DBMS Relational Model

Codd’s rule of DBMS Relational DBMS concepts Relational Integrity Constraints DBMS keys Convert ER model into Relational model Difference between DBMS and RDBMS Relational Algebra DBMS Joins

DBMS Normalization

Functional Dependency Inference Rules Multivalued Dependency Normalization in DBMS: 1NF, 2NF, 3NF, BCNF and 4NF

DBMS Transaction

What is Transaction? States of transaction ACID Properties in DBMS Concurrent execution and its problems DBMS schedule DBMS Serializability Conflict Serializability View Serializability Deadlock in DBMS Concurrency control Protocols

Difference

Difference between DFD and ERD

Misc

Advantages of DBMS Disadvantages of DBMS Data Models in DBMS Relational Algebra in DBMS Cardinality in DBMS Entity in DBMS Attributes in DBMS Data Independence in DBMS Primary Key in DBMS Foreign Key in DBMS Candidate Key in DBMS Super Key in DBMS Aggregation in DBMS Hashing in DBMS Generalization in DBMS Specialization in DBMS View in DBMS File Organization in DBMS What Is A Cloud Database What Is A Database Levels Of Locking In DBMS What is RDBMS Fragmentation in Distributed DBMS What is Advanced Database Management System Data Abstraction in DBMS Checkpoint In DBMS B Tree in DBMS BCNF in DBMS Advantages of Threaded Binary Tree in DBMS Advantages of Database Management System in DBMS Enforcing Integrity Constraints in DBMS B-Tree Insertion in DBMS B+ Tree in DBMS Advantages of B-Tree in DBMS Types of Data Abstraction in DBMS Levels of Abstraction in DBMS 3- Tier Architecture in DBMS Anomalies in Database Management System Atomicity in Database Management System Characteristics of DBMS DBMS Examples Difference between Relational and Non-Relational Databases Domain Constraints in DBMS Entity and Entity set in DBMS ER Diagram for Banking System in DBMS ER Diagram for Company Database in DBMS ER Diagram for School Management System in DBMS ER Diagram for Student Management System in DBMS ER Diagram for University Database in DBMS ER Diagram of Company Database in DBMS Er Diagram Symbols and Notations in DBMS How to draw ER-Diagram in DBMS Integrity Constraints in DBMS Red-Black Tree Deletion in DBMS Red-Black Tree Properties in DBMS Red-Black Tree Visualization in DBMS Redundancy in Database Management System Secondary Key in DBMS Structure of DBMS 2-Tier Architecture in DBMS Advantages and Disadvantages of Binary Search Tree Closure of Functional Dependency in DBMS Consistency in Database Management System Durability in Database Management System ER Diagram for Bank Management System in DBMS ER Diagram for College Management System in DBMS ER Diagram for Hotel Management System in DBMS ER Diagram for Online Shopping ER Diagram for Railway Reservation System ER Diagram for Student Management System in DBMS Isolation in DBMS Lossless Join and Dependency Preserving Decomposition in DBMS Non-Key Attributes in DBMS Data Security Requirements in DBMS DBMS functions and Components What is Homogeneous Database? DBMS Functions and Components Advantages and Disadvantages of Distributed Database Relational Database Schema in DBMS Relational Schema Transaction Processing in DBMS Discriminator in DBMS

Advantages of Threaded Binary Tree in DBMS

We know that every node in a binary tree contains both its data value and the address pointers for its left and right children. A null pointer is used to indicate the lack of a child node in a binary tree when a node is a leaf node or does not have any left or right children.

A binary tree is a type of tree data structure consisting of left and right nodes, or nodes, where each node has at most two descendants. The root node (the first node in the tree) is the starting point for everything.

The following are contained in each node of the tree:

  • Information pointing to the left child
  • Pointer to the appropriate kid
  • The left and right child pointers in the case of a leaf node point to null.

A Threaded Binary tree: What is it?

Instead of putting NULL in the left and right child pointers in a Threaded Binary Tree, the nodes will store the predecessor and successor in order.

In a threaded binary tree, the in-order successor of a node is stored for nodes whose right pointer is null (if-exists), and the in-order predecessor of a node is stored for nodes whose left pointer is null (if-exists).

As their in-order predecessor and successor do not exist, the leftmost and the rightmost child pointers of a tree always point to null.

A threaded binary tree is a variation of the normal binary tree. A threaded binary tree stores the ordered ancestor (if any) if the node's left pointer is NULL, and stores the ordered successor (if any) if the node's right pointer is NULL.

There are two types of threaded binary trees:

  • Single-threaded binary tree
    With this type, if a node has a right null pointer, that right pointer is threaded to the node's successors (if any) in order.
  • Double-threaded binary tree
    In this type, a null pointer to the left of a node points to its in-order, predecessor, and a null pointer to its right to its in-order successor.
    The node structure of a double-stranded binary tree:
    A binary tree with a binary chain uses two boolean variables:
    right and left threads.

Advantages of Threaded Binary Trees

Let's discuss some advantages of threaded binary trees:

  • No stack or recursion needed:
    Unlike binary trees, threaded binary trees do not require stacks or recursion for traversal.
  • Optimal memory usage:
    Another benefit of the thread binary tree data structure is reduced memory waste. In a normal binary tree, memory is wasted if the left and right pointers of a node are NULL. But threaded binaries overcome this problem by storing predecessors/successors in order.
  • Time complexity:
    Traversing in-order in a threaded binary tree is faster because it gets the next node in O(1) time than a regular binary tree that takes O(height). However, insert and delete operations take longer in threaded binary trees.
  • Reverse pass:
    Double-stranded threaded binary trees even allow backward traversal.
  • These trees allow linear traversal of elements.
  • You can find the parent node without explicitly using the parent pointer
  • Threaded tree allows traversing nodes back and forth sequentially
  • A node contains pointers to its ordered ancestors and descendants
  • For a given node, you can easily find the predecessor and successor nodes in order. So searching is much easier.

Disadvantages of Threaded Binary Tree

Let's discuss some drawbacks that may cause problems for programmers using it.

  • Complex inserts and deletes:
    Preserving the predecessor/successor order of nodes with null left/right pointers makes inserting and removing nodes a slower and much more complicated process.
  • Additional memory usage:
    To distinguish between threads and normal links, we use additional storage in the form of right thread and left thread variables. (However, there is a more efficient way to distinguish between threads and regular links).

Conclusion

With binary trees, a child often encounters fewer than two nodes. In such scenarios, the linked list representation of these trees will store nulls in the left/right pointers of the nodes. To avoid this memory waste, we introduce the concept of a threaded binary tree.

A binary tree consists of all left child pointers (usually zero points to the node's unordered ancestors, if any) and all right child pointers (usually to the node's unordered successors, if any). It is threaded by moving the zero point of).

There are two types of it: single-threaded binary tree and double-threaded binary tree. We also discussed its advantages and disadvantages.