Confidential Teaching Materials:
Quiz 1 Grading Criteria, Page 1 of 5
Quiz 4 Grading Criteria
Note: To receive any credit whatsoever, the date, your name, your student number, and your answers must
be legible and readily readable in the judgment of the grader.
Add brief explanatory comments as necessary to make sure your answers are clear and unambiguous
to the grader.
[p1] 15 points
Given the following module (for a linked list of numbers):
procedure Print_It(head isoftype in ptr toa ListNode)
if(head <> NIL) then
if(head^.next <> NIL) then
print(head^.next^.data)
Print_It(head^.next^.next)
endif
endif
endprocedure
head -> 2 -> 6 -> 4 -> 1 -> 8 -> 10 -> 17 -> nil
(9 points) What is the output of procedure Print_It when applied to the above linked list?
(6 points) What is the pattern? (Describe lgocial pattern in plain English.)
(Hint: draw a picture of the list and keep track of where head is currently pointing)
LINES=10
[c1] 1 points
[p2] 15 points
You have just been hired by the Registrar’s Office to help keep track of information about students. They need a
data structure to store information about this institution’s students. Your first task is to create the declarations
needed to store student data such that it can be stored in a linked list. The following student data is to be stored:
Name (example: John Doe)
Social Security Number (example: 123-45-6789)
Whether or not the student has financial aid
GPA (example: 3.0)
Confidential Teaching Materials:
Quiz 1 Grading Criteria, Page 2 of 5
LINES=36
[c2] 15 points
[p3] 30 points
You need a way to add new students to your linked list. Write a module that will expect to be passed a pointer to
the head of the list and an appropriate data record and will add the data to the linked list. The linked list is to be
maintained in alphabetical order by the student’s name. Repetition is to be handled by recursion. Don’t forget that
you can compare strings just as you can numbers! Example:
“alpha” < “beta”
LINES=51
[c3] 30 points
Confidential Teaching Materials:
Quiz 1 Grading Criteria, Page 3 of 5
Procedure Header: (8 pts)
2 pts for being a procedure (pro)
1 pt for data parameter (rec)
1 pt for data parameter of being proper type ( rec)
1 pt for being an in param (inp)
1 pt for pointer parameter (ptr)
1 pt for ptr being of appropriate type ListPtr (ptr)
1 pt for ptr being being an in/out param (inp)
Body: (22 pts)
2 pts for having a temp pointer ( ptr)
nil case (6pts)
2 pts for checking for nil (wrt, log)
1 pts for creating a new node ( nwp)
2 pts for correctly filling it with data (rec, log)
1 pt for setting head^.Next to nil (ptr)
insertion case (8pts)
2 pts for detecting correct place for insertion ( wrt,log)
1 pt for accessing data.Name correctly (rec)
1 pt for accessing head^.Data.Name correctly (ptr, rec)
1 pt for creating a new node ( nwp)
1 pt for correctly filling it with data ( rec)
1 pt for assigning temp^.Next <- head (ptr, log)
1 pt for assigning head <- temp ( ptr, log)
recursion (6pts)
2 pts for recursing at the right time (wrt, log)
1 pt for attempting the recursion ( rsr)
1 pt for data parameter (rsr)
2 pts for head^.Next parameter (rsr)
[p4] 40 points
A new scholarship has been created. Students with a GPA of 3.5 or higher are eligible to apply. We need to make
a list of all students who are eligible. Write a RECURSIVE module that:
expects to be passed the head of a list that is maintained in alphabetical order by name (one you created in p2).
returns a pointer to the head of a NEW list that contains a list of students with GPA better than or equal to 3.5.
(Hint: no need to sort the new list!)
LINES=51
[c4] 40 points
Solution model 1:
Confidential Teaching Materials:
Quiz 1 Grading Criteria, Page 4 of 5
New_List_Helper: (35 pts)
1 pt(x2) for having two parameters(npo)
1 pt for old_head being in (inp)
1 pt for new_head being in/out (iop)
Confidential Teaching Materials:
Quiz 1 Grading Criteria, Page 5 of 5
Solution model 2:
Solution model 3:
Solution models 2 and 3: