Category: STL

Print Adjacency List for a Directed Graph

An Adjacency List is used for representing graphs. Here, for every vertex in the graph, we have a list of all the other vertices which the particular vertex has an edge to.Problem: Given the adjacency list and number of vertices and edges of a graph, the task is to represent the adjacency list for a […]

Continue Reading

push_back() vs emplace_back() in C++ STL Vectors

push_back() vs emplace_back() in C++ STL VectorsIn C++, vectors are dynamic arrays, that can grow or shrink and their storage is handled by the container itself. There are two ways of inserting an element in a vector. They are push_back() and emplace_back(). In this article, we will discuss the difference between them.push_back():This method is used […]

Continue Reading