Computer programming - Lab 10

Topics for the lab 1. Matrix multiply Write a function that multiplies two matrices given as parameters, using dynamic allocation for the result.

2. Splitting into words Write a function that splits a string into words (strings with no whitespace), returning an array of pointers to copies of the words in the string.

3. Sort text lines Read text until end of input, splitting lines longer than 255 characters. Store the text in memory as array of pointers to lines. Each line is stored as a length-prefixed string: there is no '\0' terminator, but the first byte of a string stores its length. Sort the strings in increasing order of their lengths, breaking ties in alphabetical order.

4. Fibonacci strings. Fibonacci strings are defined as follows: S0 = 0, S1 = 01, Sn = Sn-1Sn-2 (concatenation).
Write a function that takes an unsigned n and returns Sn. Use at most n allocations and copy operations.

5. Mergesort Write a function that sorts an array: 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 sequence. Free all temporary allocated data.


Marius Minea
Last modified: Wed Nov 26 22:30:00 EET 2014