๐ Day 58 | DSA | Tree Concepts
๐ Day 58 | DSA | Tree Concepts
๐๐ป Read it hereโฆ
---
๐ณ Tree Data Structure Basics (DSA)
๐ Root
๐น The topmost node of the tree
๐น Every tree has exactly one root
๐น Starting point of traversal
---
๐ถ Children
๐น Nodes directly connected below a parent
๐น A parent can have multiple children
๐น Children have exactly one parent
---
๐ฆ Internal Nodes
๐น Nodes that have at least one child
๐น Not leaf nodes
๐น Help in forming tree structure
---
๐ Level
๐น Position of a node in the tree
๐น Root is level 0
๐น Level increases as we go down
---
๐ Traversals
๐ธ Inorder (L โ Root โ R)
---
๐ธ Preorder (Root โ L โ R)
---
๐ธ Postorder (L โ R โ Root)
---
๐ Height of Tree
๐น Number of edges on the longest path from root to leaf
๐น Empty tree height = -1 (by convention)
๐น Single node tree height = 0
---
๐ก Interview Tip:
๐ Height โ Number of nodes
๐ Height counts edges, not nodes
---
Support โค๏ธ Like โข Save โข Share
Follow @codewithbrains for more DSA visuals ๐
#dsa #tree #datastructures #coding #binarytree softwareengineer developer 100daysofcode
Comments
Comments from the original post on Instagram
No comments yet
