Non Linear Data Structure 1
Non Linear Data Structure 1
Structure
It is a form of data structure where the data elements
don’t stay arranged linearly or sequentially.
10. Full Binary Tree: A binary tree is full if each node has either
0 or 2 children. In other words, every node is either a leaf or
has two children. and right subtrees of any node differ by at
most one.
11. Complete Binary Tree: A binary tree is complete
if all levels, except possibly the last, are completely
filled, and all nodes are as left as possible.
Theseproperties provide a foundation for
understanding and working with binary trees in
various algorithms and applications, such as
searching, sorting, and hierarchical data
representation.
Application of Tree Data Structure
File
System: This allows for efficient navigation and
organization of files.
1.Binary Tree
2.Binary Search Tree
3.AVL Tree
4.B-Tree
Binary Tree
data item
File explorer.
Used as the basic data structure in Microsoft Excel
and spreadsheets.
Editor tool: Microsoft Excel and spreadsheets.
Evaluate an expression
Advantages of Binary Tree
2. Search
Searching in a BST follows the same logic as insertion:
• Start at the root node.
• If the target value is less than the current node's value, move to the left child.
• If the target value is greater, move to the right child.
• Repeat this process until the value is found or a NULL pointer is reached,
indicating the value is not present.
3. Height of a BST
he height of a BST (hhh) is the number of edges in the longest path from the root to a
leaf node.
• Formula: 2h+1 −1
NB: In a Binary Search Tree (BST), the number of nodes can vary depending on the tree's
height and how well it is balanced.
1. Draw the BST where the data value at each node
is an integer and the values are entered in the
following order: 9 7 12
2. )
Draw the BST after the following insertions have
been done in the tree of part (1) 6 8 10 14
3. calculate
number nodes the height, maximum l
nodes minimum nodes and depth nodes
Constructing the Binary Search Tree (BST) based on the given sequence of
insertions and then calculate the required properties.
9
/\
7 12
1. Null Graph
A graph is known as a null graph if there are
no edges in the graph.
2. Trivial Graph
Graph having only a single vertex, it is also the
smallest graph possible.
3. Undirected Graph
A graph in which edges do not have any direction. That is
the nodes are unordered pairs in the definition of every
edge.
4. Directed Graph
A graph in which edge has direction. That is the nodes
are ordered pairs in the definition of every edge.
Representation of Graphs