User Tools

Site Tools


haas:fall2014:common:data:llkatocode


Corning Community College


Data Structures


Linked List Knowledge Assessment: From Pictures to Code

Rules

Open resource, closed person- do not communicate with anyone other than the instructor regarding material contained therein.

This is not take home- this is to be done during sanctioned times in the LAIR. If you do not finish, you may be able to resume work on following days (but note there may be additional content on following days).

There is the possibility of being asked to write code, debug, or draw diagrams– all related to content and concepts we have covered.

Reference Code

You may utilize the reference code (if needed) from the first part of the knowledge assessment, replicated here:

Node Struct

1
struct node {
    int value;
    struct node *next;
    struct node *prev;
};

List Struct

1
struct list {
    struct node *start;
    struct node *end;
};

create() function

1
struct node *create()
{
    struct node *tmp;
    tmp = (struct node *) malloc (sizeof(struct node));
    tmp -> prev = tmp -> next = NULL;
    tmp -> value = -1;
    return(tmp);
}

func1() function

1
struct node *func1(int val)
{
    int i = 0, old = 0;
    struct node *tmp, *tmp2;
 
    tmp = tmp2 = create();
 
    tmp -> value = 1;
 
    for(i = 0; i < val; i++)
    {
        tmp2 -> next = create();
        tmp2 -> next -> value = tmp2 -> value + old;
        old = tmp2 -> value;
        tmp2 = tmp2 -> next;
    }
    tmp2 -> next = tmp;
 
    return(tmp2 -> next);
}

func2() function

1
struct node *func2(int val)
{
    int i = 0;
    struct node *tmp, *tmp2;
 
    tmp2 = create();
    tmp = tmp2;
 
    tmp -> value = val;
 
    while (i < val)
    {
        tmp -> next = create();
        tmp -> next -> value = i;
        tmp = tmp -> next;
        i++;
    }
    return(tmp2);
}

func3() function

1
struct node *func3()
{
    struct node *tmp, *tmp2;
    tmp = tmp2 = create();
    tmp2 -> next = create();
 
    tmp -> next -> prev = tmp2;
 
    return(tmp);
}

func4() function

1
struct node *func4(struct node *tmp)
{
    while (tmp -> next != NULL)
    {
        tmp = tmp -> next;
    }
    return(tmp);
}

Item 0x4

Provide the code that will recreate the linked data structure represented here:

Item 0x5

Provide the code that will recreate the linked data structure represented here:

Item 0x6

Provide the code that will recreate the linked data structure represented here:

Submission

Your produced output from this activity will be logically accurate code (C, pseudo code, etc.) of various linked data structures.

As such, before leaving, please hand in any such papers– even if not done, for there may be additional opportunities to work on it in future days.

haas/fall2014/common/data/llkatocode.txt · Last modified: 2013/10/04 13:44 by 127.0.0.1