Algorithms Practice

To-Do List

References

Common Packages and Methods

In a BST parent, left nodes contain larger values or a right node contain smaller values

Delete Operation

  1. Node to be deleted is the leaf:
    • Simply remove from the tree.
  2. Node to be deleted has only one child:
    • Copy the child to the node and delete the child
  3. Node to be deleted has two children:
    • Find inorder successor of the node. Copy contents of the inorder successor to the node and delete the inorder successor. Note that inorder predecessor can also be used.

Visualizing BST (Not Required)

Required Methods

[Problem] Given a Binary Tree, print left view of it. Left view of a Binary Tree is set of nodes visible when tree is visited from left side.

BST Playground

Undirected Graphs

Depth First Search (DFS)

Breadth First Search (BFS)

Directed Graphs

Dijkstra's algorithm (Shortest Path from source to all vertices)

Given a graph and a source vertex in the graph, find shortest paths from source to all vertices in the given graph. Works only on Positive Weighted Graphs.

Resources