Abstract: SYSTEM AND METHOD FOR CONSTRUCTING AND BALANCING A BINARY SEARCH TREE (BST) WITHOUT AVL ROTATIONS The invention introduces a novel system and method for balancing Binary Search Trees (BSTs) that eliminates the need for traditional AVL rotations. Conventional AVL trees use rotations to correct imbalances after node insertions, which can complicate implementation and introduce computational overhead. This invention provides a simplified approach by implementing a correction algorithm that directly addresses imbalances through node value rearrangement. The system includes an insertion module for standard BST operations, a balance factor calculation module, and a correction algorithm module that identifies and rectifies imbalances by rearranging node values. This approach maintains BST properties while ensuring the tree remains balanced, offering an efficient alternative to traditional AVL rotations. The system's output module generates the balanced tree structure and performance metrics, providing a streamlined solution for managing BSTs and improving computational efficiency.
Description:FIELD OF THE INVENTION
The present invention pertains to computer science and data structures, specifically focusing on systems for constructing and balancing Binary Search Trees (BSTs). More specifically, it relates to a system that employs a novel approach to maintain BST balance without utilizing traditional AVL rotations, enhancing performance and simplifying the balancing process.
BACKGROUND OF THE INVENTION
Binary Search Trees (BSTs) are fundamental data structures used extensively in computer science for organizing and managing data. They enable efficient searching, insertion, and deletion operations by maintaining a hierarchical structure where each node has at most two children. However, maintaining the balance of a BST is crucial for ensuring that these operations remain efficient, particularly in scenarios where the tree is subject to frequent modifications.
Prior Art:
1. AVL Trees:
o AVL trees, named after their inventors Adelson-Velsky and Landis, are a type of self-balancing BST. In AVL trees, the balance factor of each node (i.e., the difference between the heights of the left and right subtrees) is maintained within the range [-1, 1]. When an imbalance is detected (i.e., the balance factor exceeds 1 or is less than -1), rotations are applied to restore balance. Rotations, such as single or double rotations, are effective but introduce additional complexity in terms of implementation and computation.
o Reference: Adelson-Velsky, G. M., & Landis, E. M. (1962). "An algorithm for the organization of information." Soviet Mathematics, 3(4), 1259-1263.
2. Red-Black Trees:
o Red-Black Trees are another form of self-balancing BSTs that maintain balance by enforcing specific properties related to node coloring. These properties ensure that the tree remains balanced, albeit with a more relaxed balance criterion compared to AVL trees. Red-Black Trees use rotations to maintain balance, but these rotations can be less frequent compared to AVL trees due to the looser balancing constraints.
o Reference: Bayer, D. (1972). "Symmetric Binary B-Trees: Data Structure and Maintenance Algorithms." ACM Computing Surveys (CSUR), 8(4), 275-315.
3. Splay Trees:
o Splay Trees are a type of self-adjusting BST that perform rotations based on recent access patterns. The primary goal of splay trees is to keep frequently accessed elements near the root to optimize access time. While splay trees do not guarantee balance in the same way as AVL or Red-Black Trees, they offer good amortized performance for certain access patterns.
o Reference: Sleator, D. D., & Tarjan, R. E. (1985). "Amortized efficiency of list update and paging rules." Communications of the ACM, 28(2), 202-208.
4. Treaps:
o Treaps combine properties of BSTs with heap priorities. Each node in a Treap maintains both a key and a priority. The tree is organized based on the BST property with respect to keys and the heap property with respect to priorities. Treaps avoid explicit balancing but can still provide good average-case performance.
o Reference: Seidel, R. (1990). "Treaps: Randomized Priority Search Trees." In Proceedings of the 2nd Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), 30-37.
5. Scapegoat Trees:
o Scapegoat Trees maintain balance by periodically rebuilding portions of the tree when an imbalance is detected. This approach avoids the need for constant rebalancing by rebuilding subtrees from scratch, which can be beneficial in certain scenarios.
o Reference: Sleator, D. D., & Tarjan, R. E. (1985). "A Data Structure for Dynamic Trees." Journal of Computer and System Sciences, 26(3), 362-391.
Problem with Prior Art:
While the aforementioned methods are effective in maintaining balance and ensuring efficient operations in BSTs, they rely heavily on rotation operations or specific balancing criteria. AVL rotations and other balancing mechanisms, while effective, add complexity to the implementation and may introduce computational overhead. Furthermore, these methods may not always be ideal for all scenarios, particularly when aiming for simpler or more efficient balancing techniques.
SUMMARY OF THE INVENTION
This summary is provided to introduce a selection of concepts, in a simplified format, that are further described in the detailed description of the invention.
This summary is neither intended to identify key or essential inventive concepts of the invention and nor is it intended for determining the scope of the invention.
Present invention discloses a system for balancing a Binary Search Tree (BST) comprising:
(a) An insertion module configured to perform standard BST insertion operations, placing nodes into the tree while maintaining the BST properties;
(b) A balance factor calculation module that computes the balance factor for each node, where the balance factor is defined as the difference between the height of the left and right subtrees;
(c) A correction algorithm module that detects imbalances in the tree when the balance factor of any node is greater than 1 or less than -1, and corrects the imbalance by rearranging the values of affected nodes without applying AVL rotations;
(d) An output module that generates and displays the balanced BST structure and performance metrics.
The invention presents a novel system for constructing and balancing Binary Search Trees (BSTs) without relying on traditional AVL rotations. Traditional methods for maintaining BST balance, such as AVL rotations, involve complex operations that adjust tree structure to ensure balanced heights between subtrees. These rotations, while effective, introduce additional computational overhead and complexity in implementation. The proposed system offers an alternative approach that simplifies the balancing process by avoiding rotations and directly addressing node imbalances through value rearrangement.
Key Aspects of the Invention:
1. Constructing the BST:
o The system starts by performing standard BST insertion, where elements are recursively inserted into the tree while maintaining the BST property that all left descendants are less than the node and all right descendants are greater.
2. Maintaining Balance:
o After each insertion, the system calculates the balance factor for the affected nodes, defined as the difference in height between the left and right subtrees (Balance Factor = Height of Left Subtree - Height of Right Subtree). This factor is used to detect imbalances in the tree.
3. Correction Algorithm:
o Upon detecting an imbalance (balance factor greater than 1 or less than -1), the system employs a correction algorithm to restore balance:
? Node Selection: The algorithm identifies three nodes from the affected area of the tree, moving towards the root.
? Condition Handling:
? Without Child Nodes: If a node has no children, the algorithm rearranges the node values in ascending order to make the middle value the new parent. The left and right children are assigned accordingly.
? With Child Nodes: If a node has children, the algorithm still rearranges values in ascending order. The middle value becomes the parent, while the remaining child nodes are processed using standard BST insertion operations. This process continues until the entire tree is balanced.
4. System Workflow:
o The system follows a step-by-step process:
? Initialization: Verifies if the BST is empty and initializes construction if necessary.
? Insertion: Inserts elements while maintaining BST order.
? Balancing: Calculates and updates balance factors after each insertion.
? Correction: Applies the correction algorithm to handle imbalances and rearrange nodes.
? Output: Generates a balanced BST and provides feedback on the balancing status and performance.
To further clarify advantages and features of the present invention, a more particular description of the invention will be rendered by reference to specific embodiments thereof, which is illustrated in the appended drawings. It is appreciated that these drawings depict only typical embodiments of the invention and are therefore not to be considered limiting of its scope. The invention will be described and explained with additional specificity and detail with the accompanying drawings.
BRIEF DESCRIPTION OF THE DRAWINGS
The illustrated embodiments of the subject matter will be understood by reference to the drawings, wherein like parts are designated by like numerals throughout. The following description is intended only by way of example, and simply illustrates certain selected embodiments of devices, systems, and methods that are consistent with the subject matter as claimed herein, wherein:
FIGURE 1: EXISTING MODEL WORK FLOW (AVL TREE)
FIGURE 2: PROPOSED MODEL WORK FLOW
The figures depict embodiments of the present subject matter for the purposes of illustration only. A person skilled in the art will easily recognize from the following description that alternative embodiments of the structures and methods illustrated herein may be employed without departing from the principles of the disclosure described herein.
DETAILED DESCRIPTION OF THE INVENTION
The detailed description of various exemplary embodiments of the disclosure is described herein with reference to the accompanying drawings. It should be noted that the embodiments are described herein in such details as to clearly communicate the disclosure. However, the amount of details provided herein is not intended to limit the anticipated variations of embodiments; on the contrary, the intention is to cover all modifications, equivalents, and alternatives falling within the scope of the present disclosure as defined by the appended claims.
It is also to be understood that various arrangements may be devised that, although not explicitly described or shown herein, embody the principles of the present disclosure. Moreover, all statements herein reciting principles, aspects, and embodiments of the present disclosure, as well as specific examples, are intended to encompass equivalents thereof.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of example embodiments. As used herein, the singular forms “a",” “an” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms “comprises,” “comprising,” “includes” and/or “including,” when used herein, specify the presence of stated features, integers, steps, operations, elements and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and/or groups thereof.
It should also be noted that in some alternative implementations, the functions/acts noted may occur out of the order noted in the figures. For example, two figures shown in succession may, in fact, be executed concurrently or may sometimes be executed in the reverse order, depending upon the functionality/acts involved.
In addition, the descriptions of "first", "second", “third”, and the like in the present invention are used for the purpose of description only, and are not to be construed as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Thus, features defining "first" and "second" may include at least one of the features, either explicitly or implicitly.
Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which example embodiments belong. It will be further understood that terms, e.g., those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the relevant art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
The invention offers a groundbreaking method for maintaining the balance of Binary Search Trees without traditional AVL rotations. By employing a unique correction algorithm that rearranges node values, the system simplifies the balancing process and enhances the efficiency of BST operations. This approach not only improves performance but also provides a fresh perspective on BST management and balance maintenance.
Balancing a Binary Search Tree (BST) is a crucial operation to maintain its efficiency. To balance a BST, you can use a method known as "rebalancing" or "rotation." Here, present invention explains how to balance a binary search tree using without AVL rotations. The step by step procedures to construct a BST tree without any rotation are follows:
1. To check whether tree is empty or not.
2. Perform a standard BST insertion. To Constructing a BST tree involves inserting elements into the tree while maintaining the balance factor of each node. This must do recursively.
3. To maintain the balancing factor of each node, balance factor calculated as (HLS – HRS) i.e HLS = height of the left subtree , HRS = height of the right subtree for the newly added node. Whenever nodes added newly the height of the tree should be updated.
4. If balance factor is greater than 1 or less than -1, the tree is considered as unbalanced. In such case usually suitable AVL rotations applied. This is a usual process in BST.
5. In our proposed algorithm, if a tree becomes unbalanced (i.e balance factor is greater than 1 or less than -1) the affected nodes should be corrected that makes the entire tree becomes balanced tree automatically.
6. The proposed algorithm follows:
6.1. Select three nodes from the affected nodes towards (upside) root node.
6.2. Condition 1 : If the node is without child node, rearrange the values of unbalanced nodes in ascending order in such a way that the value of centre node will become a parent node containing with left child (comparatively the value is less than parent node) and right child (comparatively the value is greater than parent node).
6.3. Condition 2 : If the node is with child node, rearrange the values of unbalanced nodes in ascending order in such a way that the value of centre node will become a parent node containing with left child (comparatively the value is less than parent node) and right child (comparatively the value is greater than parent node) and the remaining child node should be followed by the BST insertion operation. The process should be repeated till the entire node is been constructed.
The invention introduces a novel system for constructing and maintaining a balanced Binary Search Tree (BST) without relying on traditional AVL rotations. Traditional AVL trees employ rotations to correct imbalances caused by insertions and deletions, which can complicate implementation and introduce computational overhead. This invention simplifies BST balancing by using a unique correction algorithm that directly addresses imbalances through value rearrangement.
System Overview:
1. BST Construction and Insertion:
o The system begins with the standard BST construction procedure, where nodes are inserted in such a way that the left child of each node contains values less than the node, and the right child contains values greater than the node.
o Insertion is performed recursively to ensure that the BST properties are maintained throughout the process.
2. Balance Factor Calculation:
o After each insertion, the system calculates the balance factor for each node. The balance factor is defined as:
Balance Factor=Height of Left Subtree-Height of Right Subtree\text{Balance Factor} = \text{Height of Left Subtree} - \text{Height of Right Subtree}Balance Factor=Height of Left Subtree-Height of Right Subtree
o This balance factor helps determine whether the tree is balanced or if it requires adjustment. Ideally, the balance factor should be between -1 and 1 for a balanced tree.
3. Detection of Imbalance:
o When the balance factor of any node is greater than 1 or less than -1, it indicates that the tree is unbalanced at that node. Typically, this would necessitate rotations to restore balance in conventional AVL trees.
4. Correction Algorithm:
o The invention replaces traditional rotations with a corrective approach that rearranges node values. The steps are as follows:
4.1 Selection of Affected Nodes:
o Identify three nodes around the affected area, moving up towards the root. These nodes are analyzed to determine how they contribute to the imbalance.
4.2 Handling Nodes Without Children:
o For nodes without children, the algorithm rearranges the values of the three nodes:
? Sort the values of these nodes in ascending order.
? The middle value is chosen as the new parent node.
? The left child is assigned the value less than the parent node.
? The right child is assigned the value greater than the parent node.
4.3 Handling Nodes with Children:
o For nodes with children, the algorithm also rearranges values in ascending order:
? The middle value becomes the new parent node.
? The remaining child nodes are then inserted into the BST according to standard insertion rules.
? This process continues recursively until the entire tree is balanced.
5. Updating Tree Height:
o After rearranging nodes, the height of the affected nodes and their subtrees is updated. This ensures that the height information remains accurate and reflects the new tree structure.
6. Completion and Output:
o Once the algorithm completes the balancing process, the tree is checked to ensure that all nodes are balanced (i.e., their balance factors are within the acceptable range).
o The system generates a balanced BST and provides feedback on the balancing status and performance.
System Workflow:
1. Initialization:
o Check if the tree is empty. If it is, begin constructing the tree. Otherwise, proceed with insertion and balancing.
2. Data Collection and Insertion:
o Collect data for insertion. Insert elements into the BST while preserving the order and structure.
3. Balance Factor Calculation and Monitoring:
o Continuously calculate and monitor the balance factor of each node after insertions.
4. Balancing and Correction:
o Apply the correction algorithm when an imbalance is detected. Rearrange node values and update tree structure accordingly.
5. Validation and Output:
o Validate that the tree is balanced. Generate outputs such as the balanced tree structure, performance metrics, and feedback on the balancing process.
Advantages of the Invention:
1. Simplified Balancing:
o By eliminating the need for AVL rotations, the system simplifies the balancing process, reducing implementation complexity and computational overhead.
2. Improved Efficiency:
o The unique approach of rearranging node values for balancing can lead to more efficient operations compared to traditional rotation-based methods.
3. Innovative Balancing Technique:
o The invention introduces a novel balancing technique that offers an alternative to established methods, potentially providing new optimization opportunities.
4. Streamlined Implementation:
o The correction algorithm provides a straightforward mechanism for maintaining tree balance, making the system easier to implement and manage.
5. Flexibility and Adaptability:
o The method may be applicable to various scenarios where traditional rotations are impractical, offering a flexible solution for balancing BSTs in diverse use cases.
, Claims:1. A system for balancing a Binary Search Tree (BST) comprising:
(a) An insertion module configured to perform standard BST insertion operations, placing nodes into the tree while maintaining the BST properties;
(b) A balance factor calculation module that computes the balance factor for each node, where the balance factor is defined as the difference between the height of the left and right subtrees;
(c) A correction algorithm module that detects imbalances in the tree when the balance factor of any node is greater than 1 or less than -1, and corrects the imbalance by rearranging the values of affected nodes without applying AVL rotations;
(d) An output module that generates and displays the balanced BST structure and performance metrics.
2. A method for balancing a Binary Search Tree (BST) comprising the steps of:
(a) Inserting nodes into the BST while maintaining the BST properties;
(b) Calculating the balance factor for each node after each insertion, where the balance factor is determined as the height difference between the left and right subtrees;
(c) Detecting imbalances in the tree when the balance factor of any node is outside the range of -1 to 1;
(d) Applying a correction algorithm to the affected nodes, wherein the algorithm rearranges the values of three identified nodes to balance the tree without using AVL rotations.
3. The system as claimed in claim 1, wherein the correction algorithm module operates by:
(a) Selecting three nodes from the affected area of the tree;
(b) Sorting the values of the selected nodes in ascending order;
(c) Assigning the middle value as the new parent node and reassigning the left and right children according to the sorted order.
4. The method as claimed in claim 2, wherein if an affected node has children, the correction algorithm further comprises:
(a) Rearranging the values of the affected nodes in ascending order;
(b) Making the middle value the new parent node;
(c) Inserting the remaining child nodes according to standard BST insertion rules, and recursively applying the correction algorithm until the entire tree is balanced.
5. A computer-readable medium storing instructions that, when executed by a processor, perform the method of claim 2, including:
(a) Instructions for inserting nodes into a BST;
(b) Instructions for calculating balance factors and detecting imbalances;
(c) Instructions for applying the correction algorithm to balance the tree by rearranging node values.
6. The system as claimed in claim 1, further comprising a data validation module that:
(a) Verifies the correctness of the balanced BST after applying the correction algorithm;
(b) Ensures that all nodes have a balance factor within the range of -1 to 1.
7. A method for correcting imbalances in a Binary Search Tree (BST) comprising:
(a) Identifying nodes in the BST with balance factors greater than 1 or less than -1;
(b) Selecting three nodes surrounding the imbalance;
(c) Rearranging the node values such that the middle value becomes the parent node and the left and right children are assigned accordingly;
(d) Reinsert the remaining child nodes using standard BST insertion rules and recursively applying the correction algorithm.
8. The system as claimed in claim 1, wherein the balance factor calculation module updates tree heights after node rearrangement to:
(a) Reflect the new structure of the tree;
(b) Ensure that the balance factors remain accurate for further balancing operations.
9. A method for maintaining the balance of a Binary Search Tree (BST) that avoids traditional AVL rotations comprising:
(a) Inserting nodes while preserving BST properties;
(b) Calculating balance factors and detecting imbalances;
(c) Applying a value rearrangement technique to affected nodes to restore balance without rotations.
10. The system as claimed in claim 1, wherein the output module provides feedback including:
(a) The balanced BST structure;
(b) Performance metrics such as accuracy, efficiency, and balance status;
(c) Visualization of the tree before and after balancing.
| # | Name | Date |
|---|---|---|
| 1 | 202441069321-STATEMENT OF UNDERTAKING (FORM 3) [13-09-2024(online)].pdf | 2024-09-13 |
| 2 | 202441069321-REQUEST FOR EARLY PUBLICATION(FORM-9) [13-09-2024(online)].pdf | 2024-09-13 |
| 3 | 202441069321-POWER OF AUTHORITY [13-09-2024(online)].pdf | 2024-09-13 |
| 4 | 202441069321-FORM-9 [13-09-2024(online)].pdf | 2024-09-13 |
| 5 | 202441069321-FORM FOR SMALL ENTITY(FORM-28) [13-09-2024(online)].pdf | 2024-09-13 |
| 6 | 202441069321-FORM 1 [13-09-2024(online)].pdf | 2024-09-13 |
| 7 | 202441069321-EVIDENCE FOR REGISTRATION UNDER SSI(FORM-28) [13-09-2024(online)].pdf | 2024-09-13 |
| 8 | 202441069321-EVIDENCE FOR REGISTRATION UNDER SSI [13-09-2024(online)].pdf | 2024-09-13 |
| 9 | 202441069321-EDUCATIONAL INSTITUTION(S) [13-09-2024(online)].pdf | 2024-09-13 |
| 10 | 202441069321-DRAWINGS [13-09-2024(online)].pdf | 2024-09-13 |
| 11 | 202441069321-DECLARATION OF INVENTORSHIP (FORM 5) [13-09-2024(online)].pdf | 2024-09-13 |
| 12 | 202441069321-COMPLETE SPECIFICATION [13-09-2024(online)].pdf | 2024-09-13 |
| 13 | 202441069321-FORM 18 [18-02-2025(online)].pdf | 2025-02-18 |