0% found this document useful (0 votes)
4 views14 pages

Lesson LL Tree

The document introduces linked lists and trees, covering their definitions, components, and coding techniques. Linked lists are sequential data structures with nodes that point to the next, while trees are hierarchical structures with nodes connected by edges. The document also outlines learning objectives and next steps for implementing and exploring various types of linked lists and trees.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views14 pages

Lesson LL Tree

The document introduces linked lists and trees, covering their definitions, components, and coding techniques. Linked lists are sequential data structures with nodes that point to the next, while trees are hierarchical structures with nodes connected by edges. The document also outlines learning objectives and next steps for implementing and exploring various types of linked lists and trees.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Introduction To Trees

- By Harshi Chandrafari
Learning Objectives:
- What are Linked Lists
- Coding a Linked List
- What are Trees
- Coding Trees
- Summary
What is Linked List?

● Definition: A sequential
data structure where
each element (node)
points to the next.
● Components: Node,
Pointer, Head, Tail.
What is Node ?

A node is a fundamental building block of a linked list. It


mainly contains two components:

● Data: The actual value or payload stored in the node.


● Next Pointer: A reference or pointer to the next node
in the sequence.
Coding a Linked List:
Coding a Linked List:
Do on your own:

Try coding the given doubly linked


list on your own.

Hint: It has one additional


component compared to Singly
Linked List.
What is Trees?
● Definition: A hierarchical
data structure with nodes
connected by edges.
● Components: Root, Parent,
Child, Siblings, Leaf.
● Leaf → A node that doesn’t have any child nodes is called as Leaf node of the
Tree.
● Siblings → Two nodes which have the same parent are known as Siblings of each
other.
● Internal Nodes → A node which has at least one child is called a Internal of the
Tree.
● Height → The height of a node is number of edges from given node to the Root
node.
● Depth → The depth of a node is length of the path from Root of the Tree to the
given node.
● Degree of a Node → The maximum number of children that a node has is known
as the degree of the node.
Coding a Tree:
Coding a Tree:
Do on your own:

Try coding a binary tree on your own.

Hint1: It has only two child, one left


child and one right child.

Hint2: No need of using vector can


use two pointers instead
Summary:
● Linked Lists: Linear data structure; types include Singly, Doubly, and Circular
Linked Lists.
● Trees: Hierarchical structure; types include Binary Tree, BST, AVL, Red-Black
Tree, Heap, and Trie.
Next Steps:
● Implement different types of linked lists and their operations.
● Explore tree types and traversal algorithms (DFS, BFS).
● Study advanced tree algorithms (LCA, Segment Tree, Dynamic Programming on
Trees).

You might also like