The document discusses trees and binary trees. It defines key tree terminology like nodes, edges, root, leaf, etc. It explains properties of binary trees including full, complete, and binary search trees. It describes techniques for traversing binary trees including preorder, inorder and postorder traversal using recursion and stacks. Searching and insertion operations in binary search trees are also summarized.
- A binary search tree (BST) is a binary tree where all left descendants of a node are less than or equal to the node's value, and all right descendants are greater than or equal.
- Searching, insertion, and deletion in a BST follow the structure of the tree - searching compares the target value to the current node to determine which subtree to search, insertion adds new nodes by comparing to parent nodes, and deletion removes nodes and restructures the tree as needed.
- Common operations like searching, insertion, and deletion are accomplished by traversing the tree from the root node down, making comparisons at each level to determine the path through left or right subtrees.
1) Tree
2) General Tree
3) Binary Tree
4) Full Binay Tree, Complete Binay Tree
5) Binary Tree Traversal (DFS & BFS)
6) Binary Search Tree
7) Reconstruction of Binay Tree
8) Expression Tree
9) Evaluation of postfix expression
10) Infix to Prefix using stack
11) Infix to Postfix using stack
12) Threaded Binary Tree
13) AVL-Tree
14) AVL-Tree Rotation
The document discusses binary search trees (BSTs). It defines a BST as a binary tree where the value of each node is greater than all values in its left subtree and less than all values in its right subtree. It provides examples of BSTs and non-BSTs. Searching, inserting, and deleting operations on a BST have O(log n) time complexity on a balanced tree but can be O(n) on a degenerate tree. Insertion and deletion can cause imbalance in the tree over time.
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.
- The document discusses binary search trees, including their properties, how to search for a key, and how to insert a new key.
- A binary search tree is a binary tree where the key in each node is greater than all keys in the left subtree and less than those in the right subtree. This property allows searching, insertion, and deletion in logarithmic time.
- To search for a key, the algorithm recursively compares the search key to the node keys, traversing left or right. To insert a new key, it is added as a new child node in the appropriate sorted position.
The document discusses binary search trees and their operations. It defines key concepts like nodes, leaves, root, and tree traversal methods. It then explains how to search, insert, find minimum/maximum elements, and traverse a binary search tree. Searching a BST involves recursively comparing the target key to node keys and traversing left or right. Insertion finds the appropriate position by moving pointers down the tree until reaching an empty node.
Binary search trees (BSTs) are binary trees where all keys in the left subtree of a node are less than or equal to the key of that node, and all keys in the right subtree are greater than or equal to the node's key. Common BST operations include search, insertion, deletion, finding the minimum/maximum keys, and tree traversals like inorder, preorder, and postorder walks. These operations have worst-case time complexity proportional to the height of the tree.
A binary search tree (BST) is a binary tree where the value of each node is greater than all values in its left subtree and less than all values in its right subtree. This property allows efficient search, insert, and delete operations in O(logN) time. To search a BST, the algorithm starts at the root and recursively checks if the target value is equal to, less than, or greater than the value of the current node to determine if it proceeds to the left or right child. Insertion finds the appropriate position to add a new node by recursively comparing its value to ancestors' values.
- A binary search tree (BST) is a binary tree where all left descendants of a node are less than or equal to the node's value, and all right descendants are greater than or equal.
- Searching, insertion, and deletion in a BST follow the structure of the tree - searching compares the target value to the current node to determine which subtree to search, insertion adds new nodes by comparing to parent nodes, and deletion removes nodes and restructures the tree as needed.
- Common operations like searching, insertion, and deletion are accomplished by traversing the tree from the root node down, making comparisons at each level to determine the path through left or right subtrees.
1) Tree
2) General Tree
3) Binary Tree
4) Full Binay Tree, Complete Binay Tree
5) Binary Tree Traversal (DFS & BFS)
6) Binary Search Tree
7) Reconstruction of Binay Tree
8) Expression Tree
9) Evaluation of postfix expression
10) Infix to Prefix using stack
11) Infix to Postfix using stack
12) Threaded Binary Tree
13) AVL-Tree
14) AVL-Tree Rotation
The document discusses binary search trees (BSTs). It defines a BST as a binary tree where the value of each node is greater than all values in its left subtree and less than all values in its right subtree. It provides examples of BSTs and non-BSTs. Searching, inserting, and deleting operations on a BST have O(log n) time complexity on a balanced tree but can be O(n) on a degenerate tree. Insertion and deletion can cause imbalance in the tree over time.
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.
- The document discusses binary search trees, including their properties, how to search for a key, and how to insert a new key.
- A binary search tree is a binary tree where the key in each node is greater than all keys in the left subtree and less than those in the right subtree. This property allows searching, insertion, and deletion in logarithmic time.
- To search for a key, the algorithm recursively compares the search key to the node keys, traversing left or right. To insert a new key, it is added as a new child node in the appropriate sorted position.
The document discusses binary search trees and their operations. It defines key concepts like nodes, leaves, root, and tree traversal methods. It then explains how to search, insert, find minimum/maximum elements, and traverse a binary search tree. Searching a BST involves recursively comparing the target key to node keys and traversing left or right. Insertion finds the appropriate position by moving pointers down the tree until reaching an empty node.
Binary search trees (BSTs) are binary trees where all keys in the left subtree of a node are less than or equal to the key of that node, and all keys in the right subtree are greater than or equal to the node's key. Common BST operations include search, insertion, deletion, finding the minimum/maximum keys, and tree traversals like inorder, preorder, and postorder walks. These operations have worst-case time complexity proportional to the height of the tree.
A binary search tree (BST) is a binary tree where the value of each node is greater than all values in its left subtree and less than all values in its right subtree. This property allows efficient search, insert, and delete operations in O(logN) time. To search a BST, the algorithm starts at the root and recursively checks if the target value is equal to, less than, or greater than the value of the current node to determine if it proceeds to the left or right child. Insertion finds the appropriate position to add a new node by recursively comparing its value to ancestors' values.
The document discusses various tree data structures, including binary trees and binary search trees. It provides definitions and examples of binary trees, their terminology like root, left/right subtrees, and tree traversal methods including preorder, inorder and postorder. It also discusses applications of binary search trees for searching, as well as operations on trees like inserting, deleting and traversing nodes.
The document discusses binary trees and their implementation and traversal methods. It defines a binary tree as a tree where each node has at most two children. It describes the common traversal orders of binary trees as inorder, preorder and postorder. It also discusses breadth first traversal and storing binary trees using node structures. Expression trees are described as binary trees used to represent mathematical expressions where leaves are operands and internal nodes are operators.
The document discusses linked lists and their advantages over arrays. It begins with an overview of arrays and their pros and cons, then introduces linked lists as an alternative that overcomes some of the limitations of arrays. Key points covered include:
- Linked lists store elements in separate blocks of memory connected via pointers, unlike arrays which use a single block.
- This allows linked lists to dynamically allocate memory as needed, rather than having a fixed size like arrays.
- Common linked list operations like inserting and deleting nodes are described, including handling different cases like empty lists.
- Functions for traversing the list, printing elements, copying lists, and deleting nodes are presented.
The document discusses tree data structures and binary search trees. It defines key tree terminology like root, internal and leaf nodes. It explains tree traversal algorithms like preorder, inorder and postorder traversal using recursion and iteration. It also describes operations on binary search trees like searching, inserting and deleting nodes. The complexity of these BST operations is provided. Algorithms to find the inorder predecessor and successor of a node in a BST are presented.
Content of slide
Tree
Binary tree Implementation
Binary Search Tree
BST Operations
Traversal
Insertion
Deletion
Types of BST
Complexity in BST
Applications of BST
The document discusses binary trees, including their basic terminology, properties, representations, traversal methods, and common operations. It provides algorithms for inserting nodes, deleting nodes, and merging two binary trees. The key points covered are:
- Binary trees have a root node, child nodes, and properties like maximum/minimum number of nodes based on height.
- They can be represented sequentially using arrays or non-sequentially using linked lists.
- Common traversal orders are preorder, inorder, and postorder.
- Operations include insertion, deletion, traversal, and merging two trees into one larger tree.
- Algorithms are presented for inserting nodes using linked lists and merging two trees by combining their nodes.
A binary tree is composed of nodes, where each node contains a value and references (pointers) to a left and right child node. It may be empty or have a root node from which all other nodes are reachable through unique paths. Nodes without child nodes are leaves. The size is the number of nodes, and the depth is the longest path from the root node. Binary trees can be balanced or unbalanced. Common traversals that visit each node once include preorder, inorder, and postorder, which differ in when the root node is visited among its child subtrees.
This document discusses binary trees, including their basic definitions, traversal methods, node representations, and functions. It describes binary trees as having a root node that partitions the tree into two disjoint subsets, left and right subtrees. Traversal methods like preorder, inorder, and postorder are explained recursively. Applications of binary search trees for sorting and searching arrays are also covered.
The document provides an overview of different tree data structures including binary trees, binary search trees, AVL trees, B-trees, and B+ trees. It describes key properties such as balance factors for AVL trees and minimum/maximum node sizes for B-trees. Implementation details are given for binary trees, binary search trees, and some common tree operations like search, insert, delete. Applications of trees in indexing large datasets are also mentioned.
The document discusses binary search trees and their implementation. It begins by defining binary trees and their properties. It then describes how binary search trees work, with the key 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. It provides pseudocode for basic binary search tree operations like search, insert, delete, find minimum and maximum. Finally, it introduces AVL trees, which are self-balancing binary search trees that ensure fast lookup by keeping the height of left and right subtrees close.
Binary search trees are binary trees where all left descendants of a node are less than the node's value and all right descendants are greater. This structure allows for efficient search, insertion, and deletion operations. The document provides definitions and examples of binary search tree properties and operations like creation, traversal, searching, insertion, deletion, and finding minimum and maximum values. Applications include dynamically maintaining a sorted dataset to enable efficient search, insertion, and deletion.
This document contains a programming exam paper with 5 questions related to object-oriented programming concepts in Java. The questions cover topics like binary search trees, message boards, exceptions, threads, and generics. Students are asked to provide implementations and specifications for various data structures and algorithms, and explain concepts like method call stacks, exceptions, synchronization, and generics.
Binary search trees (BSTs) are data structures that allow for efficient searching, insertion, and deletion. Nodes in a BST are organized so that all left descendants of a node are less than the node's value and all right descendants are greater. This property allows values to be found, inserted, or deleted in O(log n) time on average. Searching involves recursively checking if the target value is less than or greater than the current node's value. Insertion follows the search process and adds the new node in the appropriate place. Deletion handles three cases: removing a leaf, node with one child, or node with two children.
This document provides an overview of trees as a non-linear data structure. It begins by discussing how trees are used to represent hierarchical relationships and defines some key tree terminology like root, parent, child, leaf, and subtree. It then explains that a tree consists of nodes connected in a parent-child relationship, with one root node and nodes that may have any number of children. The document also covers tree traversal methods like preorder, inorder, and postorder traversal. It introduces binary trees and binary search trees, and discusses operations on BSTs like search, insert, and delete. Finally, it provides a brief overview of the Huffman algorithm for data compression.
This document discusses sorting algorithms. It explains that sorting refers to arranging data in a specified order like numerical or alphabetical. Selection sort is described as finding the minimum element and swapping it into the correct position in each pass through the array until sorted. An example of selection sort is provided, showing the steps and swaps to sort an array of numbers.
Python is a widely used high-level programming language for general-purpose programming. Python is a simple, powerful and easy to learn the programming language. It is commonly used for Web and Internet development, Scientific and Numeric computing, Business application and Desktop GUI development etc. The basic data structures in python are lists, dictionaries, tuples, strings and sets
This document summarizes Python's standard data types including numbers, strings, lists, tuples, and dictionaries. It describes that in Python, data types are classes and variables are objects of those classes. It provides examples of how to define number variables and delete number object references. It also explains that strings can be defined using single or double quotes and how string slicing and concatenation works using indexes and operators.
Set Similarity Search using a Distributed Prefix Tree IndexHPCC Systems
The document describes an approach for set similarity search using a distributed prefix tree index. It begins by introducing the problem of set similarity search and examples of similarity functions like Jaccard similarity. It then reviews existing approaches like inverted indexes and introduces a new approach using a prefix tree to index the record sets. The remainder of the document discusses implementing and testing the prefix tree approach on various datasets and analyzing the results. It finds that the token order in the prefix tree impacts performance and that adding the level as an additional index key improves query runtime. The prefix tree approach generally outperforms inverted indexes at high similarity thresholds.
A binary tree is a tree data structure where each node has at most two children, described as left and right. There are different types of binary trees including full binary trees where each node has 0 or 2 children, and complete binary trees where all levels are fully filled except the lowest, which is filled from left to right. The document discusses properties of binary trees like the maximum number of nodes on each level and relationships between numbers of nodes and edges. It also describes common traversal techniques like preorder, inorder and postorder that visit nodes in different sequences, and provides pseudocode for algorithms to perform these traversals using a stack.
This document provides an introduction to trees as a non-linear data structure. It discusses key terms like root, parent, child, leaf nodes. It also covers different types of trees like binary trees and binary search trees. Tree traversal algorithms like preorder, inorder and postorder are explained along with pseudocode. Finally, it briefly discusses applications of trees and the Huffman algorithm for data compression.
The document discusses various tree data structures, including binary trees and binary search trees. It provides definitions and examples of binary trees, their terminology like root, left/right subtrees, and tree traversal methods including preorder, inorder and postorder. It also discusses applications of binary search trees for searching, as well as operations on trees like inserting, deleting and traversing nodes.
The document discusses binary trees and their implementation and traversal methods. It defines a binary tree as a tree where each node has at most two children. It describes the common traversal orders of binary trees as inorder, preorder and postorder. It also discusses breadth first traversal and storing binary trees using node structures. Expression trees are described as binary trees used to represent mathematical expressions where leaves are operands and internal nodes are operators.
The document discusses linked lists and their advantages over arrays. It begins with an overview of arrays and their pros and cons, then introduces linked lists as an alternative that overcomes some of the limitations of arrays. Key points covered include:
- Linked lists store elements in separate blocks of memory connected via pointers, unlike arrays which use a single block.
- This allows linked lists to dynamically allocate memory as needed, rather than having a fixed size like arrays.
- Common linked list operations like inserting and deleting nodes are described, including handling different cases like empty lists.
- Functions for traversing the list, printing elements, copying lists, and deleting nodes are presented.
The document discusses tree data structures and binary search trees. It defines key tree terminology like root, internal and leaf nodes. It explains tree traversal algorithms like preorder, inorder and postorder traversal using recursion and iteration. It also describes operations on binary search trees like searching, inserting and deleting nodes. The complexity of these BST operations is provided. Algorithms to find the inorder predecessor and successor of a node in a BST are presented.
Content of slide
Tree
Binary tree Implementation
Binary Search Tree
BST Operations
Traversal
Insertion
Deletion
Types of BST
Complexity in BST
Applications of BST
The document discusses binary trees, including their basic terminology, properties, representations, traversal methods, and common operations. It provides algorithms for inserting nodes, deleting nodes, and merging two binary trees. The key points covered are:
- Binary trees have a root node, child nodes, and properties like maximum/minimum number of nodes based on height.
- They can be represented sequentially using arrays or non-sequentially using linked lists.
- Common traversal orders are preorder, inorder, and postorder.
- Operations include insertion, deletion, traversal, and merging two trees into one larger tree.
- Algorithms are presented for inserting nodes using linked lists and merging two trees by combining their nodes.
A binary tree is composed of nodes, where each node contains a value and references (pointers) to a left and right child node. It may be empty or have a root node from which all other nodes are reachable through unique paths. Nodes without child nodes are leaves. The size is the number of nodes, and the depth is the longest path from the root node. Binary trees can be balanced or unbalanced. Common traversals that visit each node once include preorder, inorder, and postorder, which differ in when the root node is visited among its child subtrees.
This document discusses binary trees, including their basic definitions, traversal methods, node representations, and functions. It describes binary trees as having a root node that partitions the tree into two disjoint subsets, left and right subtrees. Traversal methods like preorder, inorder, and postorder are explained recursively. Applications of binary search trees for sorting and searching arrays are also covered.
The document provides an overview of different tree data structures including binary trees, binary search trees, AVL trees, B-trees, and B+ trees. It describes key properties such as balance factors for AVL trees and minimum/maximum node sizes for B-trees. Implementation details are given for binary trees, binary search trees, and some common tree operations like search, insert, delete. Applications of trees in indexing large datasets are also mentioned.
The document discusses binary search trees and their implementation. It begins by defining binary trees and their properties. It then describes how binary search trees work, with the key 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. It provides pseudocode for basic binary search tree operations like search, insert, delete, find minimum and maximum. Finally, it introduces AVL trees, which are self-balancing binary search trees that ensure fast lookup by keeping the height of left and right subtrees close.
Binary search trees are binary trees where all left descendants of a node are less than the node's value and all right descendants are greater. This structure allows for efficient search, insertion, and deletion operations. The document provides definitions and examples of binary search tree properties and operations like creation, traversal, searching, insertion, deletion, and finding minimum and maximum values. Applications include dynamically maintaining a sorted dataset to enable efficient search, insertion, and deletion.
This document contains a programming exam paper with 5 questions related to object-oriented programming concepts in Java. The questions cover topics like binary search trees, message boards, exceptions, threads, and generics. Students are asked to provide implementations and specifications for various data structures and algorithms, and explain concepts like method call stacks, exceptions, synchronization, and generics.
Binary search trees (BSTs) are data structures that allow for efficient searching, insertion, and deletion. Nodes in a BST are organized so that all left descendants of a node are less than the node's value and all right descendants are greater. This property allows values to be found, inserted, or deleted in O(log n) time on average. Searching involves recursively checking if the target value is less than or greater than the current node's value. Insertion follows the search process and adds the new node in the appropriate place. Deletion handles three cases: removing a leaf, node with one child, or node with two children.
This document provides an overview of trees as a non-linear data structure. It begins by discussing how trees are used to represent hierarchical relationships and defines some key tree terminology like root, parent, child, leaf, and subtree. It then explains that a tree consists of nodes connected in a parent-child relationship, with one root node and nodes that may have any number of children. The document also covers tree traversal methods like preorder, inorder, and postorder traversal. It introduces binary trees and binary search trees, and discusses operations on BSTs like search, insert, and delete. Finally, it provides a brief overview of the Huffman algorithm for data compression.
This document discusses sorting algorithms. It explains that sorting refers to arranging data in a specified order like numerical or alphabetical. Selection sort is described as finding the minimum element and swapping it into the correct position in each pass through the array until sorted. An example of selection sort is provided, showing the steps and swaps to sort an array of numbers.
Python is a widely used high-level programming language for general-purpose programming. Python is a simple, powerful and easy to learn the programming language. It is commonly used for Web and Internet development, Scientific and Numeric computing, Business application and Desktop GUI development etc. The basic data structures in python are lists, dictionaries, tuples, strings and sets
This document summarizes Python's standard data types including numbers, strings, lists, tuples, and dictionaries. It describes that in Python, data types are classes and variables are objects of those classes. It provides examples of how to define number variables and delete number object references. It also explains that strings can be defined using single or double quotes and how string slicing and concatenation works using indexes and operators.
Set Similarity Search using a Distributed Prefix Tree IndexHPCC Systems
The document describes an approach for set similarity search using a distributed prefix tree index. It begins by introducing the problem of set similarity search and examples of similarity functions like Jaccard similarity. It then reviews existing approaches like inverted indexes and introduces a new approach using a prefix tree to index the record sets. The remainder of the document discusses implementing and testing the prefix tree approach on various datasets and analyzing the results. It finds that the token order in the prefix tree impacts performance and that adding the level as an additional index key improves query runtime. The prefix tree approach generally outperforms inverted indexes at high similarity thresholds.
A binary tree is a tree data structure where each node has at most two children, described as left and right. There are different types of binary trees including full binary trees where each node has 0 or 2 children, and complete binary trees where all levels are fully filled except the lowest, which is filled from left to right. The document discusses properties of binary trees like the maximum number of nodes on each level and relationships between numbers of nodes and edges. It also describes common traversal techniques like preorder, inorder and postorder that visit nodes in different sequences, and provides pseudocode for algorithms to perform these traversals using a stack.
This document provides an introduction to trees as a non-linear data structure. It discusses key terms like root, parent, child, leaf nodes. It also covers different types of trees like binary trees and binary search trees. Tree traversal algorithms like preorder, inorder and postorder are explained along with pseudocode. Finally, it briefly discusses applications of trees and the Huffman algorithm for data compression.
Binary trees are a non-linear data structure where each node has at most two children, used to represent hierarchical relationships, with nodes connected through parent-child links and traversed through preorder, inorder, and postorder methods; they can be represented through arrays or linked lists and support common operations like search, insert, and delete through comparing node values and restructuring child pointers.
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.
The document discusses trees and binary search trees. It defines key tree concepts like nodes, roots, parents, children, leaves and subtrees. It explains that a binary search tree is a type of binary tree where all left descendants of a node are less than or equal to the node and all right descendants are greater. The document outlines operations on binary search trees like searching, inserting, deleting nodes and different tree traversals. It also discusses balancing binary search trees using the AVL tree data structure.
This document discusses binary search trees and efficient binary trees. It begins by explaining what a binary search tree is and how it allows for efficient searching in O(log n) time. It then discusses how to create, search, insert, delete, determine the height and number of nodes in a binary search tree. The document also covers mirrored binary trees, threaded binary trees, and AVL trees, which are self-balancing binary search trees that ensure searching remains O(log n) time.
This document discusses different types of trees and tree traversal algorithms. It begins by defining what a tree is and describing some key tree terminology like root, child, parent, and leaf nodes. It then covers different types of binary trees like full, complete, and extended binary trees. The document also explains tree traversal algorithms like preorder, inorder, and postorder traversal. Finally, it discusses binary search trees and their insertion, deletion, and search algorithms. Heap trees are also covered with examples of inserting and deleting nodes to maintain the heap property.
This document discusses hashing concepts and binary tree data structures. It defines hashing as a technique that maps data to a hash table using a hash function. It provides examples of hash functions like division, mid-square, and folding methods. It also defines binary trees as data structures that have a root node and left and right subtrees. It describes terminology like ancestors, descendants, and levels for binary trees. It differentiates between types of binary trees like complete, strict, and almost complete binary trees. It also discusses representations and traversals like preorder, inorder, and postorder for binary trees.
The document discusses trees and tree data structures. It provides details on heap data structures and algorithms for inserting and deleting elements from a heap. It also covers B-trees, including their definition, properties, and algorithms for constructing, inserting, and removing elements from a B-tree. B-trees are designed to improve search efficiency for large datasets stored on disk compared to binary search trees.
Tree representations can be list-based or use left child and right sibling pointers. Binary search trees store values such that all left descendants are less than the node value and all right descendants are greater. Common operations on binary search trees are search, insertion, and deletion through comparing node values, replacing nodes, or restructuring subtrees.
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.
Trees are fundamental data structures that combine advantages of ordered arrays and linked lists. They consist of nodes connected by edges, where nodes often represent entities and edges represent relationships between nodes. Common tree operations include traversing to visit all nodes in order, searching for a node by its key, and inserting or deleting nodes. These operations have O(log N) time complexity where N is the number of nodes. Binary trees restrict each node to at most two children while Huffman trees are used to compress data by assigning variable-length binary codes to characters based on their frequency.
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.
Data structures and Algorithm analysis_Lecture4.pptxAhmedEldesoky24
This document defines and explains binary search trees (BSTs). It defines key BST terms like root, leaf nodes, and height. It also outlines common BST operations like search, insertion, deletion, finding the minimum/maximum elements, and tree traversals. Search, minimum/maximum, and traversal operations have linear time complexity based on tree height, while insertion and deletion are O(h) where h is the tree height. The document uses examples to illustrate BST concepts and operations.
This document discusses binary trees and their representations and uses. It defines key terms related to binary trees like nodes, leaves, siblings, and levels. It describes different types of binary trees like complete and extended binary trees. It explains how to represent binary trees in memory using linked and sequential representations. It provides examples of how binary trees can be used to represent expressions and model tournaments. It also discusses algorithms for traversing binary trees in preorder, inorder and postorder sequences.
This document discusses nonlinear data structures like trees and graphs. It defines trees and graphs, and describes their properties. Specific tree types discussed include binary trees, binary search trees, and n-ary trees. Graphs can be directed or undirected. The document also covers tree traversal methods and discusses searching algorithms for graphs like breadth-first search and depth-first search.
This document discusses nonlinear data structures like trees and graphs. It defines trees and graphs, and notes that all trees are graphs but not all graphs are trees. It then describes different types of trees like binary trees, binary search trees, and n-ary trees. It also covers graph concepts like directed and undirected graphs. The document discusses traversing trees using preorder, inorder and postorder traversal and covers graph searching algorithms like breadth-first search and depth-first search.
The document discusses data structures and algorithms. It begins by defining data structures as organized data and allowed operations. It then discusses arrays, linked lists, binary trees, and their implementations. Arrays allow fast access but fixed size, while linked lists and trees can grow dynamically but have slower access. Binary tree operations like search, insert, and delete have logarithmic time complexity due to the tree height being logarithmic in the number of nodes. The document provides examples of various data structure implementations and traversals.
This presentation includes basic of PCOS their pathology and treatment and also Ayurveda correlation of PCOS and Ayurvedic line of treatment mentioned in classics.
A review of the growth of the Israel Genealogy Research Association Database Collection for the last 12 months. Our collection is now passed the 3 million mark and still growing. See which archives have contributed the most. See the different types of records we have, and which years have had records added. You can also see what we have for the future.
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...PECB
Denis is a dynamic and results-driven Chief Information Officer (CIO) with a distinguished career spanning information systems analysis and technical project management. With a proven track record of spearheading the design and delivery of cutting-edge Information Management solutions, he has consistently elevated business operations, streamlined reporting functions, and maximized process efficiency.
Certified as an ISO/IEC 27001: Information Security Management Systems (ISMS) Lead Implementer, Data Protection Officer, and Cyber Risks Analyst, Denis brings a heightened focus on data security, privacy, and cyber resilience to every endeavor.
His expertise extends across a diverse spectrum of reporting, database, and web development applications, underpinned by an exceptional grasp of data storage and virtualization technologies. His proficiency in application testing, database administration, and data cleansing ensures seamless execution of complex projects.
What sets Denis apart is his comprehensive understanding of Business and Systems Analysis technologies, honed through involvement in all phases of the Software Development Lifecycle (SDLC). From meticulous requirements gathering to precise analysis, innovative design, rigorous development, thorough testing, and successful implementation, he has consistently delivered exceptional results.
Throughout his career, he has taken on multifaceted roles, from leading technical project management teams to owning solutions that drive operational excellence. His conscientious and proactive approach is unwavering, whether he is working independently or collaboratively within a team. His ability to connect with colleagues on a personal level underscores his commitment to fostering a harmonious and productive workplace environment.
Date: May 29, 2024
Tags: Information Security, ISO/IEC 27001, ISO/IEC 42001, Artificial Intelligence, GDPR
-------------------------------------------------------------------------------
Find out more about ISO training and certification services
Training: ISO/IEC 27001 Information Security Management System - EN | PECB
ISO/IEC 42001 Artificial Intelligence Management System - EN | PECB
General Data Protection Regulation (GDPR) - Training Courses - EN | PECB
Webinars: https://pecb.com/webinars
Article: https://pecb.com/article
-------------------------------------------------------------------------------
For more information about PECB:
Website: https://pecb.com/
LinkedIn: https://www.linkedin.com/company/pecb/
Facebook: https://www.facebook.com/PECBInternational/
Slideshare: http://www.slideshare.net/PECBCERTIFICATION
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
How to Build a Module in Odoo 17 Using the Scaffold MethodCeline George
Odoo provides an option for creating a module by using a single line command. By using this command the user can make a whole structure of a module. It is very easy for a beginner to make a module. There is no need to make each file manually. This slide will show how to create a module using the scaffold method.
2. • A tree is a hiearchical structure .
• Collection of nodes or Finite set of nodes This
collection can be empty Nodes and Edges.
3. TREE TERMINOLOGY
• NODE:A node is the key component of the tree
data structure that stores the data element and
may contain zero,one or more link to other
sucessor node for connectivity. A tree consist of
finite set of nodes.
• EDGE or LINK: A directed line from one node to the
other successor node is called edge of the tree.i
• It is also known as link or arc or branch of a tree.
• A tree consists of a finite set of edges that connects
node.
4. • PARENT: The immediate predecessor of a node is
called its parent.All the nodes except the root node
have exactly one parent.
• CHILD: All the immediate successors of a node are
known as its child. If a node has two child then one
on the left is called left child and other on the right
is called right child.
• SIBLING: Two or more nodes with same parents are
called siblings.
• ROOT: The topmost node of the tree is called the
root of the tree.One can reach any node of the tree
from the root node by following the edges.
5. • LEAF: The node that does not have any child node
is called leaf node.
• PATH: A path is a result in sequence of nodes when
we traverse from a node to a node along the edges
that connect them. There is always a unique path
from the root to any other node in a tree.
• LEVEL: The level of the node is an integer value that
measures the distance of a node from the root.As
the root is at zero distance from itself so it is at
level 0.
• DEGREE: The maximum number of children that are
possible for a node is known as degree ,like in
binary tree max 2 children can be there so degree is
2
6. • DEPTH: The depth of a node is the length(number
of edges) of the path from the root to the node of
the tree.
• Depth of the node is sometimes also referred to the level of a node.
• HEIGHT: The height of a tree is the length (number
of edges) of the path from the node to its furthest
leaf .
7. BINARY TREE
• A binary tree is a special form of tree in which a
node can have atmost two children
• A node in a binary tree may not necessarily have
the maximum of two children i.e either 1,2 or 0
child.
• A tree which does not contain any node is called
empty binary node.
9. Full Binary Tree
A binary tree is said to be full binary tree
if each node has exactly zero or two
children.
Also known as proper binary tree
10. Complete Binary Tree
A complete binary tree is either a full
binary tree or one in which every level is
fully occupied except possibly for the
bottomost level where all the nodes
must be as far left as possible.
11. PROPERTIES OF BINARY TREE
• 1.The maximum number of nodes in a binary tree
on a given level (say L) is 2L ,where L>=0 .
• 2.The maximum number of nodes in an binary tree
with height h is 2h+1-1
• 3.the minimum number of nodes possible in a
binary tree of height h is h+1
12. • 4.if n is the number of nodes and e is the number of
edges in an non-empty binary tree then n=e+1.
• 5.if n0 is the number of leaf nodes (no child) and n2 is
the number of nodes with two children in a non-empty
binary tree then n0= n2+1
• 6.for a complete binary tree T with n nodes ,the
height is floor[log2(n+1) -1]
13. Binary Tree Traversal Techniques
• Three recursive techniques for binary tree
traversal
• In each technique, the left subtree is traversed
recursively, the right subtree is traversed
recursively, and the root is visited
• What distinguishes the techniques from one
another is the order of those 3 tasks
13
14. Preoder, Inorder, Postorder
• In Preorder, the root
is visited before (pre)
the subtrees traversals
• In Inorder, the root is
visited in-between left
and right subtree traversal
• In Preorder, the root
is visited after (pre)
the subtrees traversals
Preorder Traversal:
1. Visit the root
2. Traverse left subtree
3. Traverse right subtree
Inorder Traversal:
1. Traverse left subtree
2. Visit the root
3. Traverse right subtree
Postorder Traversal:
1. Traverse left subtree
2. Traverse right subtree
3. Visit the root 14
24. PRE-ORDER USING STACK
• PREORD(INFO,LEFT,RIGHT,ROOT): A binary tree
T is in memory .The algorithm does a
preorder traversal of T, applying an
operation PROCESS to each of its node. An
array STACK is used to temporarily hold the
addresses of nodes.
25. • 1.[Initiaaly push NULL onto STACK and initialize
PTR]
Set TOP1.STACK[1]NULL and PTRROOT
2.Repeat steps 3 to 5 while PTR!=NULL
3.Apply PROCESS to INFO[PTR]
4.[Right Child?]
If RIGHT[PTR]!=NULL [Push on STACK]
TOPTOP+1
STACK[TOP]RIGHT[PTR]
[End of if structure]
26. • 5.[Left Child ?]
If LEFT[PTR]!=NULL,
Set PTRLEFT[PTR]
Else [pop from stack]
PTRSTACK[TOP]
TOPTOP-1
[End of if strucutre]
[End of step 2 loop]
6.Exit
27. IN-ORDER
• INORDER(INFO,LEFT,RIGHT,ROOT):A binary tree is
in memory. This algorithm does an inorder traversal
.applying PROCESS to each of its node.An array
STACK is used to temporarily hold the addresses of
node.
28. 1.[Push NULL onto STACK and initialize PTR]
TOP1,STACK[1]NULL and PTRROOT
2.Repeat while PTR!=NULL [Push left most path onto
stack]
a)TOPTOP+1 and STACK[TOP]PTR [Saves
nodes]
b)PTRLEFT[PTR] [updates PTR]
[End of loop]
3.PTRSTACK[TOP]
TOPTOP-1 [pops node from STACK]
29. 4.Repeat steps 5 to 7 while PTR!=NULL [Backtracking]
5.Apply PROCESS to INFO[PTR]
6.[Right child?]
If RIGHT[PTR]!=NULL
a)PTRRIGHT[PTR]
b)GOTO step 2
7.PTRSTACK[TOP]
TOP=TOP-1 [Pops node]
[end of step 4 loop]
8.Exit
30. POSTORDER
• POSTORD(INFO,LEFT,RIGHT,ROOT):A binary
tree T is in memory.This algorithm does a
postorder traversal of T,applying an
operation PROCESS to each of its node.An
array STACK is used to temporarily hold the
address of nodes
31. 1.[push NULL onto STACK and initialize PTR]
Set TOP1,STACK[1]NULL,PTRROOT
2.[Push left-most path onto STACK]
Repeat steps 3 to 5 while(PTR!=NULL)
3.TOPTOP+1
STACK[TOP]PTR [ Pushes PTR on STACK]
4.if RIGHT[PTR]!=NULL, then [Push on STACK]
TOPTOP+1 and STACK[TOP]=-RIGHT[PTR].
[end of If strucutre]
32. Set PTRLEFT[PTR] [Updates pointer PTR]
[End of Step 2 loop]
6.Set PTRSTACK[TOP] and TOPTOP-1 [Pops node from
STACK]
7.Repeat while PTR>0.
A)Apply PROCESS to INFO[PTR]
B)Set PTRSTACK[TOP] and TOPTOP-1 [pops node
from STACK]
8.If PTR<0 ,then:
a)PTR-PTR
b)Goto step 2.
[End of If structure]
9.EXIT
34. INTRODUCTION
• Binary Search Tree abbreviated as BST is a special
form of binary tree whose nodes are arranged in
such a way that for every node N,the values
contained in all nodes in its left sub tree are less the
value contained in N and values contained in the
right sub tree are larger than the node N
35. SEARCHING
• Searching an item is the key operation performed on a BST.
When we want to search given item(ITEM) in BST ,we begin by
first comparing the ITEM with the value in root.
• A)if they are equal then the location of the root node is
returned.
• B)If the ITEM is less than the value of the root then we need to
search the left sub tree of the root. The right sub tree is
eliminated .
• C)if the ITEM is greater than the value of the root then we
need to search the right sub tree of the root.
36. Searching in BST
• BSTSEARCH(ROOT,ITEM): Given linked BST whose root
node is pointed to by pointer ROOT. A variable PTR is
used which is a pointer that points to the current node
being processed. Another local variable LOC returns the
location of a given ITEM. The local variable FLAG contains
Boolean value which is TRUE(i.e. 1) if search is successful
otherwise FALSE(i.e. 0) . This algo searches for a given
ITEM from BST.
37. 1. PTRROOT [Stores address of ROOT into PTR]
2. FLAG0 [Assume search is unsuccessful]
3. LOCNULL
4. Repeat steps while PTR!=NULL and FLAG=0
5. If ITEM =INFO(PTR) then [Item found]
FLAG1, LOCPTR
Else if ITEM < INFO(PTR) then [Item in left subtree]
PTRLEFT(PTR)
Else
PTRRIGHT(PTR) [Item in right subtree]
[End if structure]
[End of step 4 loop]
38. INSERTION IN BST
• Insertion of new node into binary search tree is
very simple operation based on the search
operation.
• In order to insert a node with given item into
BST ,we begin searching at the root and descend
level by level moving left or right subtree as
appropriate comparing the value of the current
node and node being inserted.
• When we reach a node with empty subtree(i.e leaf)
then we insert the new node as its left or right child
depending on ITEM.
39. • While searching if the ITEM to be inserted is
already in the tree then do nothing as we know
binary tree cannot hold the duplicate values.
• Also note that as insertion take place only at leaf
node so we only need ITEM to be inserted and not
the location of the insertion
40. • BST_INSERT(ROOT,ITEM,AVAIL) –Given a linked
list BST whose root node is pointed to by a pointer
ROOT.A local variable PTR is used which points to the
current node being processed. The variable PPTR is a
pointer that points to the parent of the new node
containing ITEM in its INFO part. The pointer
variable NEW points to the new node and the AVAIL
pointer points to the first node in the availability
list.This algorithm inserts the given ITEM into BST.
41. 1. If AVAIL=NULL then [No space for new node]
Write “ Overflow”.
return
[End of if structure]
2. [Get new node from availability list]
a) NEWAVIAL
b) AVAILLEFT(AVAIL)
c) INFO(NEW)ITEM [Copy ITEM into INFO part of new node]
3.[New node has no children]
a) LEFT(NEW)NULL
b) RIGHT(NEW)NULL
4.If ROOT=NULL then [Tree is empty]
ROOTNEW [Insert new node as root]
return
[End of if structure]
42. [Remaining steps insert new node at appropriate location in non empty tree]
5.PTRROOT, PTRNULL
6. Repeat steps 7 and 8 while PTR!=NULL [Finding parent of new node]
7.PPTRPTR [ Make current node as parent]
8. If ITEM> INFO(PTR) then [Item>current node’s INFO part]
PTRRIGHT(PTR) [Move towards right subtree]
ELSE
PTRLEFT(PTR) [Move towards left subtree]
[End of If structure]
[End of step 6 loop]
9.If ITEM<INFO(PPTR) then
LEFT(PPTR)NEW [Insert new node as left child]
Else
RIGHT(PPTR)NEW [Insert new as right child]
10. Return
43. DELETION IN BST
BSTDELETE(ROOT,ITEM ,AVAIL)-Given a linked binary
search tree whose root is pointed to by pointer ROOT. A local variable
PTR is used which is a pointer that points to the current node being
processed. The variable PPTR is a pointer that points to the parent of
ITEM. The local variable LOC returns the location of given ITEM that
is to be deleted. The FLAG variable contains a Boolean value which is
TRUE if search is successful , other wise FALSE. This algo deletes the
given ITEM from BST.
44. 1.PTRROOT, FLAG0 [Initialize PTR, assume search successful]
2. Repeat steps 3 while PTR!=NULL [All nodes served ] and FLAG=0 [Search
Unsuccessful]
3. If ITEM=INFO(PTR) then [Node to be deleted found]
FLAG1, LOCPTR
Else If ITEM < INFO(PTR) then [ITEM in left subtree]
PPTRPTR [Make current node as a parent]
PTRLEFT(PTR) [Make a left child as current node]
Else [ITEM in right subtree]
PPTRPTR
PTRRIGHT(PTR)
[End of If structure]
[End of step 3 loop]
4. If LOC=NULL then
Write “ITEM does not exist”
return
45. [End of If structure]
5. If RIGHT(LOC)!=NULL and LEFT(LOC)!=NULL then [ Case 3]
Call DELNODE_TWOCH(ROOT, LOC, PPTR)
Else[Case 1 and Case 2]
Call DELNODE_ZRONECH(ROOT,LOC,PPTR)
[End of If structure]
6.[Returning deleted node to availability list]
LEFT(LOC)AVAIL
AVAILLOC
7. Return
46. DELNODE_ZRONECH
• DELNODE_ZRONECH (ROOT,LOC,PPTR):
This algorithm deletes a node with zero or one
child from BST. A local variable CHILDNODE
will be set to NULL if the deleted node does
not have any child or will point to left or right
child of deleted node otherwise.
47. 1.[Initialize childnode]
If LEFT(LOC)=NULL and RIGHT(LOC)=NULL then [No Child]
CHILDNODENULL
Else If LEFT(LOC)!=NULL then
CHILDNODELEFT(LOC)
Else
CHILDNODERIGHT(LOC)
[End of If structure]
2.If PPTR=NULL then [No parent]
ROOTCHILDNODE
Else If LOC=LEFT(PPTR) then [Deleted node to the left of parent node]
LEFT(PPTR)CHILDNODE
ELSE [Deleted Node to the right of parent node]
RIGHT(PPTR)CHILDNODE
[End of If structure] [End of structure] 3. Return
48. DELNODE_TWOCH
DELNODE_TWOCH(ROOT,LOC,PPTR): This algorithm
deletes a node with two children from BST . LOC points to
the node to be deleted and PPTR points to its parent. A
local variable SUCC points to the inorder successor of
node to be deleted. The local variable PARSUCC points to
the parent of inorder successor.
49. [Find inorder successor node and parent of successor node[Step 1 and 2]]
1.SUCCRIGHT(LOC), PARSUCCLOC
2. Repeat while LEFT(SUCC) !=NULL
PARSUCCSUCC [ Make successor as parent]
SUCCLEFT(SUCC) [ Make left child of successor as successor node]
[End of Step 2 loop]
3. Call DELNODE_ZRONECH(ROOT,SUCC,PARSUCC) [Delete inorder successor]
[Steps 4 and 5 replace node N by its inorder successor]
4. If PARSUCC=NULL then [No Parent]
ROOTSUCC
Else if LOC=LEFT(PPTR) then [deleted node to left of its parent]
LEFT(PPTR)SUCC
Else [deleted node to right of its parent]
RIGHT(PPTR)SUCC
50. [End of If structure]
5. a) LEFT(SUCC)LEFT(LOC)
b) RIGHT(SUCC)RIGHT(LOC)
6. Return