5. 5
DATA
STRUCTURE-
An organization
of data to suit a
specific
Purpose
STACK
TREE
QUEUE
LIST
HEAP
HASH TABLE
It has data and the operations that
can be done on stored data
7. 7
Stack Features
Homogeneous Data
Members
Variable Length
LAST IN – FIRST OUT
TOP-An access pointer for
insertions and deletions
Stack Operations
PUSH- Insert Element at
Top, (overflow if full)
POP- Delete Element at
Top, (Underflow if empty)
PEEK- Read the Element at
Top
isEmpty- Check if the Stack
is empty
isFull- Check if the Stack is
Full
push(), pop(), isEmpty(), isFull() and peek() all take O(1) time. There is no loop in
any of these operations.
8. Objectives
• 1. To develop an algorithm for feature selection
from gene expression data
• 2. To develop an algorithm for inference of gene
regulatory networks
• 3. To develop an algorithm for classification of
tumor samples based on results of 1 and 2.
8
9. Implementation as an Array
9
void push()
{
if(top>=size-1)
{
printf("ntSTACK FULL");
}
else
{
printf(" Enter a value to
be pushed:");
scanf("%d",&x);
top++;
stack[top]=x;
}
}
void pop()
{
if(top<=-1)
{
printf("nt Stack
EMPTY");
}
else
{
printf("nt The popped
elements is %d",
stack[top]);
top--;
}
}
int size=5;
int stack[size];
int top;
10. Implementation as a Linked List
10
void push(int value)
{
node *tmp;
tmp =
malloc(sizeof(node));
tmp -> data = value;
tmp -> next = top;
top = tmp;
}
int pop()
{
node *tmp;
int n;
tmp = top;
n = tmp->data;
top = top->next;
free(tmp);
return n;
}
struct node
{
int data;
struct node
*next;
};
node *top;
top = NULL;
11. Applications of Stack
11
Expression Evaluation
Expression
Conversion
Syntax Parsing
Backtracking
Parenthesis
Check
String
Reversal
Function Call-
Recursion
Parameter Space & Local
Variables Processing
13. 13
Queue Features
Homogeneous Data
Members
Variable Length
FIRST IN – FIRST OUT
Front is An access pointer
for deletions
Rear is an access pointer
for insertions
Queue Operations
Enqueue()- Insert Element
at rear
Dequeue()- Delete Element
at front
Peek()- get the element at
front without removing it
isEmpty()- Check if the
queue is empty
isFull()- Check if the queue
is Full
17. Applications of Queue
17
•Serving requests on a single shared resource, like a
printer, CPU task scheduling etc.
•In real life scenario, Call Center phone systems uses
Queues to hold people calling them in an order, until a
service representative is free.
•Handling of interrupts in real-time systems. The
interrupts are handled in the same order as they arrive
i.e First come first served.