2.Continued fractions A real number 0 < x < 1 can be successively
approximated in a
continued
fraction with 1/a1, 1/(a1+1/a2), 1/(a1+1/(a2+1/a3)), ...
where a1, a2, a3, ... are natural numbers. In the initial
approximation, a1 is ⌊1/x⌋, and one continues using the
same rule for the fractional part of the denominator approximated with
a1, etc. One obtains a sequence of rational numbers p1/q1,
p2/q2, ... that approximate x increasingly well, alternating from above
and below.
Define a structure that represents a rational number and compute (recursively)
the nth rational approximation of a fractional number x
using a continued fraction.
3.Prime factors. Define a data structure to represent an unsigned number as a product of powers of primes. Write a function that computes the product of two numbers, in the same representation.
4.Predicate formulas. A formula in predicate logic is
2. Write a function nodup that takes an (integer) list and returns a list with all consecutive duplicates removed.
3. Count the number of segments in a list such that all elements in a segment have the same value and consecutive segments have distinct values.
4. Define a type that can hold a set of alphanumeric characters (both uppercase and lowercase) represented on a 64-bit word and the basic operations on it.
5. Mergesort Write a function that sorts an integer list: 1) split it into two (almost) equal parts; 2) recursively sort the parts; 3) merge the sorted parts, by repeatedly choosing the smallest of the two values at the front of each list. Free all temporary allocated data (using decons from intlist.h).