0% found this document useful (0 votes)
4 views

Fdt Report (Word)

The document discusses Binary Search Trees (BST), a data structure that enables efficient searching, insertion, and deletion of data through an organized hierarchy. It outlines key features, operations, applications in various fields such as database indexing and AI, as well as advantages and disadvantages of using BSTs. The conclusion emphasizes the importance of BSTs in data management and their potential for future developments in technology.

Uploaded by

nive69555
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Fdt Report (Word)

The document discusses Binary Search Trees (BST), a data structure that enables efficient searching, insertion, and deletion of data through an organized hierarchy. It outlines key features, operations, applications in various fields such as database indexing and AI, as well as advantages and disadvantages of using BSTs. The conclusion emphasizes the importance of BSTs in data management and their potential for future developments in technology.

Uploaded by

nive69555
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Fundamentals of Data

Structure
24BTELY106

“Binary Search Tree”

Submitted By:
Name SRN
REKA S 24SUUBEADS105
VIDYASHREE V 24SUUBEADS19
VISHWAS S 24SUUBEADS173
WAHID M 24SUUBEADS175
YASHAS C S 24SUUBEADS176
YASHWANTH GOWDA K S 24SUUBEADS177
YASHWANTH V 24SUUBEADS178
H NIVEDITHA 24SUUBEADS037
R RAHUL MUKESH 24SUUBEADS102
TEJASWINI S 24SUUBEADS156

Faculty in-charge:
Mr. Denny Andrews
School of Engineering and Technology,
SNPSU

JANUARY 2025

1
CONTENTS

Sl. No. Table of Contents Page No.


1 Introduction
3-5

2 Applications of BST in real world


6-7

3 About the domain


8-9

4 Applications of the domain


10-11

5 How is it applied
12-13

6 Advantages and Disadvantages


14

7 Scope of the domain 15

8 Conclusion 16-17

2
INTRODUCTION TO BINARY SEARCH TREE

A Binary Search Tree (BST) is a type of binary tree that facilitates efficient searching,
insertion, and deletion operations due to its organized structure. It is widely used in various
applications where quick access to data is essential.

What is a Binary Search Tree?


A Binary Search Tree (BST) is a data structure used in computer science that maintains
elements in a sorted order, allowing for efficient search, insertion, and deletion operations.

Key Features of BST:


1. Node Structure:
- Each node contains a key (data value).
- Nodes have at most two children: left child and right child.

2. Ordering Property:
- For any given node N:
- All nodes in the left subtree have values less than N.
- All nodes in the right subtree have values greater than N.

3. No Duplicate Keys:
- Generally, duplicate keys are not allowed, but this may vary by implementation.

Operations on BST:
1. Search:
- Begin at the root and compare the target value with the current node.
- Traverse left if the target is smaller; traverse right if larger.
- Time complexity: O(h), where h is the tree height.

2. Insertion:
- Traverse the tree and find the appropriate position while maintaining the BST property. -
Add the new node at the identified position.

3. Deletion:
- Handle three scenarios:
- Node is a leaf (has no children).
- Node has one child.
- Node has two children (find in-order successor or predecessor).

Applications of BST:
1. Database indexing for efficient data retrieval.
2. Symbol tables in compilers.
3. Dynamic sorting algorithms.
4. Network routing tables in telecommunications.

3
A Binary Search Tree (BST) is a binary tree where each node follows these rules:
1. The left subtree contains nodes with values smaller than the root.
2. The right subtree contains nodes with values greater than the root.
3. Both left and right subtrees must also be BSTs.

Properties of BST:
- Left Subtree < Root < Right Subtree
- No duplicate values (in standard BSTs)
- In-order traversal produces a sorted sequence
- Efficient search, insert, and delete operations (O(log n) in a balanced BST)

Example of BST:

Applications of BST:
- Database indexing and searching
- File systems & storage management
- Autocomplete and spell checkers
- Network routing tables
- AI and machine learning (decision trees)

Binary Search Trees are widely used in computing due to their efficiency in searching
and organizing data. Keeping the BST balanced ensures optimal performance.

Common Applications
- Searching and sorting data
- Implementing associative arrays and sets
- Database indexing

4
Diagram of a Binary Search Tree:

Below is a simple illustration of a Binary Search Tree:

8
/\
3 10
/\\
1 6 14
/\/
4 7 13

This tree satisfies the BST properties:


