Skip to main content

Posts

Showing posts with the label DSA

Cheat Sheet Binary Tree

Terminologies Root node - the topmost element is called the root of the binary tree Leaf Node - the node that does not have any children is the leaf node   Level of Binary Tree -  horizontal distance of Binary Tree -      horizontal distance of the root is 0     horizontal distance of the left child = horizontal distance of its parent minus 1     horizontal distance of the right child = horizontal distance of its parent plus 1  Predecessor -   successor   -  Binary Tree Problems   1. Inorder traversal  (Left root Right) while(root != null){     inorder(root.left)     print(root.data)     inorder(root.right) } 2. Preorder traversal (root Left right ) while(root != null){      print(root.data)      preorder(root.left)     preorder(root.right) } 3. Postorder traversal (Left right root) while(root != null){     postorder(ro...

Cheats For Sorting Algorithm

Sorting algorithm 1. Bubble Sort 2. Insertion Sort 3. Selection Sort  4. Merge Sort 5. Quick Sort Quick Sort - The partition logic of quick sort is very powerful problem solving tool. there are 2 partition logic  1. Horare's Partition Scheme  2. Lomuto's Partition Scheme , This is used for Kth order statistics, example 3rd Highest or Lowest element in the given list.