October 22, 2002
Your name: ________________________________________
Your id: ________________________________________
Your score: __________ / 100
Open textbook (but no other books), open notes. No use of computers. There are 4 problems.
Who is your TA and what is the time of your recitation? Check one of the following ...
R012 M 1000AM-1115AM ECCH 105 Cyrus Hall R013 M 0100PM-0215PM ECCH 105 Damon McCoy R014 M 0300PM-0415PM ECCH 105 Cyrus Hall R015 M 0500PM-0615PM ECCH 105 Trevor Stone R016 T 0930AM-1045AM ECCH 105 Alan Schmidt R017 T 1100AM-1215PM ECCH 105 Alan Schmidt
could be turned into a “circular” list by making the last node point to the first node and the first node point to the last node like this:
Given a non-circular list with head pointing to its first node, write a piece of code that turns the list into a circular one.
A. length = 0;
for (current = head;
current->next != head;
current=current->next)
length++;
B. length = 1;
for (current = head;
current->next != head;
current=current->next)
length++;
C. length = 0;
for (current = head;
current != head;
current=current->next)
length++;
D. length = 1;
for (current = head;
current != head;
current=current->next)
length++;
E. length = 1;
for (current = head;
current->previous != head;
current=current->previous)
length++;