- The left subtree of 8 contains nodes with keys < 8.- The right subtree of 8 contains nodes
with keys > 8.
- These properties hold for all subtrees recursively.

5
APPLICATIONS OF BST

1. Database Indexing
- Use Case: BSTs are used in database systems for indexing data, enabling quick lookups,
insertions, and deletions.
- Example: A database query for finding a record by key can be optimized with BSTs,
reducing the search time.

2. Search Algorithms
- Use Case: BSTs are employed in search operations where elements need to be accessed or
retrieved quickly.
- Example: Auto-complete features in search engines often rely on tree-based structures.

3. Dynamic Sorting
- Use Case: BSTs can dynamically maintain sorted data during insertions and deletions.
- Example: Used in applications that require real-time sorted views of data, like stock price
monitoring systems.

4. Routing Tables in Networks


- Use Case: Routing tables in network protocols use BST-like structures to store IP
addresses for efficient lookups.
- Example: Internet routers use tree structures for determining the next hop in packet
forwarding.

5. Filesystem and Hierarchical Data Representation


- Use Case: BSTs can represent and search hierarchical file systems and data.
- Example: Directories and files in a computer's file system are often managed using tree
structures.

6. Autonomous Driving Systems


- Use Case: BSTs are used in pathfinding algorithms to make decisions based on sorted data
like distances or costs.
- Example: Real-time navigation systems in autonomous vehicles.

7. Gaming Applications
- Use Case: BSTs are used in AI for decision trees and maintaining leaderboards.
- Example: Managing scores and rankings in online multiplayer games.

8. Spell Checking and Autocorrect Systems


- Use Case: BSTs help in efficiently finding and suggesting corrections for misspelled words.
- Example: Word processors and text editors.

9. Event Scheduling Systems


- Use Case: BSTs are used to store and retrieve events based on their scheduled time.
- Example: Calendar applications like Google Calendar.

6
10. Cryptography and Data Encryption
- Use Case: BSTs contribute to efficient storage and access of keys and certificates in
cryptographic systems.
- Example: Public key infrastructure (PKI) implementations.
By leveraging their ordered structure, BSTs offer optimized solutions for numerous
computational problems

7
ABOUT THE DOMAIN
A Binary Search Tree (BST) is a data structure that functions like a dictionary, where each
node stores a key-value pair, with the key being used to maintain a sorted order within the
tree, allowing for efficient searching, insertion, and deletion operations based on the
comparison of keys; essentially, if a key is smaller than the current node's key, it goes to the
left subtree, and if larger, it goes to the right subtree, ensuring a logical hierarchy for quick
access to data.

Key points about BSTs:


Structure:
Each node in a BST can have at most two children: a left child and a right child.

Ordering rule:
The key value of a node is always greater than all the keys in its left subtree and smaller
than all the keys in its right subtree.

How BSTs work as a dictionary:


Inserting a key-value pair:
i. Start at the root node.
ii. Compare the new key to the current node's key.
iii. If the new key is smaller, move to the left child; if larger, move to the right child.
iv. If you reach a null node, create a new node with the new key-value pair at that position.

Searching for a key:


i. Start at the root node.
ii. Compare the target key with the current node's key.
iii. If they match, the value is found.
iv. If the target key is smaller, move to the left child; if larger, move to the right child.
v. If you reach a null node, the key is not found.

Deleting a key:
Find the node with the key to be deleted.
Depending on the number of children the node has, replace it with either its left or right
child, or with the successor (the smallest key in the right subtree) or predecessor (the
largest key in the left subtree).

8
Advantages of using BSTs as dictionaries:
Efficient search:
In a balanced BST (where the left and right subtrees are roughly equal in size), search
operations can be performed in O(log n) time on average, where n is the number of
elements in the tree.

Ordered traversal:
By performing an in-order traversal, you can retrieve the keys in sorted order.
Disadvantages of BSTs:
Worst-case scenario:
If insertions are done in a sorted order, the BST can become skewed, leading to a linear
search time in the worst case.
Balancing techniques:
To maintain optimal performance, balancing techniques like AVL trees or Red-Black trees
might be necessary to prevent the tree from becoming too skewed.

9
APPLICATIONS OF THE DOMAIN

