CS210 Lab: Queue Prelab

Prelab Questions:

The following are some questions that you can answer prior to the lab.
These questions are designed to refresh your memory on link lists. For more details on link lists see the following CS115 labs:
Introduction to C++ Pointers
Simple Linked Lists
Refer to the following diagram when answering the questions:

  1. Give the values of the following expressions
    1. ptr1->data
    2. ptr2->next->data
    3. head->next->next->data
  2. Are the following expressions true or false
    1. head->next == ptr1
    2. ptr1->next->data== 46
    3. ptr2->next == NULL
    4. head->data == 12
  3. Decide whether the syntax of each of the following statements is valid or invalid. If it is valid, mark it as such; if it is invalid, explain what is wrong.
    1. head->next = ptr1->next;
    2. head->next = *(ptr2->next);
    3. *head = ptr2;
    4. ptr2 = ptr1->next->data;
    5. ptr1->data = ptr2->data;
    6. ptr2 = ptr2->next->next;
  4. Write one statement to do each of the following:
    1. Make head point to the node containing 34.
    2. Make ptr2 point to the last node in the list.
    3. Make head point to an empty list.
    4. Set the data member of the node containing 34 to 45.

For Answers, click here
Back to Queue Lab click here

CS Dept Home Page
CS Dept Class Files
CS210 Class Files

Copyright: Department of Computer Science, University of Regina.