Map containers in C++

Map containers stores values in the form of key and a value pair. Keys are unique and each key is associated with a value pair. Map is designed to access elements by their key. Map finds an element by their key in O(logn) time. The complexity for insert operation depends on the size of the map. Map is defined in standard template library(STL).
A complete and simple explanation of map can be found here.

I am posting here a simple program, which uses some basic functionalities provided by map class, such as creation of map, insertion of key and value pair, searching for a value and use of iterators etc… Continue reading “Map containers in C++”

Introduction to LaTeX

LaTeX is a document preparation system for high-quality typesetting. You can consider LaTeX as a system which does exactly what MS Word do, but in a different way with a lot of additional features and advantages. Inevitably there are two kinds of users, one who support MS Word, and other who support LaTeX.
I am supporting LaTeX, because LaTeX has the following Advantages over MS Word,

  • It enforces proper typesetting. The writer can concentrate more on content rather than the appearance of the document.
  • It is easy to modify documents written using Latex
  • LaTeX does not crash much and has low machine memory requirements.
  • Re-usability of the code written in LaTeX

This post gives a brief introduction to LaTeX. Continue reading “Introduction to LaTeX”

Sieve-of-Eratosthenes, Algorithm to find prime numbers up to an integer.

Sieve-of-Eratosthenes is a simple, efficient and fast algorithm for finding all prime numbers up to an integer number. This post explains Sieve-of-Eratosthenes algorithm, and its implementation in C language.

Algorithm & Flowchart

Input to Sieve-of-Eratosthenes algorithm is an integer number and output is all prime numbers which is less than the input number.

Sample Input : 10
Sample Output : 2, 3, 5, 7.

Continue reading “Sieve-of-Eratosthenes, Algorithm to find prime numbers up to an integer.”