This is a closed-book, in-class exam. Put your answers in the blue book, and label your work appropriately. Explain your answers clearly.
#include#define salmon(a) (a=b) int guppy( int, int ); void walleye( int, char * ); void carp( char *, char * ); int herring( int, int ); int flounder( int, int ); void main() { char this[100] = "wish"; char that[100] = "clam"; char theOther[100] = "oyster"; int someNumber; /* Section 1 */ printf( "guppy: %d\n", guppy( 1, 2 ) ); /* Section 2 */ someNumber = 5; walleye( someNumber, this ); printf( "walleye: %d %s\n", someNumber, this ); /* Section 3 */ carp( that, theOther ); printf( "carp: %s %s\n", that, theOther ); /* Section 4 */ printf( "herring: %d\n", herring( 3, 4 ) ); /* Section 5 */ printf( "flounder: %d\n", flounder( 5, 6 ) ); } int guppy( int a, int b ) { return( a == b ); } void walleye( int a, char *b ) { a = 6; b[0] = 'f'; } void carp( char *a, char *b ) { a = b; } int herring( int a, int b ) { return( (a > b) ? 0 : 1 ); } int flounder( int a, int b ) { salmon( b ); return( a + b ); }
Add('A'), Add('N'), Delete, Add('O'), Delete, Add('S'), Add('T'),
Delete, Add('R'), Add('I'), Delete, Add('C'), Add('H')
what is the state of the queue? That is, show the contents of each of the 6 slots in the array, and the values of front and back.
typdef struct CharNode
{
char c;
struct CharNode *next;
} CharNode;
Write the function int StringLength( CharNode *string ) that returns the length of the given string.
Consider the following function.
void MysteryFunction( char s[] )
{
int i;
char c;
stack theStack;
Initialize( &theStack );
for( i=0; s[i] != '\0'; i++ )
Push( &theStack, s[i] );
while( !IsEmpty( theStack ) )
{
c = Pop( &theStack );
putchar( c );
}
}
void Traverse( BSTNode *root )
{
if( root != NULL )
{
Traverse( root->left );
Traverse( root->right );
printf( "%d ", root->key );
}
}
If you call Traverse with the root of the tree you built in the previous problem as its argument, what output do you get? I will grade this problem based on the tree you actually wrote down on the previous problem, whether that problem was correct or not.