This document discusses binary search trees and balanced binary search trees like AVL trees. It begins with an overview of binary search trees and their properties. It then introduces the concept of balance factors and describes how AVL trees maintain a balance factor between -1 and 1 for every node through rotations. The document provides examples of single and double rotations performed during insertion to rebalance the tree. It concludes with an algorithm for inserting a node into an AVL tree that searches back up the tree to perform necessary rotations after an insertion causes imbalance.
The document defines common tree terminology and describes trees and binary trees. It discusses tree traversal methods including preorder, inorder, and postorder traversal. It also covers binary search trees, including their representation, properties, and common operations like searching, insertion, deletion, finding the minimum/maximum, and finding predecessors and successors. Key operations on binary search trees like searching, insertion, and deletion run in O(h) time where h is the tree height.
Binary trees and binary search trees are discussed. Binary trees have nodes with at most two children, while binary search trees have the additional property that for every node, all keys in its left subtree are smaller than the node's key and all keys in its right subtree are larger. Common tree operations like searching, insertion, and deletion can be performed in O(log n) time on balanced binary search trees. AVL trees are discussed as one way to balance binary search trees through rotations.
This document discusses trees and binary trees. It covers tree definitions, properties, traversals, and common algorithms. Specifically for binary trees, it discusses their implementation, operations like insertion and deletion, and binary search trees. BSTs allow for efficient search, insertion, and deletion in O(h) time where h is the tree height. Balanced BSTs like red-black trees maintain h as O(log n) to guarantee efficient performance.
This document discusses trees and binary trees. It covers tree definitions, properties, traversals, and common algorithms. Specifically for binary trees, it discusses their implementation, operations like insertion and deletion, and binary search trees. BSTs allow for efficient search, insertion, and deletion in O(h) time where h is the tree height. Balanced BSTs like red-black trees maintain h as O(log n) to guarantee efficient performance.
A binary tree is composed of nodes where each node contains a value and pointers to its left and right children. A binary tree traversal involves systematically visiting each node by traversing either breadth-first or depth-first. Breadth-first traversal visits nodes by level while depth-first traversal can be pre-order, in-order, or post-order depending on when the node is visited. Threaded binary trees reduce the number of null pointers by using them to point to other nodes for more efficient traversals.
The document discusses various tree data structures including binary trees and their terminology. It defines a tree as a set of nodes connected by links/branches where one node is designated as the root. Key terms discussed include child, parent, leaf, root, and level. The document also covers different ways to represent trees using arrays and linked lists and how to traverse trees using preorder, inorder, and postorder traversal algorithms.
Trees are useful for representing hierarchically ordered data like directory structures and family trees. A tree is a collection of nodes connected by branches, with each node having at most one parent. It is defined recursively as a root node with zero or more subtrees. Binary trees restrict nodes to having at most two children. Trees can be traversed in preorder, inorder, or postorder. Binary search trees organize nodes to keep all left descendants less than the parent and all right descendants greater than the parent. Graphs generalize trees by allowing many-to-many relationships between nodes.
This document discusses tree data structures and binary search trees. It begins by defining linear and non-linear data structures, with trees being a non-linear structure. It then defines general tree terminology like root, child, parent, leaves, etc. It describes tree traversal methods like preorder, inorder and postorder. It also discusses binary search trees and basic BST operations like insertion, deletion and searching. Finally, it discusses how BSTs can be used for sorting by inserting elements into a BST and then performing an inorder traversal.
The document defines common tree terminology and describes trees and binary trees. It discusses tree traversal methods including preorder, inorder, and postorder traversal. It also covers binary search trees, including their representation, properties, and common operations like searching, insertion, deletion, finding the minimum/maximum, and finding predecessors and successors. Key operations on binary search trees like searching, insertion, and deletion run in O(h) time where h is the tree height.
Binary trees and binary search trees are discussed. Binary trees have nodes with at most two children, while binary search trees have the additional property that for every node, all keys in its left subtree are smaller than the node's key and all keys in its right subtree are larger. Common tree operations like searching, insertion, and deletion can be performed in O(log n) time on balanced binary search trees. AVL trees are discussed as one way to balance binary search trees through rotations.
This document discusses trees and binary trees. It covers tree definitions, properties, traversals, and common algorithms. Specifically for binary trees, it discusses their implementation, operations like insertion and deletion, and binary search trees. BSTs allow for efficient search, insertion, and deletion in O(h) time where h is the tree height. Balanced BSTs like red-black trees maintain h as O(log n) to guarantee efficient performance.
This document discusses trees and binary trees. It covers tree definitions, properties, traversals, and common algorithms. Specifically for binary trees, it discusses their implementation, operations like insertion and deletion, and binary search trees. BSTs allow for efficient search, insertion, and deletion in O(h) time where h is the tree height. Balanced BSTs like red-black trees maintain h as O(log n) to guarantee efficient performance.
A binary tree is composed of nodes where each node contains a value and pointers to its left and right children. A binary tree traversal involves systematically visiting each node by traversing either breadth-first or depth-first. Breadth-first traversal visits nodes by level while depth-first traversal can be pre-order, in-order, or post-order depending on when the node is visited. Threaded binary trees reduce the number of null pointers by using them to point to other nodes for more efficient traversals.
The document discusses various tree data structures including binary trees and their terminology. It defines a tree as a set of nodes connected by links/branches where one node is designated as the root. Key terms discussed include child, parent, leaf, root, and level. The document also covers different ways to represent trees using arrays and linked lists and how to traverse trees using preorder, inorder, and postorder traversal algorithms.
Trees are useful for representing hierarchically ordered data like directory structures and family trees. A tree is a collection of nodes connected by branches, with each node having at most one parent. It is defined recursively as a root node with zero or more subtrees. Binary trees restrict nodes to having at most two children. Trees can be traversed in preorder, inorder, or postorder. Binary search trees organize nodes to keep all left descendants less than the parent and all right descendants greater than the parent. Graphs generalize trees by allowing many-to-many relationships between nodes.
This document discusses tree data structures and binary search trees. It begins by defining linear and non-linear data structures, with trees being a non-linear structure. It then defines general tree terminology like root, child, parent, leaves, etc. It describes tree traversal methods like preorder, inorder and postorder. It also discusses binary search trees and basic BST operations like insertion, deletion and searching. Finally, it discusses how BSTs can be used for sorting by inserting elements into a BST and then performing an inorder traversal.
Binary search trees have the following key properties:
1. Each node contains a value.
2. The left subtree of a node contains only values smaller than the node's value.
3. The right subtree of a node contains only values larger than the node's value.
Binary search trees allow for efficient insertion and search operations in O(log n) time due to their structure. Deletion may require rebalancing the tree to maintain the binary search tree properties.
Binary search trees have the property that all values in the left subtree of a node are smaller than the node's value and all values in the right subtree are larger. They allow for efficient search, insertion, and deletion operations that take O(log n) time on average for a balanced tree with n nodes. However, standard binary search trees may become unbalanced over time, affecting performance. Various self-balancing binary search tree data structures, such as AVL trees and red-black trees, use tree rotations during insertions and deletions to maintain height balance.
Common Use of Tree as a Data Structure
ADVANCE
1. Nodes
2. Parent Nodes & Child Nodes
3. Leaf Nodes
4. Root Node
5. Sub Tree
6. Level of a tree:
7. m-ary Tree
8. Binary Tree (BT)
9. Complete and Full Binary Tree
10. Traversal
11. Binary Search Tree (BST)
12. Inorder Traversal – Left_ParentNode_Right
13. Postorder Traversal – Left_Right_ParentNode
14. Preorder Traversal – ParentNode_Left_Right
15. Binary Search Tree (BST)
16. BST - Insert, Delete
Common Use of Tree as a Data Structure
INTERMEDIATE
1. Nodes
2. Parent Nodes & Child Nodes
3. Leaf Nodes
4. Root Node
5. Sub Tree
6. Level of a tree:
7. m-ary Tree
8. Binary Tree (BT)
9. Complete and Full Binary Tree
10. Traversal
11. Binary Search Tree (BST)
12. BST - Insert, Delete
This document discusses trees and binary trees. It defines key terminology like root, leaf nodes, internal nodes, and provides examples of different types of binary trees including full, complete, balanced, and binary search trees. It also covers different representations of binary trees using arrays and linked lists as well as common traversal techniques for binary trees like preorder, inorder and postorder traversal.
In computer science, tree traversal (also known as tree search) is a form of graph traversal and refers to the process of visiting (checking and/or updating) each node in a tree data structure, exactly once. Such traversals are classified by the order in which the nodes are visited. The following algorithms are described for a binary tree, but they may be generalized to other trees as well.
BST+ RedBlackTrees CNN stands for Convolutional Neural Network.pptxssuser7b7f4e
It's a type of deep learning algorithm commonly used for image recognition and classification tasks. It's inspired by the human visual system and consists of multiple layers of neurons that perform convolutions, pooling, and activation functions to extract features from input images. CNNs have revolutionized fields like computer vision, achieving state-of-the-art performance in tasks such as object detection, image segmentation, and facial recognition.
The document discusses binary trees and binary search trees. It defines key terms like root, child, parent, leaves, height, depth. It explains tree traversal methods like preorder, inorder and postorder. It then describes binary search trees and how they store keys in a way that searching, insertion and deletion can be done efficiently in O(log n) time. It discusses implementation of operations like search, insert, delete on BSTs. It introduces balanced binary search trees like AVL trees that ensure height is O(log n) through rotations during insertions and deletions.
The document discusses algorithms and data structures, focusing on binary search trees (BSTs). It provides the following key points:
- BSTs are an important data structure for dynamic sets that can perform operations like search, insert, and delete in O(h) time where h is the height of the tree.
- Each node in a BST contains a key, and pointers to its left/right children and parent. The keys must satisfy the BST property - all keys in the left subtree are less than the node's key, and all keys in the right subtree are greater.
- Rotations are a basic operation used to restructure trees during insertions/deletions. They involve reassigning child
This document discusses binary search trees. It begins by explaining what trees and binary trees are. It then describes key properties of binary search trees like their height and how every node's key is greater than all keys in its left subtree and less than keys in its right subtree. The document outlines common binary search tree operations like searching, insertion, deletion and traversal. It explains how each operation takes O(height of the tree) time since they involve traversing down a path in the tree from the root.
lecture10 date structure types of graph and terminologyKamranAli649587
The document discusses tree traversal techniques and heaps. It begins by explaining tree traversal concepts and the three common traversal techniques: preorder, inorder, and postorder. It then discusses heaps, which are almost complete binary trees where the key of each node is less than or equal to its children's keys. Heaps support efficient insertion and deletion of minimum elements in logarithmic time and are used to implement priority queues. Code implementations of binary trees, tree traversals, heaps, and their operations like insertion and deletion are also provided.
This document provides information about different tree data structures including binary trees, binary search trees, AVL trees, red-black trees, splay trees, and B-trees. Binary search trees allow for fast searching and maintain an ordered structure. AVL and red-black trees are self-balancing binary search trees that ensure fast search, insert, and delete times by keeping the tree balanced. B-trees are multiway search trees that allow for efficient storage and retrieval of data in databases and file systems.
The document provides an overview of B-trees, which are data structures designed for databases stored on disk. B-trees minimize disk I/O operations by storing data in large pages that can be read from disk in bulk. The key operations of search, insertion, and deletion in B-trees require O(log n) disk accesses on average by balancing the tree structure and merging or splitting nodes as needed to keep them between t-1 and 2t-1 keys in size.
This document discusses binary search trees and red-black trees. It begins by defining binary search trees and describing their basic operations like search, insertion, and deletion which take time proportional to the height of the tree. It then introduces red-black trees, which add color attributes to nodes in a binary search tree to ensure the tree remains balanced, allowing operations to take O(log n) time. The properties of red-black trees are described, including that they guarantee all paths from a node to leaves contain the same number of black nodes.
Introduction to data structure by anil duttAnil Dutt
This document provides an introduction and overview of common data structures including linked lists, stacks, queues, trees, and graphs. It defines each structure and describes their basic operations and implementations. Linked lists allow insertions and deletions anywhere and come in singly and doubly linked varieties. Stacks and queues follow last-in, first-out and first-in, first-out rules respectively. Binary trees enable fast searching and sorting of data. Graphs represent relationships between nodes connected by edges.
mitochondria moment and super computer integration.pptAMMAD45
The document discusses binary search trees, which are binary trees that store keys in nodes such that all keys in the left subtree of a node are less than the node's key and all keys in the right subtree are greater. This property allows searching, insertion, and deletion operations to be performed efficiently in O(log N) time on average. The document covers tree terminology, traversal methods, and implementations of searching, inserting, deleting, finding the minimum/maximum keys, and maintaining the binary search tree properties during operations.
The document discusses red-black trees, which are binary search trees augmented with node colors to guarantee a height of O(log n). It reviews the properties of red-black trees, including that every node is red or black, leaves are black, red nodes have black children, and all paths from root to leaf contain the same number of black nodes. It then proves that these properties ensure a height of O(log n) and thus search, minimum, maximum, successor and predecessor operations take O(log n) time. Insert and delete operations also take O(log n) time but require special handling to maintain the red-black tree properties during modification.
The document discusses different types of tree data structures, including general trees, binary trees, binary search trees, and their traversal methods. General trees allow nodes to have any number of children, while binary trees restrict nodes to having 0, 1, or 2 children. Binary search trees organize nodes so that all left descendants are less than the parent and all right descendants are greater. Common traversal orders for trees include preorder, inorder, and postorder, which differ in whether they process the root node before or after visiting child nodes.
The document discusses binary tree traversal methods. It defines key binary tree terminology like nodes, edges, root, and provides examples of different types of binary trees like strictly binary, complete, and almost complete binary trees. It also explains the three common traversal techniques for binary search trees - in-order, pre-order and post-order traversals - and provides pseudocode algorithms and examples for each traversal method.
Short overview of balance tree: Data Structures, Binary search tree, BST Problem, Self Balancing BST, Usage, Red Black Trees, Red Black Insertion, AVL Tree, Rotations, B-Tree
Presented by The Global Peatlands Assessment: Mapping, Policy, and Action at GLF Peatlands 2024 - The Global Peatlands Assessment: Mapping, Policy, and Action
Binary search trees have the following key properties:
1. Each node contains a value.
2. The left subtree of a node contains only values smaller than the node's value.
3. The right subtree of a node contains only values larger than the node's value.
Binary search trees allow for efficient insertion and search operations in O(log n) time due to their structure. Deletion may require rebalancing the tree to maintain the binary search tree properties.
Binary search trees have the property that all values in the left subtree of a node are smaller than the node's value and all values in the right subtree are larger. They allow for efficient search, insertion, and deletion operations that take O(log n) time on average for a balanced tree with n nodes. However, standard binary search trees may become unbalanced over time, affecting performance. Various self-balancing binary search tree data structures, such as AVL trees and red-black trees, use tree rotations during insertions and deletions to maintain height balance.
Common Use of Tree as a Data Structure
ADVANCE
1. Nodes
2. Parent Nodes & Child Nodes
3. Leaf Nodes
4. Root Node
5. Sub Tree
6. Level of a tree:
7. m-ary Tree
8. Binary Tree (BT)
9. Complete and Full Binary Tree
10. Traversal
11. Binary Search Tree (BST)
12. Inorder Traversal – Left_ParentNode_Right
13. Postorder Traversal – Left_Right_ParentNode
14. Preorder Traversal – ParentNode_Left_Right
15. Binary Search Tree (BST)
16. BST - Insert, Delete
Common Use of Tree as a Data Structure
INTERMEDIATE
1. Nodes
2. Parent Nodes & Child Nodes
3. Leaf Nodes
4. Root Node
5. Sub Tree
6. Level of a tree:
7. m-ary Tree
8. Binary Tree (BT)
9. Complete and Full Binary Tree
10. Traversal
11. Binary Search Tree (BST)
12. BST - Insert, Delete
This document discusses trees and binary trees. It defines key terminology like root, leaf nodes, internal nodes, and provides examples of different types of binary trees including full, complete, balanced, and binary search trees. It also covers different representations of binary trees using arrays and linked lists as well as common traversal techniques for binary trees like preorder, inorder and postorder traversal.
In computer science, tree traversal (also known as tree search) is a form of graph traversal and refers to the process of visiting (checking and/or updating) each node in a tree data structure, exactly once. Such traversals are classified by the order in which the nodes are visited. The following algorithms are described for a binary tree, but they may be generalized to other trees as well.
BST+ RedBlackTrees CNN stands for Convolutional Neural Network.pptxssuser7b7f4e
It's a type of deep learning algorithm commonly used for image recognition and classification tasks. It's inspired by the human visual system and consists of multiple layers of neurons that perform convolutions, pooling, and activation functions to extract features from input images. CNNs have revolutionized fields like computer vision, achieving state-of-the-art performance in tasks such as object detection, image segmentation, and facial recognition.
The document discusses binary trees and binary search trees. It defines key terms like root, child, parent, leaves, height, depth. It explains tree traversal methods like preorder, inorder and postorder. It then describes binary search trees and how they store keys in a way that searching, insertion and deletion can be done efficiently in O(log n) time. It discusses implementation of operations like search, insert, delete on BSTs. It introduces balanced binary search trees like AVL trees that ensure height is O(log n) through rotations during insertions and deletions.
The document discusses algorithms and data structures, focusing on binary search trees (BSTs). It provides the following key points:
- BSTs are an important data structure for dynamic sets that can perform operations like search, insert, and delete in O(h) time where h is the height of the tree.
- Each node in a BST contains a key, and pointers to its left/right children and parent. The keys must satisfy the BST property - all keys in the left subtree are less than the node's key, and all keys in the right subtree are greater.
- Rotations are a basic operation used to restructure trees during insertions/deletions. They involve reassigning child
This document discusses binary search trees. It begins by explaining what trees and binary trees are. It then describes key properties of binary search trees like their height and how every node's key is greater than all keys in its left subtree and less than keys in its right subtree. The document outlines common binary search tree operations like searching, insertion, deletion and traversal. It explains how each operation takes O(height of the tree) time since they involve traversing down a path in the tree from the root.
lecture10 date structure types of graph and terminologyKamranAli649587
The document discusses tree traversal techniques and heaps. It begins by explaining tree traversal concepts and the three common traversal techniques: preorder, inorder, and postorder. It then discusses heaps, which are almost complete binary trees where the key of each node is less than or equal to its children's keys. Heaps support efficient insertion and deletion of minimum elements in logarithmic time and are used to implement priority queues. Code implementations of binary trees, tree traversals, heaps, and their operations like insertion and deletion are also provided.
This document provides information about different tree data structures including binary trees, binary search trees, AVL trees, red-black trees, splay trees, and B-trees. Binary search trees allow for fast searching and maintain an ordered structure. AVL and red-black trees are self-balancing binary search trees that ensure fast search, insert, and delete times by keeping the tree balanced. B-trees are multiway search trees that allow for efficient storage and retrieval of data in databases and file systems.
The document provides an overview of B-trees, which are data structures designed for databases stored on disk. B-trees minimize disk I/O operations by storing data in large pages that can be read from disk in bulk. The key operations of search, insertion, and deletion in B-trees require O(log n) disk accesses on average by balancing the tree structure and merging or splitting nodes as needed to keep them between t-1 and 2t-1 keys in size.
This document discusses binary search trees and red-black trees. It begins by defining binary search trees and describing their basic operations like search, insertion, and deletion which take time proportional to the height of the tree. It then introduces red-black trees, which add color attributes to nodes in a binary search tree to ensure the tree remains balanced, allowing operations to take O(log n) time. The properties of red-black trees are described, including that they guarantee all paths from a node to leaves contain the same number of black nodes.
Introduction to data structure by anil duttAnil Dutt
This document provides an introduction and overview of common data structures including linked lists, stacks, queues, trees, and graphs. It defines each structure and describes their basic operations and implementations. Linked lists allow insertions and deletions anywhere and come in singly and doubly linked varieties. Stacks and queues follow last-in, first-out and first-in, first-out rules respectively. Binary trees enable fast searching and sorting of data. Graphs represent relationships between nodes connected by edges.
mitochondria moment and super computer integration.pptAMMAD45
The document discusses binary search trees, which are binary trees that store keys in nodes such that all keys in the left subtree of a node are less than the node's key and all keys in the right subtree are greater. This property allows searching, insertion, and deletion operations to be performed efficiently in O(log N) time on average. The document covers tree terminology, traversal methods, and implementations of searching, inserting, deleting, finding the minimum/maximum keys, and maintaining the binary search tree properties during operations.
The document discusses red-black trees, which are binary search trees augmented with node colors to guarantee a height of O(log n). It reviews the properties of red-black trees, including that every node is red or black, leaves are black, red nodes have black children, and all paths from root to leaf contain the same number of black nodes. It then proves that these properties ensure a height of O(log n) and thus search, minimum, maximum, successor and predecessor operations take O(log n) time. Insert and delete operations also take O(log n) time but require special handling to maintain the red-black tree properties during modification.
The document discusses different types of tree data structures, including general trees, binary trees, binary search trees, and their traversal methods. General trees allow nodes to have any number of children, while binary trees restrict nodes to having 0, 1, or 2 children. Binary search trees organize nodes so that all left descendants are less than the parent and all right descendants are greater. Common traversal orders for trees include preorder, inorder, and postorder, which differ in whether they process the root node before or after visiting child nodes.
The document discusses binary tree traversal methods. It defines key binary tree terminology like nodes, edges, root, and provides examples of different types of binary trees like strictly binary, complete, and almost complete binary trees. It also explains the three common traversal techniques for binary search trees - in-order, pre-order and post-order traversals - and provides pseudocode algorithms and examples for each traversal method.
Short overview of balance tree: Data Structures, Binary search tree, BST Problem, Self Balancing BST, Usage, Red Black Trees, Red Black Insertion, AVL Tree, Rotations, B-Tree
Presented by The Global Peatlands Assessment: Mapping, Policy, and Action at GLF Peatlands 2024 - The Global Peatlands Assessment: Mapping, Policy, and Action
Improving the viability of probiotics by encapsulation methods for developmen...Open Access Research Paper
The popularity of functional foods among scientists and common people has been increasing day by day. Awareness and modernization make the consumer think better regarding food and nutrition. Now a day’s individual knows very well about the relation between food consumption and disease prevalence. Humans have a diversity of microbes in the gut that together form the gut microflora. Probiotics are the health-promoting live microbial cells improve host health through gut and brain connection and fighting against harmful bacteria. Bifidobacterium and Lactobacillus are the two bacterial genera which are considered to be probiotic. These good bacteria are facing challenges of viability. There are so many factors such as sensitivity to heat, pH, acidity, osmotic effect, mechanical shear, chemical components, freezing and storage time as well which affects the viability of probiotics in the dairy food matrix as well as in the gut. Multiple efforts have been done in the past and ongoing in present for these beneficial microbial population stability until their destination in the gut. One of a useful technique known as microencapsulation makes the probiotic effective in the diversified conditions and maintain these microbe’s community to the optimum level for achieving targeted benefits. Dairy products are found to be an ideal vehicle for probiotic incorporation. It has been seen that the encapsulated microbial cells show higher viability than the free cells in different processing and storage conditions as well as against bile salts in the gut. They make the food functional when incorporated, without affecting the product sensory characteristics.
Evolving Lifecycles with High Resolution Site Characterization (HRSC) and 3-D...Joshua Orris
The incorporation of a 3DCSM and completion of HRSC provided a tool for enhanced, data-driven, decisions to support a change in remediation closure strategies. Currently, an approved pilot study has been obtained to shut-down the remediation systems (ISCO, P&T) and conduct a hydraulic study under non-pumping conditions. A separate micro-biological bench scale treatability study was competed that yielded positive results for an emerging innovative technology. As a result, a field pilot study has commenced with results expected in nine-twelve months. With the results of the hydraulic study, field pilot studies and an updated risk assessment leading site monitoring optimization cost lifecycle savings upwards of $15MM towards an alternatively evolved best available technology remediation closure strategy.
Epcon is One of the World's leading Manufacturing Companies.EpconLP
Epcon is One of the World's leading Manufacturing Companies. With over 4000 installations worldwide, EPCON has been pioneering new techniques since 1977 that have become industry standards now. Founded in 1977, Epcon has grown from a one-man operation to a global leader in developing and manufacturing innovative air pollution control technology and industrial heating equipment.
RoHS stands for Restriction of Hazardous Substances, which is also known as t...vijaykumar292010
RoHS stands for Restriction of Hazardous Substances, which is also known as the Directive 2002/95/EC. It includes the restrictions for the use of certain hazardous substances in electrical and electronic equipment. RoHS is a WEEE (Waste of Electrical and Electronic Equipment).
Microbial characterisation and identification, and potability of River Kuywa ...Open Access Research Paper
Water contamination is one of the major causes of water borne diseases worldwide. In Kenya, approximately 43% of people lack access to potable water due to human contamination. River Kuywa water is currently experiencing contamination due to human activities. Its water is widely used for domestic, agricultural, industrial and recreational purposes. This study aimed at characterizing bacteria and fungi in river Kuywa water. Water samples were randomly collected from four sites of the river: site A (Matisi), site B (Ngwelo), site C (Nzoia water pump) and site D (Chalicha), during the dry season (January-March 2018) and wet season (April-July 2018) and were transported to Maseno University Microbiology and plant pathology laboratory for analysis. The characterization and identification of bacteria and fungi were carried out using standard microbiological techniques. Nine bacterial genera and three fungi were identified from Kuywa river water. Clostridium spp., Staphylococcus spp., Enterobacter spp., Streptococcus spp., E. coli, Klebsiella spp., Shigella spp., Proteus spp. and Salmonella spp. Fungi were Fusarium oxysporum, Aspergillus flavus complex and Penicillium species. Wet season recorded highest bacterial and fungal counts (6.61-7.66 and 3.83-6.75cfu/ml) respectively. The results indicated that the river Kuywa water is polluted and therefore unsafe for human consumption before treatment. It is therefore recommended that the communities to ensure that they boil water especially for drinking.
Optimizing Post Remediation Groundwater Performance with Enhanced Microbiolog...Joshua Orris
Results of geophysics and pneumatic injection pilot tests during 2003 – 2007 yielded significant positive results for injection delivery design and contaminant mass treatment, resulting in permanent shut-down of an existing groundwater Pump & Treat system.
Accessible source areas were subsequently removed (2011) by soil excavation and treated with the placement of Emulsified Vegetable Oil EVO and zero-valent iron ZVI to accelerate treatment of impacted groundwater in overburden and weathered fractured bedrock. Post pilot test and post remediation groundwater monitoring has included analyses of CVOCs, organic fatty acids, dissolved gases and QuantArray® -Chlor to quantify key microorganisms (e.g., Dehalococcoides, Dehalobacter, etc.) and functional genes (e.g., vinyl chloride reductase, methane monooxygenase, etc.) to assess potential for reductive dechlorination and aerobic cometabolism of CVOCs.
In 2022, the first commercial application of MetaArray™ was performed at the site. MetaArray™ utilizes statistical analysis, such as principal component analysis and multivariate analysis to provide evidence that reductive dechlorination is active or even that it is slowing. This creates actionable data allowing users to save money by making important site management decisions earlier.
The results of the MetaArray™ analysis’ support vector machine (SVM) identified groundwater monitoring wells with a 80% confidence that were characterized as either Limited for Reductive Decholorination or had a High Reductive Reduction Dechlorination potential. The results of MetaArray™ will be used to further optimize the site’s post remediation monitoring program for monitored natural attenuation.
4. 4
Tree Jargon
• Length of a path =
number of edges
• Depth of a node N =
length of path from
root to N
• Height of node N =
length of longest
path from N to a leaf
• Depth and height of
tree = height of root
A
B C D
E F
depth=0, height = 2
depth = 2, height=0
5. 5
Definition and Tree Trivia
Recursive Definition of a Tree:
A tree is a set of nodes that is
a. an empty set of nodes, or
b. has one node called the root from which
zero or more trees (subtrees) descend.
• A tree with N nodes always has ___ edges
• Two nodes in a tree have at most how many
paths between them?
6. 6
Implementation of Trees
• Obvious Pointer-Based Implementation: Node with
value and pointers to children
– Problem?
A
B C D
E F
10. 10
Example Arithmetic Expression:
A + (B * (C / D) )
Tree for the above expression:
Application: Arithmetic
Expression Trees
+
A *
B /
C D
• Used in most compilers
• No parenthesis need – use tree structure
• Can speed up calculations e.g. replace
/ node with C/D if C and D are known
• Calculate by traversing tree (how?)
11. 11
Traversing Trees
• Preorder: Root, then Children
– + A * B / C D
• Postorder: Children, then Root
– A B C D / * +
• Inorder: Left child, Root, Right child
– A + B * C / D
+
A *
B /
C D
12. 12
void print_preorder ( TreeNode T)
{
TreeNode P;
if ( T == NULL ) return;
else { print_element(T.Element);
P = T.FirstChild;
while (P != NULL) {
print_preorder ( P );
P = P.NextSibling; }
}
}
Example Code for Recursive
Preorder
What is the running time for a tree with N nodes?
13. 13
Binary Trees
• Properties
Notation:
depth(tree) = MAX {depth(leaf)} = height(root)
– max # of leaves = 2depth(tree)
– max # of nodes = 2depth(tree)+1 – 1
– max depth = n-1
– average depth for n nodes =
(over all possible binary trees)
• Representation:
A
B
D E
C
F
H
G
J
I
Data
right
pointer
left
pointer
n
14. 14
Dictionary & Search ADTs
• Operations
– create
– destroy
– insert
– find
– delete
• Dictionary: Stores values associated with user-
specified keys
– keys may be any (homogenous) comparable type
– values may be any (homogenous) type
– implementation: data field is a struct with two parts
• Search ADT: keys = values
• kim chi
– spicy cabbage
• kreplach
– tasty stuffed dough
• kiwi
– Australian fruit
insert
find(kreplach)
•kohlrabi
- upscale tuber
• kreplach
- tasty stuffed dough
17. 17
Binary Search Tree
Dictionary Data Structure
4
12
10
6
2
11
5
8
14
13
7 9
• Search tree property
– all keys in left subtree
smaller than root’s key
– all keys in right subtree
larger than root’s key
– result:
• easy to find any given
key
• inserts/deletes by
changing links
18. 18
In Order Listing
visit left subtree
visit node
visit right subtree
20
9
2
15
5
10
30
7 17
In order listing:
19. 19
In Order Listing
visit left subtree
visit node
visit right subtree
20
9
2
15
5
10
30
7 17
In order listing:
25791015172030
21. 21
Insert
Concept: proceed down tree as in Find; if new key not found,
then insert a new node at last spot traversed
void insert(Comparable x, Node root) {
// Does not work for empty tree – when root is
NULL
if (x < root.key){
if (root.left == NULL)
root.left = new Node(x);
else insert( x, root.left ); }
else if (x > root.key){
if (root.right == NULL)
root.right = new Node(x);
else insert( x, root.right ); } }
22. 22
Time to Build a Tree
Suppose a1, a2, …, an are inserted into an initially empty BST:
1. a1, a2, …, an are in increasing order
2. a1, a2, …, an are in decreasing order
3. a1 is the median of all, a2 is the median of elements
less than a1, a3 is the median of elements greater than
a1, etc.
4. data is randomly ordered
23. 23
Analysis of BuildTree
• Increasing / Decreasing: (n2)
1 + 2 + 3 + … + n = (n2)
• Medians – yields perfectly balanced tree
(n log n)
• Average case assuming all input sequences
are equally likely is (n log n)
– equivalently: average depth of a node is log n
Total time = sum of depths of nodes
24. 24
Proof that Average Depth of a Node in a BST
Constructed from Random Data is (log n)
Method: Calculate sum of all depths, divide by number
of nodes
• D(n) = sum of depths of all nodes in a random BST
containing n nodes
• D(n) = D(left subtree)+D(right subtree)
+ adjustment for distance from root to subtree
+ depth of root
• D(n) = D(left subtree)+D(right subtree)
+ (number of nodes in left and right subtrees)
+ 0
• D(n) = D(L)+D(n-L-1)+(n-1)
25. 25
Random BST, cont.
• D(n) = D(L)+D(n-L-1)+(n-1)
• For random data, all subtree sizes equally likely
1
0
1
0
1
0
[ ( )] [ ( ) when left tree size is L]
[ ( )] [ ( )] [ ( 1)] ( 1)
2
[ ( )] [ ( )] ( 1)
[ (
Prob(left tree size is L)
1
[ ( ) / ] (lo
)] ( log
g )
)
n
L
n
L
n
L
E D n E D n
n
E D n n
E D n E D L E D n L n
E D n E D L n
n
E D n O n n
O n
this looks just like the
Quicksort average case
equation!
26. 26
log
versus
n n
Why is average depth of BST's made from
random inputs different from the average
depth of all pos
log
Because there are more ways to build shallow
trees than d
sible
eep t
BST
ee
?
r
's
n n
s!
27. 27
Random Input vs. Random Trees
Inputs
1,2,3
3,2,1
1,3,2
3,1,2
2,1,3
2,3,1
Trees
For three items, the
shallowest tree is
twice as likely as
any other – effect
grows as n
increases. For n=4,
probability of
getting a shallow
tree > 50%
29. 29
FindMin/FindMax
Node min(Node root) {
if (root.left == NULL)
return root;
else
return min(root.left);
}
20
9
2
15
5
10
30
7 17
How many children can the min of a node have?
30. 30
Successor
Find the next larger node
in this node’s subtree.
– not next larger in entire
tree
Node succ(Node root) {
if (root.right == NULL)
return NULL;
else
return
min(root.right);
}
20
9
2
15
5
10
30
7 17
How many children can the successor of a node have?
33. 33
Deletion - Two Child Case
30
9
2
20
5
10
7
Delete(5)
replace node with value guaranteed to be between the left and
right subtrees: the successor
Could we have used the predecessor instead?
34. 34
Deletion - Two Child Case
30
9
2
20
5
10
7
Delete(5)
always easy to delete the successor – always has either 0 or 1
children!
35. 35
Deletion - Two Child Case
30
9
2
20
7
10
7
Delete(5)
Finally copy data value from deleted successor into original
node
36. 36
Lazy Deletion
• Instead of physically deleting
nodes, just mark them as
deleted
+ simpler
+ physical deletions done in batches
+ some adds just flip deleted flag
– extra memory for deleted flag
– many lazy deletions slow finds
– some operations may have to be
modified (e.g., min and max)
20
9
2
15
5
10
30
7 17
37. 37
Dictionary Implementations
BST’s looking good for shallow trees, i.e. the depth D is
small (log n), otherwise as bad as a linked list!
unsorted
array
sorted
array
linked
list
BST
insert find +
O(1)
O(n) find +
O(1)
O(Depth)
find O(n) O(log n) O(n) O(Depth)
delete find +
O(1)
O(n) find +
O(1)
O(Depth)
38. 38
CSE 326: Data Structures
Part 3: Trees, continued
Balancing Act
Henry Kautz
Autumn Quarter 2002
39. 39
Beauty is Only (log n) Deep
• Binary Search Trees are fast if they’re shallow
e.g.: complete
• Problems occur when one branch is much
longer than the other
How to capture the notion of a “sort of” complete
tree?
40. 40
Balance
balance = height(left subtree) - height(right subtree)
• convention: height of a “null” subtree is -1
• zero everywhere perfectly balanced
• small everywhere balanced enough: (log n)
– Precisely: Maximum depth is 1.44 log n
t
5
6
41. 41
AVL Tree
Dictionary Data Structure
4
12
10
6
2
11
5
8
14
13
7 9
• Binary search tree
properties
• Balance of every node is
-1 b 1
• Tree re-balances itself
after every insert or
delete
15
What is the balance of each node in this tree?
42. 42
AVL Tree Data Structure
15
9
2 12
5
10
20
17
0
0
1
0
0
1 2
3 10
3
data
height
children
30
0
43. 43
Not An AVL Tree
15
9
2 12
5
10
20
17
0
1
2
0
0
1 3
4 10
4
data
height
children
30
0
18
0
46. 46
General Case: Insert Unbalances
a
X
Y
b
Z
h h - 1
h + 1 h - 1
h + 2
a
X
Y
b
Z
h-1 h - 1
h h - 1
h + 1
a
X
Y
b
Z
h
h - 1
h
h - 1
h + 1
47. 47
Properties of General Insert +
Single Rotation
• Restores balance to a lowest point in tree
where imbalance occurs
• After rotation, height of the subtree (in the
example, h+1) is the same as it was before
the insert that imbalanced it
• Thus, no further rotations are needed
anywhere in the tree!
50. 50
General Double Rotation
• Initially: insert into X unbalances tree (root height goes to h+3)
• “Zig zag” to pull up c – restores root height to h+2, left subtree
height to h
a
Z
b
W
c
Y
a
Z
b
W
c
Y
h+1
h
h
h
h + 3
h + 2
h
h
h+1
h + 2
h+1
h
X
X
51. 51
Another Double Rotation Case
• Initially: insert into Y unbalances tree (root height goes to h+2)
• “Zig zag” to pull up c – restores root height to h+1, left subtree
height to h
a
Z
b
W
c
Y
a
Z
b
W
c
Y
h+1
h
h
h
h + 3
h + 2
h
h
h+1
h + 2
h+1
h
X
X
52. 52
Insert Algorithm
• Find spot for value
• Hang new node
• Search back up looking for imbalance
• If there is an imbalance:
“outside”: Perform single rotation and exit
“inside”: Perform double rotation and exit
53. 53
AVL Insert Algorithm
Node insert(Comparable x, Node root){
// returns root of revised tree
if ( root == NULL )
return new Node(x);
if (x <= root.key){
root.left = insert( x, root.left );
if (root unbalanced) { rotate... } }
else { // x > root.key
root.right = insert( x, root.right );
if (root unbalanced) { rotate... } }
root.height = max(root.left.height,
root.right.height)+1;
return root;
}
61. 61
Deletion with Propagation
We get to choose whether
to single or double rotate!
20
5
2
17
3
10
30
12
0 2
2
0
1 3
4
33
15
13
1
0 0
1
11
0
18
0
What different
about this case?
64. 64
AVL Deletion Algorithm
• Recursive
1. If at node, delete it
2. Otherwise recurse to
find it in
3. Correct heights
a. If imbalance #1,
single rotate
b. If imbalance #2
(or don’t care),
double rotate
• Iterative
1. Search downward for
node, stacking
parent nodes
2. Delete node
3. Unwind stack,
correcting heights
a. If imbalance #1,
single rotate
b. If imbalance #2
(or don’t care)
double rotate
65. 65
AVL
• Automatically Virtually Leveled
• Architecture for inVisible Leveling
• Articulating Various Lines
• Amortizing? Very Lousy!
• Amazingly Vexing Letters
66. 66
AVL
• Automatically Virtually Leveled
• Architecture for inVisible Leveling
• Articulating Various Lines
• Amortizing? Very Lousy!
• Amazingly Vexing Letters
Adelson-Velskii Landis
67. 67
Pro:
• All operations guaranteed O(log N)
• The height balancing adds no more than a
constant factor to the speed of insertion
Con:
• Space consumed by height field in each node
• Slower than ordinary BST on random data
Can we guarantee O(log N) performance with less
overhead?
Pros and Cons of AVL Trees
69. 69
Today: Splay Trees
• Fast both in worst-case amortized analysis
and in practice
• Are used in the kernel of NT for keep track of
process information!
• Invented by Sleator and Tarjan (1985)
• Details:
• Weiss 4.5 (basic splay trees)
• 11.5 (amortized analysis)
• 12.1 (better “top down” implementation)
70. 70
Basic Idea
“Blind” rebalancing – no height info kept!
• Worst-case time per operation is O(n)
• Worst-case amortized time is O(log n)
• Insert/find always rotates node to the root!
• Good locality:
– Most commonly accessed keys move high in
tree – become easier and easier to find
71. 71
Idea
17
10
9
2
5
3
You’re forced to make
a really deep access:
Since you’re down there anyway,
fix up a lot of deep nodes!
move n to root by
series of zig-zag
and zig-zig
rotations, followed
by a final single
rotation (zig) if
necessary
74. 74
Why Splaying Helps
• Node n and its children are always helped (raised)
• Except for last step, nodes that are hurt by a zig-
zag or zig-zig are later helped by a rotation higher
up the tree!
• Result:
– shallow nodes may increase depth by one or two
– helped nodes decrease depth by a large amount
• If a node n on the access path is at depth d before
the splay, it’s at about depth d/2 after the splay
– Exceptions are the root, the child of the root, and the
node splayed
80. 80
Locality
• “Locality” – if an item is accessed, it is likely to
be accessed again soon
– Why?
• Assume m n access in a tree of size n
– Total worst case time is O(m log n)
– O(log n) per access amortized time
• Suppose only k distinct items are accessed in the
m accesses.
– Time is O(n log n + m log k )
– Compare with O( m log n ) for AVL tree
getting those k items
near root
those k items are all at
the top of the tree
81. 81
Splay Operations: Insert
• To insert, could do an ordinary BST insert
– but would not fix up tree
– A BST insert followed by a find (splay)?
• Better idea: do the splay before the insert!
• How?
82. 82
Split
Split(T, x) creates two BST’s L and R:
– All elements of T are in either L or R
– All elements in L are x
– All elements in R are x
– L and R share no elements
Then how do we do the insert?
83. 83
Split
Split(T, x) creates two BST’s L and R:
– All elements of T are in either L or R
– All elements in L are x
– All elements in R are > x
– L and R share no elements
Then how do we do the insert?
Insert as root, with children L and R
84. 84
Splitting in Splay Trees
• How can we split?
– We have the splay operation
– We can find x or the parent of where x would
be if we were to insert it as an ordinary BST
– We can splay x or the parent to the root
– Then break one of the links from the root to a
child
85. 85
Split
split(x)
T L R
splay
OR
L R L R
x > x
> x < x
could be x, or
what would
have been the
parent of x
if root is x
if root is > x
92. 92
Splay Trees, Summary
• Splay trees are arguably the most practical
kind of self-balancing trees
• If number of finds is much larger than n,
then locality is crucial!
– Example: word-counting
• Also supports efficient Split and Join
operations – useful for other tasks
– E.g., range queries