Tuesday, February 24, 2009

IT 123A-Queue

Concept;

A queue (pronounced /kjuː/) is a particular kind of collection in which the entities in the collection are kept in order and the principal (or only) operations on the collection are the addition of entities to the rear terminal position and removal of entities from the front terminal position. This makes the queue a First-In-First-Out (FIFO) data structure.
[1].>(google.com)http://en.wikipedia.org/wiki/Queue_(data_structure)

Illustration;







[2](google.com)http://images.google.com.ph/images?hl=en&q=Queue&um=1&ie=UTF-8&sa=N&tab=wi

Referrence;

http://www.google.com.ph/search?hl=en&q=Queue&meta=


Tuesday, February 17, 2009

IT 123A-Doubly Linked List

Concept;

Doubly Linked List-A more sophisticated kind of linked list is a doubly-linked list or two-way linked list. Each node has two links: one points to the previous node, or points to a null value or empty list if it is the first node; and one points to the next, or points to a null value or empty list if it is the final node...[1](google.com)-(http://en.wikipedia.org/wiki/Linked_list)...

Illustration;







Referrence;
http://www.google.com.ph/search?hl=en&q=Doubly+Linked+List&meta=
























Thursday, February 12, 2009

IT 123A-Double Ened

Concept;

Double-Ended LinkList- it is a first and last reference. It can be thearrangement of such qualities in every inputs that are available. (wiki,google)

Programer: Niel Jay F. Ehilla
Subject: Data Structure
Purpose: To know about Double-Ended LinkList

Code/Implementation;

public class Link{
private int idata;
private long ddata;
link next;

public Link (int nidata, long nddata){
iData=nidata;
dData=nddata;
}
}


public class FirstLastLink{
private LinkFirst;
private LinkLast;
public FirstLastLink(){
first=null;
last=null;
}
public boolean isEmpty(){
return(first&&last==null);
}
public void insertFirst(int nidata, long nddata){
Link newLink=new Link(nidata, nddata);
new.next=first;
first=newLink;
}
public void insertLast(int nidata, long nddata){
Link newLink=new Link(nidata,nddata);
newLink.next=last;
last=newLink;
}
public Link deleteFirst(int nidata, long nddata){
Link temp=first;
first=first.next;
return temp;
}
public Link deleteLast(int nidata, long nidata){
Link temp2=last;
last=last.next;
return temp2;
}
public void displaylist(){
System.out.print("The List(first--->last):");
Link current=first;
while(current!=null){
current.displaylink();
current=current.next;
}
Link current2=last;
while(current2!=null){
current2.displaylink();
current2=current2.next;
}
System.out.println(" ");
}
}

public class Apps{
public static void main(String[]args){

FirstLastList theList=new FirstLastList();

theList.insertFirst(001, 1,000,000);
theList.insertFirst(002, 2,000,000);
theList.insertFirst(003, 3,000,000);

theList.insertLast(09, 4,000);
theList.insertLast(25, 5,000);
theList.insertLast(28, 6,000);

System.out.println(theList);

theList.deleteFirst();
theList.deleteLast();

System.out.println(theList);
}
}

Reference;
http://www.google.com.ph/search?hl=en&q=doubly+link+list&meta=

Monday, February 2, 2009

IT 123A-Stack

A.) Definition/Concept
Stack- is an abstract data type and data structure based on the principle of Last In First Out. (google.com)
History;
The stack method of expression evaluation was first proposed in 1955 and then patented in 1957 by early German computer scientist Friedrich L. Bauer, (google.com)
Abstract data type;
As an abstract data type, the stack is a container of nodes and has two basic operations: push and pop.(google.com)
Operations;
In modern computer languages, the stack is usually implemented with more operations than just "push" and "pop". The length of a stack can often be returned as a parameter. Another helper operation top(also known as peek) can return the current top element of the stack without removing it from the stack.(google.com)
Implementation;
A typical storage requirement for a stack of n elements is O(n). The typical time requirement of O(1) operations is also easy to satisfy with a dynamic array or (singly) linked list implementation.

Ex.
class Stack(object):
def __init__(self):
self.stack_pointer = None
def push(self, element):
self.stack_pointer = Node(element, self.stack_pointer)
def pop(self):
e = self.stack_pointer.element
self.stack_pointer = self.stack_pointer.next
return e def peek(self):
return self.stack_pointer.element
def __len__(self):
i = 0
sp = self.stack_pointer
while sp:
i += 1
sp = sp.next
return i class Node(object):
def __init__(self, element=None, next=None):
self.element = element
self.next = next if __name__ == '__main__':
# small use example s = Stack()
[s.push(i) for i in xrange(10)]
print [s.pop() for i in xrange(len(s))] (google.com)
Hardware support;
stack in main memory;
Many CPUs have registers that can be used as stack pointers. Some, like the Intel x86, have special instructions that implicitly use a register dedicated to the job of being a stack pointer. Others, like the DEC PDP-11 and the Motorola 68000 family have addressing modes that make it possible to use any of a set of registers as a stack pointer. (google.com)
stack in registers;
The Intel 80x87 series of numeric coprocessors has a set of registers that can be accessed either as a stack or as a series of numbered registers. Sun's SPARC has a number of register windows organized as a stack which significantly reduces the need to use memory for passing function's arguments and return values. (google.com)

B.)illustration







C.) Reference
http://en.wikipedia.org/wiki/Stack_(data_structure