COMP 411: Lab X: Choose Your Own Adventure (Mini-Project)

Due Friday, April 20, 2018, 11:59 PM

This will be the last lab assignment. You are asked to choose ONE out of several assignments described below. You will complete the assignment in a little over two weeks (by Apr 20). You will do the program first in C, then in assembly in MARS.

NOTE: Your score on this assignment is worth 5% of the total score for the course. Your score on this assignment will NOT be dropped when computing the final course scores and letter grades. This lab is considered a mini-project, and worth approximately two labs. But one of your lowest lab scores from amongst Labs 1-10 will be dropped.

Extra Credit: You may choose to do more than one assignment from the list below. If so, your highest scoring one will be considered as the mini project, and any additional ones will be score for extra credit. There is no limit to how many assignments you can submit. Any extra credit awarded will not be directly added to your total score for the course. Instead, extra credit will be subjectively taken into account when letter grades are being finalized. If you total score is very near a letter grade cutoff, the instructor may bump your letter grade up if you have earned sufficient extra credit points.


Please choose one of the five assignments below, or propose your own. You may do extra assignments for extra credit.


Recursive Quick-Sort or Merge-Sort

Write a recursive implementation of quick-sort or merge-sort (or any other sorting method, but it must be recursive) for integers in increasing order. The input will consist of N, the number of integers to sort, followed by the integers to be sorted, one per line. The output will simply be the sorted list of integers, one per line.

TIP: The number of integers to sort, N, will not be more than 50.

Test Inputs, Due Date and Submission Procedure

Put your entire C program in one file named ex1.c. Put your entire MIPS program in one file named ex1.asm. While it may be helpful to partition your assembly code into multiple files during code development, please merge them all together into one file before submitting. Sample inputs and corresponding outputs are provided under /home/porter/comp411/samples/labX/sort. You should try running your program on the sample input files provided, and make sure the program's output is identical to that in the sample output files.

Put the C and assembly programs into a folder on classroom.cs.unc.edu, and then run the selfchecking and submit scripts as follows:

 % /home/porter/comp411/bin/comp411start
 % cd ~/comp411lab/labX
 % selfchecklabX-sort
 % submitlabX-sort

Due Date: Friday, April 20, 11:59 pm.


Towers of Hanoi

Write a recursive implementation of the Towers of Hanoi game. The input will be a small number, N, which represents the number of disks, numbered 1 to N. All the disks are initially on Peg 1 (source peg), and the goal is to have them on Peg 3 (target peg) at the end. Peg 2 is available for use (spare peg). The output will be a series of moves, one per line, which look like, "Move disk 3 from Peg 1 to Peg 2".

TIP: You do not need to maintain arrays or stacks for each of the pegs. My C code for the body of the recursive procedure is a total of 4 lines. As a hint, my implementation has the following declaration of the recursive procedure. Within the body of the procedure, the single disk that is actually moved is disk #N. You can find the algorithm here (see "Recursive solution").

    void hanoi(int N, int A, int B, int C)

Test Inputs, Due Date and Submission Procedure

Put your entire C program in one file named ex1.c. Put your entire MIPS program in one file named ex1.asm. While it may be helpful to partition your assembly code into multiple files during code development, please merge them all together into one file before submitting. Sample inputs and corresponding outputs are provided under /home/porter/comp411/samples/labX/hanoi. You should try running your program on the sample input files provided, and make sure the program's output is identical to that in the sample output files.

Put the C and assembly programs into a folder on classroom.cs.unc.edu, and then run the selfchecking and submit scripts as follows:

 % /home/porter/comp411/bin/comp411start
 % cd ~/comp411lab/labX
 % selfchecklabX-hanoi
 % submitlabX-hanoi

Due Date: Friday, April 20, 11:59 pm.


Picture Manipulation

Building on the PPM/PGM picture manipulation exercise of Lab 7, you are to implement rotation and blurring of PGM (grayscale only) pictures. Specifically, given an input PGM image on standard input, the output will be a PGM image that has been rotated 90 degrees clockwise, and each pixel has been "blurred" by replacing it with the average of the nine pixels in a 3x3 square centered on that pixel. Pixels that are on the four border lines are left untouched.

TIP: You can assume that the input picture will always be of size 64x64 pixels.

