Algorithms and datastructure preparation


Algorithms and data-structure preparation.

Each class has a corresponding Test class eg.

Class -> BinaryTreeHeight 
Test class -> BinaryTreeHeightTest

Tree Algorithms

  • Tree Traversal - Preorder, PostOrder, InOrder, LevelOrder.
  • BinaryTreeHeight - Evaluate the height of the binary tree.
  • BinaryTreeMaxElement - Find max element in a binary tree.
  • BinaryTreeSearchElement - Search and element in a binary tree.
  • BinaryTreeInsertElement - Insert an element in a binary tree.
  • BinaryTreeSize - Size of the Binary tree.
  • BinaryTreeLevelOrderReverseTraverse - Traverse in reverse level order (reverse BFS)
  • BinaryTreeDeepestNode - 1) Get the deepest node in binary tree. 2) Get the parent of the deepest node.
  • BinaryTreeDeleteNode - Swap the node to be deleted with the deepest node. Make deepest node null.

Two Pointer Algorithms

  • MergeSortedArrays - Merge Two sorted arrays.
  • CheckSortedArrayContainsPairWithGivenSum - Given a sorted array and a number N, find pair of indices (i,j) in array such that their sum = N.