Provide code that produces a list of numbers which is the n-th order forward difference, given a non-negative integer (specifying the order) and a lis
Continue ReadingC++: Balanced Ternary
Balanced ternary is a way of representing numbers. Unlike the prevailing binary representation, a balanced ternary integer is in base 3, and each digi
Continue ReadingC++: Matrix Exponentiation Operator
Most programming languages have a built-in implementation of exponentiation for integers and reals only. Demonstrate how to implement matrix expone
Continue ReadingC++: Hofstadter-Conway $10,000 Sequence
The definition of the sequence is colloquially described as: Starting with the list [1,1], Take the last number in the list so far: 1, I'll ca
Continue ReadingC++: Single Inheritance
Inheritance is an operation of type algebra that creates a new type from one or several parent types. The obtained type is called derived type. It inh
Continue ReadingC++: Binary Search Tree Insertion
void insert(Node*& root, int data) { if (!root){ root = new Node(data); } else if (data < root->data){ insert(root->left,
Continue ReadingC++: Create a Two-Dimensional Array at Runtime
Get two integers from the user, then create a two-dimensional array where the two dimensions have the sizes given by those numbers, and which can be a
Continue ReadingC++ Code
[pt_view id="e30eb21e03"]
Continue ReadingC++: Normal PDF
const double Pi = 3.14159265359; // Standard Normal probability density function double Normal_PDF(const double & x) // Normal PDF(x) = e
Continue ReadingC++: Equilibrium Index
An equilibrium index of a sequence is an index into the sequence such that the sum of elements at lower indices is equal to the sum of elements at hig
Continue Reading