Notes
Algorithmic Pattern
Algorithmic Pattern
  • About
  • Arrays
    • Kadane’s Algorithm
    • Boyer Moore majority vote algorithm
  • Linked List
    • Linked List
    • Cycle Detection
    • Sorting
  • Stack
    • Stack
    • Monotonic Stack
    • Reversing an Array
    • Tower of Hanoi
  • Queue
    • Queue
    • Deques
    • Priority Queue
  • Heap
    • Heap
    • Binary Heap
    • Binomial Heap
  • Sort
    • Sorting
    • Insertion Sort
    • Selection Sort
    • Bubble Sort
    • Quick Sort
    • Merge Sort
    • Counting Sort
    • Pigeon Hole Sort
  • Tree
    • Centre of gravity
    • Shortest Path
    • Diameter of Tree
    • Binary Tree Traversal
  • Graph
    • Topological Sort
    • Tree Traversal
    • Graph
    • Cycle detection
  • Numerical Algorithms
    • GCD of two numbers
    • Performing Exponentiation
    • Finding If Number is Prime
    • Randomising Data
    • Prime Numbers
  • Miscellaneous
    • Finding the majority element
    • Rotate array by K steps
Powered by GitBook
On this page
  • Depth First Search
  • Breadth First Search
  1. Graph

Tree Traversal

Depth First Search

DFS will only store as much memory on the stack as is required for the longest root to leaf path in the tree. In other words, it space usage is O(h)\text{O}(h)O(h) where hhh is the height of the tree.

Breadth First Search

PreviousTopological SortNextGraph

Last updated 1 year ago