======Data Structures Knowledge Assessment======
=====Overview=====
We have been going full force with our explorations of linked lists these past few weeks. Just to make sure we are all retaining this information, please complete the following (via **gimmeh**), here in class, before 1:20pm.
=====0x0: Functions=====
Say we had the following:
#include "my_header.h"
int main()
{
char (*myfunc)(int, int, char);
int a, b, c, d;
char e, g;
char *f;
a = b = 0;
c = 23;
d = 72;
e = 16;
g = 36;
d = func1(a, b);
myfunc = &func2;
c = func3(func1(a, d), b);
g = myfunc(a, b, e + 11);
// <-- RIGHT HERE
return(0);
}
RIGHT HERE, what is the value of **e**, and what is the function prototype for **func2**?
- e: 16, char func2(int, char);
- e: 27, int func2(int);
- e: 16, char func2(int, int, char);
- e: 32, int func2(char, int, int);
=====0x1: List Nodes and Trees=====
Say we had the following (and JUST the following):
struct {
char value;
struct node *next;
};
How would you make this node suitable for a **binary tree**?
- Add "struct node *prev;" inside the struct
- Add "Node *right;" inside the struct
- Add "typedef node struct Tree;"
- Add "typedef Node *prev;"
=====0x2: Stacks=====
Say we had the following generic Stack Operations:
stacksize(4); // set stack size
push(3);
push(1);
push(4);
push(1);
push(5);
push(9);
What is the second value popped off the stack?
- 5
- 4
- 3
- 1
=====0x3: Queues=====
Say we had the following generic Queue Operations:
queuesize(4); // set stack size
enqueue(3);
enqueue(1);
enqueue(4);
enqueue(1);
enqueue(5);
enqueue(9);
What is the second value dequeued off the queue?
- 5
- 4
- 3
- 1