Exercises - Week 2

 
1.  Array Insertion

    Given an array of N elements of integers write a function to insert a new student in a particular index of the array, without deleting existing values; then write a function to remove an element in a particular index of the array, and move the following elements backward to fill the empty slot in the array.
Do the same with an array of struct student.
  
2.  Matrix product
      
The product of two matrixes A and B is a matrix P where each element P[i][j] is the scalar product of two arrays: the i-th row of A and the j-th column of B.
The scalar product of two arrays is the sum of the products of elements at the same index.
Note that the product can be calculated only if the number of columns of A is equals to the number of rows of B.

3. ADT

Implement the Queue, Stack, and List showed during lesson as a C library by defining their implementation and the header file.

4. Students and Files 

Read a text file containing students' information and create a data structure in memory.
Note that the length of the file is not known in advance.
Define functions for:
1. adding a student to the existing structure in memory;
2. deleting a student from memory given its ID number;
3. print on screen the current set of students;
4. sorting students by ID (use insertion-sort algorithm );
5. reading the data structure from a file and create it in memory.
6. saving the current data structure in a file.

Each line of the input file contains data (ID name surname) of one student separated by a blank (space):
123 Homer Simpson
456 Peter Griffin
119 Ken Shiro
325 Mickey Mouse
276 Eric Cartman
-------------------------------------------
Note1: See C language C recap slides or the "C language tutorial" for functions on files.
Note2: use the most recent C-99 standard on gcc compiler by setting the command line parameter: -std=c99