User Tools

Site Tools


opus:fall2012:smalik2:datapart2

data Keyword 2

doubly linked list

Definition

A doubly linked list a a method of storing data.
The manner in which the data is stored is by a series of structs. There will be a variable that will always point to the first struct, and if you want there can be one to always point to the last struct.
Every struct has a minimum of three variables contained within - the data value, a pointer to the struct after it, and a pointer to the struct before it. These pointers is how one will navigate these structs, it is how they are linked together.

References

No references for this keyword.

data Keyword 2 Phase 2

linked list

Definition

A linked list is a data structure consisting of a group of nodes which together represent a sequence. Under the simplest form, each node is composed of data and a link to the next node in the sequence; more complex variants add additional links. This structure allows for efficient insertion or removal of elements from any position in the sequence.

References

Demonstration

Demonstration of the indicated keyword.

Plenty of linked list demos in my repo.

  5 void FillList(Node **start)
  6 {
  7     char input;
  8     Node *tmp;
  9     tmp=(*start);
 10     tmp == NULL;
 11     printf("Enter a value (-1 to end): ");
 12     scanf("%hhd", &input);
 13 
 14     while(input != -1)
 15     {
 16         if (tmp == NULL)
 17         {
 18             tmp=(Node*)malloc(sizeof(Node));
 19             tmp->value=input;
 20             tmp->next=NULL;
 21             tmp->prev=NULL;
 22             *start=tmp;
 23         }
 24         else
 25         {
 26             tmp->next=(Node*)malloc(sizeof(Node));
 27             tmp->next->value=input;
 28             tmp->next->next=NULL;
 29             tmp->next->prev=tmp;
 30             tmp=tmp->next;
 31         }
 32         printf("Enter a value (-1 to end): ");
 33         scanf("%hhd", &input);
 34     }
 35 }

This is a function that creates a linked list.

opus/fall2012/smalik2/datapart2.txt · Last modified: 2012/10/31 18:06 by smalik2