The Fibonacci sequence is a sequence Fn of natural numbers defined recursively: F0 = 0 F1 = 1 Fn = Fn-1 + Fn-2, if n>1 Write a function to ge
Continue ReadingC++: Delegates
A delegate is a helper object used by another object. The delegator may send the delegate certain messages, and provide a default implementation when
Continue ReadingC++: Hailstone Sequence
The Hailstone sequence of numbers can be generated from a starting positive integer, n by: If n is 1 then the sequence ends. If n is even then
Continue ReadingC++: Insertion Sort
#include <algorithm> template<class Iterator> void insertion_sort( Iterator a, Iterator end ) { std::iter_swap( a, std::min_ele
Continue ReadingC++: Check That File Exists
In this task, the job is to verify that a file called "input.txt" and the directory called "docs" exist. This should be done twice: once for the curre
Continue ReadingC++: Heap Sort
#include <algorithm> // for std::make_heap, std::sort_heap template <typename Iterator> void heap_sort(Iterator begin, Iterator en
Continue ReadingC++: Ackermann Function
The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows ver
Continue ReadingC++: Mutual Recursion
Two functions are said to be mutually recursive if the first calls the second, and in turn the second calls the first. Write two mutually recursive
Continue ReadingBest C++ Books
Reference Style - All Levels A Tour of C++ (Bjarne Stroustrup) The "tour" is a quick (about 180 pages and 14 chapters) tutorial overview of all
Continue ReadingC++: Binary Digits
The task is to output the sequence of binary digits for a given non-negative integer. The decimal value 5, should produce an output of 101 The deci
Continue Reading