NAME: LAB TIME:
WPI BOX NUMBER:
1.5em 1.5em
This is a closed book (and notes) examination. Answer all questions on the exam itself. Take the number of points assigned to each problem and the amount of space provided for your answer as a measure of the length and difficulty of the expected solution. The exam totals 100 points.
SCORE:
<>
's what type of searching (linear, binary, hashing) is done?
Answer all that apply.
4 8 7 6 1
typedef unsigned int Set; Set s, t; InitSet(s); InitSet(t); AddMember(s, 3); AddMember(s, 5); AddMember(s, 9); AddMember(t, 5); AddMember(t, 4); AddMember(t, 1); AddMember(t, 9); PrintSet(s); PrintSet(t); PrintSet(Union(s, t)); PrintSet(Intersect(s, t)); PrintSet(Difference(s, t)); DeleteMember(t, 5); DeleteMember(t, 7); PrintSet(t);
Now assume the Set abstraction is implemented as a bit vector where the setting the ith bit indicates the value i is in the set. Show how the AddMember() operation is defined.
5011 2021 3033 6544 3237 7777
What would the tree look like if the node 2021 were deleted from the tree?
Indicate which sort corresponds to each performance line in the graph (circle a sort) for parts a-d and answer the questions in parts e and f.
int Mystery(char *pch) { if (*pch == '\0') return(0); else if (strlen(pch)%2 == 1) return(1 + Mystery(pch + 1)); else return(Mystery(pch + 1)); }
typedef struct treetag { char chNode; /* value of the node */ struct treetag *pTreeLeft; /* pointer to leftmost child */ struct treetag *pTreeNext; /* pointer to next sibling */ } TreeNodeType;
int CountChildren(TreeNodeType *pTreeRoot, char chValue) /* your code goes here */