Data Structure Tutorial Pdf

Punjabi - 3gp Video Songs 2015, Download, PagalWorld, Pagalworld.com, Mp3 Song, Mp3 Songs. Download mp4 3gp mobile videos on Punjabi category. Punjabi song video download 3gp mp3.

What are trees?

  • Tree is a hierarchical data structure which stores the information naturally in the form of hierarchy style.
  • Tree is one of the most powerful and advanced data structures.
  • It is a non-linear data structure compared to arrays, linked lists, stack and queue.
  • It represents the nodes connected by edges.

The above figure represents structure of a tree. Tree has 2 subtrees.

Data Structure tutorial for beginners and programmers - Learn Data Structure with easy, simple and step by step tutorial covering syntax, notes and examples for computer science students on important concepts like Linked List, Stack, Queue, Dequeue, Searching, Sorting etc. Introduction to Data Structure Prof. Pradyumansinh Jadeja 2130702 – Data Structure 1 Introduction to Data Structure Computer is an electronic machine which is used for data processing and manipulation. When programmer collects such type of data for processing, he would require to store all of them in computer’s main memory.


TutorialA is a parent of B and C.
B is called a child of A and also parent of D, E, F.
Tree is a collection of elements called Nodes, where each node can have arbitrary number of children.
FieldDescription
RootRoot is a special node in a tree. The entire tree is referenced through it. It does not have a parent.
Parent NodeParent node is an immediate predecessor of a node.
Child NodeAll immediate successors of a node are its children.
SiblingsNodes with the same parent are called Siblings.
PathPath is a number of successive edges from source node to destination node.
Height of NodeHeight of a node represents the number of edges on the longest path between that node and a leaf.
Height of TreeHeight of tree represents the height of its root node.
Depth of NodeDepth of a node represents the number of edges from the tree's root node to the node.
Degree of NodeDegree of a node represents a number of children of a node.
EdgeEdge is a connection between one node to another. It is a line between two nodes or a node and a leaf.

In the above figure, D, F, H, G are leaves. B and C are siblings. Each node excluding a root is connected by a direct edge from exactly one other node
parent → children.

Levels of a node

Levels of a node represents the number of connections between the node and the root. It represents generation of a node. If the root node is at level 0, its next node is at level 1, its grand child is at level 2 and so on. Levels of a node can be shown as follows:
Note:
- If node has no children, it is called Leaves or External Nodes.
- Nodes which are not leaves, are called Internal Nodes. Internal nodes have at least one child.
- A tree can be empty with no nodes or a tree consists of one node called the Root.

Height of a Node


As we studied, height of a node is a number of edges on the longest path between that node and a leaf. Each node has height.
In the above figure, A, B, C, D can have height. Leaf cannot have height as there will be no path starting from a leaf. Node A's height is the number of edges of the path to K not to D. And its height is 3.
Note: Data structure tutorial point pdf free download
- Height of a node defines the longest path from the node to a leaf.
- Path can only be downward.

Depth of a Node


While talking about the height, it locates a node at bottom where for depth, it is located at top which is root level and therefore we call it depth of a node.

Data Structure Tutorial Pdf Free


In the above figure, Node G's depth is 2. In depth of a node, we just count how many edges between the targeting node & the root and ignoring the directions.

Data Structure Tutorial Pdf In C


Note: Depth of the root is 0.

Advantages of Tree

  • Tree reflects structural relationships in the data.
  • It is used to represent hierarchies.
  • It provides an efficient insertion and searching operations.
  • Trees are flexible. It allows to move subtrees around with minimum effort.