Test Inputs, Due Date and Submission Procedure

Put your entire C program in one file named ex1.c. Put your entire MIPS program in one file named ex1.asm. While it may be helpful to partition your assembly code into multiple files during code development, please merge them all together into one file before submitting. Sample inputs and corresponding outputs are provided under /home/porter/comp411/samples/labX/pgm. You should try running your program on the sample input files provided, and make sure the program's output is identical to that in the sample output files.

Put the C and assembly programs into a folder on classroom.cs.unc.edu, and then run the selfchecking and submit scripts as follows:

 % /home/porter/comp411/bin/comp411start
 % cd ~/comp411lab/labX
 % selfchecklabX-pgm
 % submitlabX-pgm

Due Date: Friday, April 20, 11:59 pm.


Simple Sort of Structures

In this exercise, you will implement sorting of records. Each record has two fields: a name (string) and an ID (number). Sort them in increasing order, first by name, then by ID number. That is, the records are sorted in increasing order by name, but if two records have the same name, then they are ordered based on the IDs. The first line of the input consists of N (the number of records contained in the input), followed by the records, with the name on one line and the ID on the next line.

Please use the following type definition for the records:

    typedef struct {
      char Name[20];
      int ID;
    } record;

A struct in C is similar to a public class in Java, except that structs in C do not have methods. Member objects of a struct are publicly accessible using the dot notation, e.g., A.Name and A.ID, where A is of type record defined above. You may use any sorting algorithm of your choice, whether recursive or simply iterative.

Your C code must define and use the struct definition of record as described above. You may NOT use separate arrays for Names and IDs. Instead, you must use an array of structs, largely as shown below:

    typedef struct {
      char Name[20];
      int ID;
    } record;

    record data[50];

TIP: You may assume that each Name field will fit within the 20 characters provided (including any newlines and null characters). You may also assume that the input will consist of at most 50 records. You are allowed to use standard C string functions (e.g., strcmp(), strcpy(), etc.).

Test Inputs, Due Date and Submission Procedure

Put your entire C program in one file named ex1.c. Put your entire MIPS program in one file named ex1.asm. While it may be helpful to partition your assembly code into multiple files during code development, please merge them all together into one file before submitting. Sample inputs and corresponding outputs are provided under /home/porter/comp411/samples/labX/struct. You should try running your program on the sample input files provided, and make sure the program's output is identical to that in the sample output files.

Put the C and assembly programs into a folder on classroom.cs.unc.edu, and then run the selfchecking and submit scripts as follows:

 % /home/porter/comp411/bin/comp411start
 % cd ~/comp411lab/labX
 % selfchecklabX-struct
 % submitlabX-struct

Due Date: Friday, April 20, 11:59 pm.


Postfix Arithmetic Interpretor

In this exercise you will write a simple interpretor (or calculator) that takes in inputs in Postfix Notation. Postfix is a less ambiguous way to express arithmetic operations than the traditional "infix" syntax.

Specifically, you will be given input files with multiple lines of postfix expressions. For each line of input, you will calculate the result and output a single line with this number.

You can make the following assumptions about the input:

In particular, we recommend the Left-to-right algorithm for evaluating postfix. This does require a simple stack data structure (not the same stack pointed to by $sp) to track numbers seen.

Test Inputs, Due Date and Submission Procedure

Put your entire C program in one file named ex1.c. Put your entire MIPS program in one file named ex1.asm. While it may be helpful to partition your assembly code into multiple files during code development, please merge them all together into one file before submitting. Sample inputs and corresponding outputs are provided under /home/porter/comp411/samples/labX/postfix. You should try running your program on the sample input files provided, and make sure the program's output is identical to that in the sample output files.

Put the C and assembly programs into a folder on classroom.cs.unc.edu, and then run the selfchecking and submit scripts as follows:

 % /home/porter/comp411/bin/comp411start
 % cd ~/comp411lab/labX
 % selfchecklabX-postfix
 % submitlabX-postfix

Due Date: Friday, April 20, 11:59 pm.


3 April 2018, Montek Singh, montek@cs.unc.edu
4 April 2018, Don Porter, porter@cs.unc.edu

Last updated: 2018-04-16 19:06:17 -0400 [validate xhtml]