Skip to content

Latest commit

 

History

History

Grapahs

most commonly used representations of a graph.

  1. Adjacency Matrix - 2D array be adj[][]
  2. Adjacency List -

Repesenting a Graph using class vs vector

Vectors ( dynamic arrays) - Vector is template class and is C++ only construct whereas arrays are built-in language construct and present in both C and C++.

  • Vectors, unlike arrays, are resizable as they grow and shrink being allocated ono heap memory.
  • Arrays have to be deallocated explicitly if defined dynamically whereas vectors are automatically de-allocated from heap memory if the varable goes out of scope.

some of the other STL containers:

  • std::vector,
  • std::set,
  • std::list.

Vector pair vs Map

  • Vector are good for small scale, all the memory in a vector is always contiguous. However for large scale finidng an elemnt in map takes fewer operations.

Todo : Cyclic finindg Tolopological soirt bipartite priority queuss