Week 08 Tutorial Questions

  1. The tutorial will start with a code review.

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

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

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

  2. Assignment 2 has been released - Beats by CSE. What is Beats by CSE and what can it do?

    Try out the reference Beats by CSE implementation: 1511 cs_beats.

  3. What are Tracks, Beats, and Notes? How are they used and how do they relate to each other?

  4. Have you learnt anything you think would be useful about CS bEats to share with the tutorial?

    Do you have questions that others in the tutorial may be able to answer?

  5. What is a struct?

    How does it differ from an array?

  6. How could we represent a student and their assignment 1 mark as a struct? What fields might we want to include?

  7. Create a

    struct student
    with the name "Gareth", zid of 5151515, assignment 1 mark of 60.2 in the main function (hint, you do not need functions or malloc).
  8. Create a struct student * with the name "Sally", zid of 5252525, assignment 1 mark of 71 using a function (hint, you will need to use malloc)

  9. Which of these structs is currently causing a memory leak and why?

    Use dcc --leakcheck to confirm this

  10. We have a struct student and a struct student *

    If we want to access the fields of these, when do we use . and when do we use ->?

  11. What is a linked list? How does it compare to an array? Which will you be using in assignment 2?

  12. Edit the existing struct student, to be able to point to another struct student.'

    Update your function which creates an instance of a student to account for this new pointer.

  13. Make a linked list to represent a class of students

  14. Create another struct definition and instance to represent the class.

    It should contain the name (i.e. M13A), the number of students and a pointer to the linked list you just made.

  15. Write a function to compare the marks of two students. It should return 1 if student a has higher marks than student b, -1 if student b has higher marks than student a, and 0 if they have the same mark. It should have the prototype

    int compare_marks(struct student student_a, struct student student_b)