Week 10 Tutorial Questions

    Looking back

  1. In this week's lab please complete the myExperience survey for COMP1511.

    Previous feedback has changed the way we run weekly tests, and helped us re-arrange content in the course to be most useful. Your tutor may also have some examples of good feedback they have received.

  2. Your tutor has asked a lab pair to present their week 9 work.

    Discuss the good, the bad and the ugly aspects of their code.

    Please be gentle in any criticism - we are all learning!

  3. It's week 10! Well done on making it this far through the course, you've all worked very hard, and achieved some incredible results, and you should all feel proud about how far you've come in these ten short weeks.

    Take some time as a tute to look back over the term, and think about how it has been for you. What were your favorite parts? What things weren't so good? And perhaps most importantly, who/what are you grateful for?

  4. How are you progressing with the assignment?

    Do you have any questions? Have you learned anything that would be useful to share with the rest of the tutorial?

  5. Abstract Data Types

  6. What is an Abstract Data Type?

    What is the purpose of a Header file?

    What is the purpose of a Implementation file?

  7. I have two files, a list.h and a list.c that describe a particular form of list that I want to use.

    I then have a main.c that would like to use the functionality offered by the other two files.

    Which files need to #include the other files?


    What is the compilation command that will combine these files into a single program?

  8. Stacks

  9. What is a stack?

  10. Draw a diagram of a stack, if it was implemented by a Linked List. Show:

    • How the linked list is structured, with a head pointer and pointers between nodes
    • Any extra structure(s) that might be needed to manage the stack
    • What happens when a new object is added to the stack
    • What happens when an object is removed from the stack
  11. Will a stack always be implemented using a linked list?

  12. Please complete the provided matching_brackets.c program.

    Given a string containing only '(', ')', '[', ']', '{' and '}', the program will check that the given string is a valid bracket sequence.

    To be valid, the given string must satisfy the following:

    • All the brackets are in a matching pair, ie any opening bracket must have a matching closing bracket.
    • For each matching pair, the opening bracket must come before the closing bracket.
    • Each matching pair can only have complete matching pairs within it, ie it cannot have one half of another matching pair between its opening and closing bracket.

    For example:

            ./matching_brackets "[(){]()}"
            Invalid bracket sequence!
            ./matching_brackets "[[]](){()}"
            All brackets match!
        

    Hint: the provided stack.h and stack.c will be helpful!

    You have also been provided some helper functions which may be useful.

  13. Recursion

  14. What is recursion?

  15. Using an iterative approach, implement a function minimum which is given a linked list struct node *head, returns the minimum of the linked list as an integer.

    minimum should have this prototype:

    int minimum(struct node *head);
  16. Using a recursive approach, implement a function minimum which is given a linked list struct node *head, returns the minimum of the linked list as an integer.

    minimum should have this prototype:

    int minimum(struct node *head);
  17. Using an iterative approach, implement a function fibonacci which is an integer n, returns the nth fibonacci number.

    fibonacci should have this prototype:

    int fibbonacci(int n);
    
  18. Using a recursive approach, implement a function fibonacci which given an integer n, returns the nth fibonacci number.

    fibonacci should have this prototype:

    int fibbonacci(int n);
    
  19. Revision questions

    The remaining tutorial questions are primarily intended for revision - either this week or later in session.

    Your tutor may still choose to cover some of the questions time permitting.

    There are no revision questions as part of this tutorial. Instead, this week, we will release a revision section on the course website that will be a set of revision questions and exercises that cover the majority of the course content

/import/chopin/1/cs1511/public_html/21T1/public/tlb/questions/q-recursion.html /import/chopin/1/cs1511/public_html/21T1/public/tlb/questions/q-recursion.html