c17f98t2

c17f98t2 - CSc 17 Test 2 Friday 13 November 1998 Page 1

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSc 17 Test 2 Friday 13 November 1998 Page 1 >>>>>>>>>>> Answers <<<<<<<<<<<<<<<<<<<<<<< 1. (15 pts) In writing the function below, I forgot to provide the documention. Provide it by stating the pre- and post-conditions. The function assumes the class Node, which is defined as follows: class Node{ public: int key; Node * next; }; void enigma(Node * head, int x, int &c){ if(head!=NULL){ if(head->key > x) c++; enigma(head->next,x,c); } } PRECONDITIONS: head is NULL or points to a valid node. Valid nodes either point to NULL or to a valid node. The variable c has some value, x has some value POSTCONDITIONS: c has been increased by the number of nodes whose keys exceed x. 2. (25 pts) Write a bool function, dup, such that the call dup(head) returns the value true if and only if the linked list to which head points has two consecutive keys which are equal. Assume that head is declared as Node * head, as where Node is the class defined in question 1. Of course, you can assume that the last link...
View Full Document

Page1 / 3

c17f98t2 - CSc 17 Test 2 Friday 13 November 1998 Page 1

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online