 You are not allowed to use loop constructs like while, for..etc, and you can only use the following ADT functions on Stack S:

isEmpty(S)
push(S)
pop()

Solution
The idea of the solution is to hold all values in Function Call Stack until the stack becomes empty. When the stack becomes empty, insert all held items one by one at the Read More →

Problem
Implement a function that checks whether a positive number is a palindrome or not. For example, 121 is a palindrome, but 123 is not.
Sollution
It is easy to check whether a string is a palindrome or not - we can check whether the first character and the last one are identical, and then compare the second Read More →

Problem
If you have a 2 GB file with one string per line, which sorting algorithm would you use
to sort the file and why?
Solution
When an interviewer gives a size limit of 2GB, it should tell you something - in this case, it
suggests that they don¡¯t want you to bring all the data into memory
So what do Read More → Tris volumineux
Les algorithmes de tri doivent aussi être adaptés en fonction des configurations informatiques sur lesquels ils sont utilisés.On suppose que toutes les données sont présentes en mémoire centrale (ou accessibles en mémoire virtuelle). La situation se complexifie si l'on veut trier des volumes de données supérieurs à la mémoire centrale disponible (ou Read More →

#include "stdlib.h"
#include "stdio.h"
#include "stdbool.h"

// Fonction d'affichage
void affichage (int grille)
{
for (int i=0; i

Given an array of integers which is initially increasing and then decreasing, find the maximum value in the array.

Input: arr[] = {8, 10, 20, 80, 100, 200, 400, 500, 3, 2, 1}
Output: 500
Input: arr[] = {1, 3, 50, 10, 9, 7, 6}
Output: 50
Corner case (No decreasing part)
Input: arr[] = {10, 20, 30, 40, 50}
Output: 50

Dynamic Programming – Cutting Rods
This problems is presented in Introduction to Algorithms as an intro to Dynamic Programming.
Given a rod of length n inches and a table of prices pi for rod lengths: i = 1, 2, ... n, determine the maximum revenue rn obtainable by cutting up the rod to pieces and selling them.

PROBLEM
write a code to reverse a C-Style String - ( C-String means that “abcd” is represented as five characters, including the null character )
EXCLUSIVE DISJUNCTION or EXCLUSIVE OR is a logical operation that outputs TRUE whenever both inputs differ (one is true, the other is false)
The XOR swap is an algorithm that uses the XOR Read More →

Given a set of time intervals in any order, merge all overlapping intervals into one and output the result which should have only mutually exclusive intervals. Let the intervals be represented as pairs of integers for simplicity.
For example, let the given set of intervals be {{1,3}, {2,4}, {5,7}, {6,8} }. The intervals {1,3} and {2,4} Read More →

In mathematics, the sieve of Eratosthenes, is a simple, ancient algorithm for finding all prime numbers up to any given limit. It does so by iteratively marking as composite (i.e. not prime) the multiples of each prime, starting with the multiples of 2.

Algorithm description
A prime number is a natural number which has exactly Read More →

RSA is a cryptosystem, which is known as one of the first practicable public-key cryptosystems and is widely used for secure data transmission. In such a cryptosystem, the encryption key is public and differs from the decryption key which is kept secret.
In RSA, this asymmetry is based on the practical difficulty of factoring the product Read More →

A permutation, also called an “arrangement number” or “order,” is a rearrangement of the elements of an ordered list S into a one-to-one correspondence with S itself. A string of length n has n! permutation.
Source: Mathword(http://mathworld.wolfram.com/Permutation.html)
Below are the permutations of string ABC.
ABC, ACB, BAC, BCA, CAB, CBA
Here is a solution using backtracking.

These permute2 values themselves Read More →

Someone posed an interesting probelm over at sitepoint the other day.
Given an array of words how can you work out each possible combination?
There are a few methods but here's the PHP code for the cleanest:

\$words = array('red', 'blue', 'green');
\$num = count(\$words);

//The total number of possible combinations
\$total = pow(2, \$num);