Posts

All about forward_list STL in c++ for competitive programming( initialization, traversal and methods/functions ) :

forward_list STL Important Points: It is a sequence container that allows constant time insert and erase operations anywhere within the container. It is same as the singly linked list in c but with a huge advantage of availability of direct functions/methods for many operations. Its objects can only be iterated in one direction i.e forward because of single link. Remember to use the header file #include<forward_list> before using forward_list STL. forward_list vs other sequence containers: forward_list perform generally better in inserting, extracting and moving elements to any position within the container.  forward_list lacks direct access to elements by their position. For example - to access the 6th element in it one has to iterate from beginning to that position.   list vs forward_list: forward_list is very similar to list and the main difference being is, in list elements can be iterated in from both directions i.e forward and backward. forward_list is less bulky th

All about list STL in c++ for competitive programming( initialization, traversal and methods/functions ) :

list STL Important Points: It is a sequence container that allows constant time insert and erase operations anywhere within the container. It is same as the doubly-linked list in c but with a huge advantage of availability of direct functions/methods for many operations. Its objects can be iterated in both directions i.e forwards and backwards. Remember to use the header file #include<list> before using list STL. List vs other sequence containers: List perform generally better in inserting, extracting and moving elements to any position within the container.  List lacks direct access to elements by their position. For example - to access the 6th element in it one has to iterate from beginning to that position.   list vs forward_list: list is very similar to forward_list and the main difference being is, in forward_list elements can only be iterated in one direction. list consumes some extra memory compared to forward_list because of double linking. list is used much in so