Lunes, Disyembre 12, 2011

data structure application

LINK LIST APPLICATION

http://www.cmpe.boun.edu.tr/~akin/cmpe223/linked_list/chap3_1.htm


QUEUES
 http://www.google.com.ph/imgres?imgurl=http://www.vceit.com/SD/queue.jpg&imgrefurl=http://www.vceit.com/SD/Queues-Stacks.htm&h=300&w=400&sz=35&tbnid=aV3HDEIiUo2__M:&tbnh=90&tbnw=120&prev=/search%3Fq%3Dqueues%2Bimage%26tbm%3Disch%26tbo%3Du&zoom=1&q=queues+image&docid=ekqgah_bX62bVM&hl=tl&sa=X&ei=Db7mTu2ZBqfMmAXszJW-Cg&ved=0CCIQ9QEwAQ&dur=1574




STACKS



http://www.mathsisfun.com/games/towerofhanoi.html



ARRAYS



http://leepoint.net/notes-java/examples/games/five/five.html

Reflection in Prelim Topics

Linked list-Data structure composed of nodes, each node holding some information and a reference to another node in the list.





Singly-linked list is a list of elements in which the elements of the list can be placed anywhere in heap memory. All of list elements are linked together with each other using an explicit link field, that is, by storing the address of the next element in the link field of the previous element. Singly-linked list has a dynamic size and its size can be determined at run-time not compile time. Here the picture which demonstrate a singly-linked list. Their are four elements in the list. The head pointer is the pointer pointing to the first element of the list.





doubly-linked list-A doubly-linked list is a linked data structure that consists of a set of data records, each having two special link fields that contain references to the previous and to the next record in the sequence.


Doubly-linked-list.svg








Arrays-

Array by definition is a variable that hold multiple elements which has the same data type.
Declaring Arrays

We can declare an array by specifying its data type, name and the fixed number of elements the array holds between square brackets immediately following the array name.

The following illustrates how to declare an array:

1 data_type array_name[size];



For example, to declare an array that contains 100 integer numbers you can do as follows:

1 int a[100];



You must follow the rules below when you declare an array in C:
The data type can be any valid C data types including C structure and union.
The name of an array has to follow the rule of C variables.
The size of array has to be a positive constant integer.
Initializing Arrays

It is like a variable, an array can be initialized. To initialize an array, you provide initializing values which are enclosed within curly braces in the declaration and placed following an equals sign after the array name.

Here is an example of initializing an array of integers.

1 int list[5] = {2,1,3,7,8};


Accessing Array Element

You can access array elements via indexes like array_name[index].

Indexes of array starts from 0 not 1 so the highest elements of an array is array_name[size-1].
Array and Pointer

An array is a pointer to the 0th element of the array. When you deference the array name you will get the 0th element. This give us the possibility of accessing array's element not only via index but also via pointer.

It is note that the array is treated as constant so you can only modify the values in the array but not array itself.











Queues- are dynamic collections which have some concept of order. This can be either based on order of entry into the queue - giving us First-In-First-Out (FIFO) or Last-In-First-Out (LIFO) queues. Both of these can be built with linked lists: the simplest "add-to-head" implementation of a linked list gives LIFO behavior. A minor modification - adding a tail pointer and adjusting the addition method implementation - will produce a FIFO queue.




Stacks- a stack is a last in, first out (LIFO) abstract data type and linear data structure. A stack can have any abstract data type as an element, but is characterized by only three fundamental operations: push, pop and stack top. The push operation adds a new item to the top of the stack, or initializes the stack if it is empty. If the stack is full and does not contain enough space to accept the given item, the stack is then considered to be in an overflow state. The pop operation removes an item from the top of the stack. A pop either reveals previously concealed items, or results in an empty stack, but if the stack is empty then it goes into underflow state (It means no items are present in stack to be removed). The stack top operation gets the data from the top-most position and returns it to the user without deleting it. The same underflow state can also occur in stack top operation if stack is empty.