Database indexing using a Binary Search Tree (BST) refers to a method of organizing data
within a database by storing key-value pairs in a tree-like structure where each node
represents a key, allowing for efficient searching, insertion, and deletion operations based on
the binary search algorithm; however, while conceptually simple, a standard BST can
become unbalanced in real-world database scenarios, leading to potential performance issues,
which is why most database systems prefer more balanced tree structures like B-Trees for
indexing purposes.

Key points about using BST for database indexing:


i. Efficient search: Due to the binary search property, looking up a specific key in a BST
can be done quickly by navigating through the tree based on comparisons with the current
node's key.
ii. Insertion and deletion: Adding or removing a key-value pair in a BST involves
traversing the tree to find the appropriate location and updating the structure accordingly.
iii. Range queries: BSTs can be used to efficiently perform range queries, where you need
to retrieve data within a specified key range.
iv. Potential issue with unbalance: A major drawback of a basic BST is that it can become
unbalanced if insertions are not carefully managed, leading to situations where searches
might require traversing a long path in the tree, impacting performance.

Why B-Trees are preferred for database indexing:


i. Balancing mechanism: B-Trees are designed with a balancing mechanism that ensures
the tree remains relatively balanced even with frequent insertions and deletions, resulting in
consistent search performance.
ii. Node structure: B-Tree nodes can store multiple keys and pointers to child nodes,
allowing for efficient access to data across multiple disk blocks

Types of indexes:

i. Primary key index: An index automatically created on the primary key of a table,
ensuring uniqueness of each row.
ii. Secondary index: An index created on non-primary key columns, allowing for faster
lookups on specific data fields.
iii. Clustered index: An index where the data itself is physically ordered based on the
index key, potentially improving query performance further.
iv. Non-clustered index: An index where the data is not physically ordered based on the
index key, requiring an additional lookup to find the actual row.

10
B-trees are the most commonly used data structures for indexes as they are time-efficient for
lookups, deletions, and insertions. All these operations can be done in logarithmic time.
Data that is stored inside of a B-tree can be sorted

11
HOW IS IT APPLIED
In database indexing, a Binary Search Tree (BST) is used as a data structure to organize and
quickly locate records within a database by storing key values in a hierarchical manner,
allowing for efficient search, insertion, and deletion operations, particularly when querying
based on specific criteria; however, due to potential imbalances, most database systems opt
for a variation of BST called a B-tree, which is better optimized for disk access patterns.
Key points about using BST in database indexing:
i. Efficient Search: The binary search principle of BSTs allows for fast lookups by
comparing the search key to the node value and navigating either left or right depending on
the comparison result.
ii. Sorted Order: Data in a BST is naturally sorted, which is crucial for efficient range
queries where you need to retrieve records within a specific value range.
iii. Insertion and Deletion: BSTs provide mechanisms to insert new records and delete
existing ones while maintaining the sorted order.
iv. Balancing Issue: A major drawback of a basic BST is that it can become unbalanced
under certain insertion patterns, leading to poor performance with deep tree levels requiring
many disk accesses.

Why B-Trees are preferred in databases:


i. Optimized for Disk Access:
B-Trees are designed to minimize disk I/O operations by storing multiple keys within a
single node, reducing the number of times data needs to be retrieved from storage.
ii. Self-Balancing Mechanism:
Unlike a basic BST, B-Trees incorporate mechanisms to automatically rebalance the tree
during insertions and deletions, ensuring consistent performance

Why is it needed?
When data is stored on disk-based storage devices, it is stored as blocks of data. These
blocks are accessed in their entirety, making them the atomic disk access operation. Disk
blocks are structured in much the same way as linked lists; both contain a section for data, a
pointer to the location of the next node (or block), and both need not be stored contiguously.

Due to the fact that a number of records can only be sorted on one field, we can state that
searching on a field that isn’t sorted requires a Linear Search which requires (N+1)/2 block
accesses (on average), where N is the number of blocks that the table spans. If that field is a
non-key field (i.e. doesn’t contain unique entries) then the entire tablespace must be
searched at N block accesses.
Whereas with a sorted field, a Binary Search may be used, which has log2 N block accesses.
Also since the data is sorted given a non-key field, the rest of the table doesn’t need to be
searched for duplicate values, once a higher value is found. Thus the performance increase is
substantial.

12
13
Advantages and Disadvantages of Binary Search Tree
(BST)
Advantages of BST:

