User Tools

Site Tools


opus:fall2012:thakes3:datapart2

data Keyword 2

array vs. linked list (pros/cons)

Definition

An array is a simpler, easier format for multiple value storage. You do not need to go threw the list in an array, you can use that element of the array. Linked lists have no benefits.

data Keyword 2 Phase 2

stack pop operation

Definition

Stack is a data structure that is used to keep things in order. A stack allows adding and removing items in order. When something is added to the stack it goes to the top of the stack, and the first item added to the stack is the last item to be removed.Pop is the operation used to remove an item from a stack.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • Wikipedia
  • class
  • c book

Demonstration

Demonstration of the indicated keyword.

This is an edited version of the code on wikipedia. <code c> void push(STACK head, int value) {

  STACK *node = malloc(sizeof(STACK));  /* create a new node */

if (node == NULL){

      printf("Error: no space available for node\n");
      abort();
  } else {                                    
      node->data = value;
      node->next = empty(*head) ? NULL : *head; /* insert new head if any */
      *head = node;
  }

} </code>

opus/fall2012/thakes3/datapart2.txt · Last modified: 2012/10/31 17:35 by thakes3