COMP 1917 Computing 1
Session 2, 2016

Lab - Week 13


This lab will be devoted to preparing for the prac exam. There are no marks allocated for this lab.

Here are a few sample questions:

  1. Write a function void shift_right(int* array, int n) which shifts every single element of the array one position to the right, with the rightmost element being wrapped around to the leftmost position. For example, if values initially contains the integers [1, 2, 3, 4, 5], once the code has executed it would contain [5, 1, 2, 3, 4].

  2. Write a function void sanitize(char *s) that removes duplicate characters from the string. For example, given a string "crazyfortruffle" the returned string should be "crazyfotule".

  3. Write a function char * twentify(char s[]) that give a string will replace all spaces with '%20'.

    For the following two tasks you can use these stub files

  4. Write a function Lnode *backToFront (Lnode * head) that given a list of nodes takes the node at the end of the list and moves it to the front of the list by changing pointers, leaving the relative order of the other nodes unchanged. This function must not create new nodes or change the value field of existing nodes.

  5. Given an unsorted linked list, and without using a temporary buffer, write a function Lnode *removeDuplicates (Lnode *head) that will delete any duplicates from the linked list.

Note: It will be specified in each question whether or not you are allowed to use library functions from string.h or ctype.h for that question. If it is not mentioned, you may assume it is ok to use them.