Assignment 3 FAQ

This page was last updated: 09:21 Sunday, 18 October, 2015 by cs1917.hw3@cse.unsw.edu.au

  1. What's up with the submission time?

    Whoops! It was accidentally set to 11:59 instead of 23:59. I apologise for the confusion.

  2. Can you give us some hints on how to get started?

    It is a good idea to keep the linked list functions in a separate file, modeled on list.c, but with a different name (for example, imglist.c). You will also need a corresponding "header" file (for example, imglist.h). This header file can be modeled on list.h, but you will need to modify the struct definition so that, instead of just an int, it contains all the information needed for each image (filename, dimension, quad tree, etc.)

    The header files quadtree.h and imglist.h will both need to be #include'd in imglist.c and hw3.c. You might also like to move the following line from hw3.c to imglist.h:

    #define MAXLLENGTH    200
    

    When an image is added, the command entered by the user will consist of the letter 'a', followed by a space, followed by the filename. You will need to extract the filename and copy it into the "filename" string of your newly-created linked list node structure - either character-by-character, or using a library function like sscanf().

    If you are copying code from list.c to imglist.c, it is a good idea to only copy one or two functions at a time, and modify them as needed. For Stage 2 you will need versions of makeNode(), insert() and printList(). Remember that, whenever a new image is added, it should be added at the "tail end" of the linked list.

  3. My program causes a Segmentation Fault

    First, change your Makefile so it compiles using dcc instead of gcc. When you run the program, it will (hopefully) warn you when you have not allocated space correctly, causing two arrays or structures to overlap in memory.

    If that doesn't help, try using gdb, like this:

    1. change your Makefile so it compiles with the -g option, e.g.
      CFLAGS = -Wall -g
      
    2. after running make, type
      gdb hw3
      
      then type
      run
      
      and enter the input as normal. When the program crashes, it will tell you where it crashed, and allow you some other options.

  4. Can you give us any hints about rotation and reflection?

    If the node is NULL then there is nothing to do. If it is not NULL, then rotation can be achieved by:

    1. recursively rotating each of the four sub-images, then
    2. permuting the subimages so that
      what was ne becomes nw, what was se becomes ne,
      what was sw becomes se, what was nw becomes sw.


Back to Assignment 3 | Back to the main page