User Tools

Site Tools


haas:fall2012:common:data-a03-20121116132500

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?

  1. e: 16, char func2(int, char);
  2. e: 27, int func2(int);
  3. e: 16, char func2(int, int, char);
  4. 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?

  1. Add “struct node *prev;” inside the struct
  2. Add “Node *right;” inside the struct
  3. Add “typedef node struct Tree;”
  4. 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?

  1. 5
  2. 4
  3. 3
  4. 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?

  1. 5
  2. 4
  3. 3
  4. 1
haas/fall2012/common/data-a03-20121116132500.txt · Last modified: 2012/11/16 12:38 by 127.0.0.1