Simple C++ Programs

This section contains simple C++ programs that are typically asked in technical interviews. The questions have been gleaned from various sources on the web. Solutions were coded and tested on a development environment consisting of a laptop running 64-bit Windows 7 home premium edition, MinGW g++ compiler and Eclipse IDE. Each code snippet can be compiled and executed independently without dependency on other files. This has been deliberately done to be instructive. 

Even though these programs are quite simple, they cover some of the very basic data structures and algorithms in computer science.

The programs have been organized as follows:

Simple C++ Programs

Arrays and strings

Basic string functions

Check for string rotation

Check if anagram

Check if unique chars

Compress string

Convert integer to string

Convert string to integer

Replace space with %20

Reverse a string

Reverse Polish Notation calculator

Reverse words

Zero out rows and columns

Graphs and Trees

Check for Path in a Directed Graph

Implement a binary tree

In-order Successor

Test if sub-tree

Lists, queues and stacks

Check if linked list is a palindrome

Delete duplicates in linked list

Delete specified node from linked list

Find start of loop in linked list

Implement linked list

Nth node from last in linked list

Partition a linked list

Recursion

Combinations of string

Combinations of string - k at a time

Count ways to climb steps

Find path in maze

Paint fill function

Permutations of string

Permutations of string - k at a time

Permutations with parenthesis

Ways of making change