CPS 100, Spring 1997, Quiz 2
Due: January 22
Problem 1: Link'n Logs ( 4 points)
Linked lists of strings are implemented using the
definition Node below. Write the fuction
MinNode that returns a pointer to the node whose
info field is alphabetically first in the linked list.
struct Node
{
string info;
Node * next;
};
Node * MinNode(Node * list)
// precondition: list is NULL terminated
// postcondition: returns a pointer to the node whose info
// field is smallest (alphabetically), returns 0
// if list == 0
Problem 2: Oboy (3 points)
Consider a list of integers in which the integers are stored in
non-decreasing order and in which the integer k occurs exactly
k times; these lists are called N-lists where
N is the largest integer in the list. For example, a 4-list is
(1,2,2,3,3,3,4,4,4,4) and a five list is a 4-list with (5,5,5,5,5)
appended to the end.
Using big-Oh notation (in terms of N) what is the number of
elements in an N-list? Justify your answer briefly.
Owen L. Astrachan
Last modified: Mon Jan 27 10:29:50 EST