Catalan numbers are a sequence of numbers which can be defined directly: Or recursively: Or alternatively (also recursive):
Continue ReadingC++: Binary Search Tree Verification
struct TreeNode { int data; TreeNode *left; TreeNode *right; }; bool isBST(TreeNode *node, int minData, int maxData) { if(node == NULL
Continue ReadingC++: Determine if Only One Instance Is Running
This task is to determine if there is only one instance of an application running. If the program discovers that an instance of it is already running,
Continue ReadingC++: Find Common Directory Path
Create a routine that, given a set of strings representing directory paths and a single character directory separator, will return a string representi
Continue ReadingC++: Iterated Digits Squaring
If you add the square of the digits of a Natural number (an integer bigger than zero), you always end with either 1 or 89: 15 -> 26 -> 40 ->
Continue ReadingC++: Generate Random Number in Range
int random_in_range(int a, int b) //Function that returns a random integer between 2 provided integers { return a + random() % (b-a+1); }
Continue ReadingC++: Fast Fourier Transform
The purpose of this task is to calculate the FFT (Fast Fourier Transform) of an input sequence. The most general case allows for complex numbers at t
Continue ReadingC++: Constrained Random Points on a Circle
Generate 100 <x,y> coordinate pairs such that x and y are integers sampled from the uniform distribution with the condition that . Then display/
Continue ReadingC++: Split a string in C++
What’s the most elegant way to split a string in C++? The string can be assumed to be composed of words separated by whitespace. (Note that I’m
Continue ReadingC++: Count in Octal
The task is to produce a sequential count in octal, starting at zero, and using an increment of a one for each consecutive number. Each number should
Continue Reading