1. Efficient Searching: The average time complexity for search, insert, and delete
operations is O(log n) in a balanced BST.
2. Ordered Structure: BST maintains elements in sorted order, making in-order traversal
useful for retrieving sorted data.
3. Dynamic Operations: Unlike arrays, BST allows efficient insertions and deletions
without shifting elements.
4. Flexible Data Management: BST can store and manage hierarchical data, making it
useful for applications like database indexing.

Disadvantages of BST:

1. Unbalanced Trees: If the BST is skewed (all nodes on one side), the worst-case time
complexity becomes O(n), reducing efficiency.
2. Extra Memory Usage: BST requires additional memory for storing left and right child
pointers.
3. Complex Implementation: Compared to arrays and linked lists, BST requires more
complex algorithms for balancing and maintenance.

14
SCOPE OF HE DOMAIN

1. Advanced Database Systems


- With increasing data sizes, BST-based structures may evolve to handle more complex
indexing and faster retrieval in distributed databases.

2. AI and Machine Learning


- BST concepts can be integrated into decision-making algorithms and tree-based models
like decision trees, random forests, and gradient boosting.

3. Real-Time Applications
- Applications requiring dynamic data management, like stock trading systems, can benefit
from improved BST implementations.

4. Internet of Things (IoT)


- BSTs can play a role in efficiently managing hierarchical IoT device networks, enabling
faster data routing and processing.

5. Genome Data Analysis


- With the growing field of bioinformatics, BSTs could be adapted to handle genomic
sequence searches and data alignment.

6. Improved Balancing Techniques


- Research in self-balancing BSTs, like AVL and Red-Black Trees, may lead to more
efficient variants for specialized applications.

7. Enhanced Networking Protocols


- BST-like structures can be refined to optimize routing algorithms and address lookups in
large-scale networks.

8. Cybersecurity Applications
- BSTs may be utilized for key management and faster encryption-decryption processes in
cryptographic systems.

9. Cloud Computing and Big Data


- In cloud-based distributed systems, BSTs could evolve to manage sorted data dynamically
across multiple servers.

10. Educational Tools and Visualization


- Improved tools and visual aids for teaching BST concepts can aid in better understanding
and practical implementation in various domains.
The future of BSTs lies in their adaptability to emerging fields and their ability to optimize
operations involving hierarchical or sorted data.

15
CONCLUSION
The Binary Search Tree (BST) is a cornerstone of data structures, characterized by its
ordered structure and versatility.
It provides a systematic way to store and retrieve data efficiently, which has made it an
indispensable tool in numerous computational problems and applications.

Key Strengths:

1. **Efficiency in Operations**:
- BSTs offer efficient search, insertion, and deletion operations, especially in their balanced
forms, where these operations average O(log n) complexity.
- This makes BSTs ideal for dynamic datasets that require frequent updates.

2. **Versatility Across Applications**:


- From database indexing to real-time systems and decision-making models, BSTs have
proven their utility in various domains.
- They form the basis of more advanced structures like AVL Trees, Red-Black Trees, and B-
Trees, which are widely used in industry.

3. **Dynamic Sorted Data**:


- Unlike static sorted arrays, BSTs maintain their order dynamically, adapting to changes
while preserving efficient data access.

Limitations and Overcoming Challenges:

1. **Dependency on Balance**:
- The performance of a BST significantly depends on its balance. An unbalanced BST can
degrade to a linear structure, reducing efficiency to O(n).
- Self-balancing trees like AVL or Red-Black Trees address this limitation, ensuring optimal
performance.

2. **Complexity in Implementation**:
- Operations like deletion, especially for nodes with two children, can be intricate and
require careful handling.
- However, modern algorithms and libraries have simplified the implementation of BST
variants, making them more accessible.

16
Future Relevance:

1. **Emerging Technologies**:
- BSTs are evolving to meet the demands of emerging fields such as big data, artificial
intelligence, and Internet of Things (IoT).
- Their hierarchical structure aligns well with the needs of data-driven applications, enabling
faster and more efficient computations.

2. **Adaptability**:
- With continuous advancements, BSTs are being integrated into hybrid data structures to
enhance their performance and applicability.

Conclusion:
The Binary Search Tree, with its balance of simplicity and power, is a testament to the
enduring relevance of foundational data structures in computer science. Despite its
limitations, the adaptability and efficiency of BSTs ensure they remain at the forefront of
algorithm design and data management.
As computational challenges grow in complexity, the role of BSTs will continue to expand,
fostering innovat

17

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy