Fdt Report (Word)
Fdt Report (Word)
Structure
24BTELY106
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
5 How is it applied
12-13
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.
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:
8
/\
3 10
/\\
1 6 14
/\/
4 7 13
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.
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.
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.
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.
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.
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 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
3. Real-Time Applications
- Applications requiring dynamic data management, like stock trading systems, can benefit
from improved BST implementations.
8. Cybersecurity Applications
- BSTs may be utilized for key management and faster encryption-decryption processes in
cryptographic systems.
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.
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