SlideShare a Scribd company logo
A Presentation
on
Data Structure and Files
Laboratory (214455)
Prepared By
Ms. K.D. Patil
Assistant Professor, Dept. of IT
Sanjivani College of Engineering, Kopargaon.
Teaching & Examination Scheme
• Teaching Scheme:
– Practical : 4 Hours/Week
• Credits:
– 02
• Examination Scheme:
– Term Work : 25 Marks
– External Practical : 50 Marks
Course Objectives
• To study data structures and their
implementations using OOP (C++)
and their applications
• To study some advanced data
structures such as trees, graphs and
tables
• To learn different file organizations
Course Outcomes
• After successful completion of this course,
student will be able to
– Apply and implement algorithm to illustrate use of
linear data structures such as stack, queue
– Apply and implement algorithms to
create/represent and traverse non-linear data
structures such as trees, graphs etc
– Apply and implement algorithms to create and
manipulate database using different file
organizations
– Learn and apply the concept of hashing in database
creation and manipulation
Assignment No. 1
• Aim:
– To implement stack as an abstract data
type using linked list and use this ADT
for conversion of infix expression to
postfix, prefix and evaluation of postfix
and prefix expression.
What is stack??
• It is a linear data structure in which
the insertion and deletion operations
are performed at only one end called
as ‘top’
• Inserting an item is known as
“pushing” onto the stack. “Popping”
off the stack is removing an item
• It is called as Last in First Out Data
structure.
Disadvantages of Stack using
Array
• The size of the stack must be
determined when a stack object is
declared
• Space is wasted if we use less
elements
• We cannot "push" more elements
than the array can hold
Stack as ADT
• Allocate memory for each new
element dynamically using linked list
• Each node in the stack should
contain two parts:
– data: the user's data
– next: the address of the
next element in the stack
Stack as ADT
• A stack is an abstract data type (ADT) that
supports two main methods:
– push(x): Inserts object x onto top of stack
– pop(): Removes the top object of stack and returns it;
if stack is empty an error occurs
• The following support methods should also be
defined:
– size(): Returns the number of objects in stack
– isEmpty(): Return a boolean indicating if stack is
empty.
– top(): return the top object of the stack, without
removing it; if the stack is empty an error occurs.
Node & Class Structure
Node Structure
• struct node
{
int data;
node* next;
};
Class Structure
•class Stack
{
private:
struct node * top; // Will always point to the head of
the list (First element)
public:
Stack()
{
top=NULL;
} // Default Constructor
void push(int);
int pop();
int getTop(); // returns the top-most element.
int isEmpty(); // returns true if the Stack is Empty,
else return false.
};
Algorithm
push
{
struct node *p;
p = new node;
p->data=value;
p->next = top;
top = p;
}
isEmpty()
{
If (top == NULL)
Return true;
Else
Return False;
}
pop
if(top != NULL)
{
Struct node *p;
p = top->data;
p = top;
top = top->next;
delete p;
}
getTop()
{
if(top)
return top->data;
else
return -1;
}
Expressions (Polish Notations)
• An expression is a collection of
operators and operands that
represents a specific value.
• Based on the operator position,
expressions are divided into THREE
types. They are as follows...
• Infix Expression eg. a+b
• Postfix Expression eg. ab+
• Prefix Expression eg. +ab
Algorithm: Infix to Postfix
Conversion
• Algorithm(infixtopostfix)
• Create stack
• Set postfix to null string
• i=0
• for all tokens ‘ch’ in the infix expression
• token=ch[i]
• if(token=‘(’)
– Push(stack, token)
• elseif(token=‘)’)
– Pop(stack, token)
– while(token!=‘(’)
- append token to postfix expression
- pop(stack, token)
• elseif(token==‘operator’)
–// test the priority of token to token at top of stack
–Stacktop(stack, toptoken)
–While(!stack.isEmpty() && priority(token)<=priority(toptoken))
-Pop(stack, tokenout)
-Append tokenout to postfix expression
-Stacktop(stack, toptoken)
–End while
–Push(stack,token)
• else
–// token is operand
–Append it to the postfix expression
• endif
• i=i+1
• end loop
• while(!stack.isempty())
–popstack(stack,token)
–Append token to postfix expression
• end while
• return postfix
• end infixtopostfix
Algorithm: Postfix Evaluation
• exprsize=length of string
• Initialize(stack s)
• x=readtoken()
• while(x)
• If(x is operand)
Push x onto stack
• If(x is operator)
{
Opnd2=pop(stack)
Opnd1=pop(stack)
Evaluate(opnd1,opnd2,operator x);
}
x=readnexttoken;
}
Algorithm: Prefix Evaluation
• exprsize=length of string
• Initialize(stack s)
• x=readtoken() // read token from right to left
• while(x)
• If(x is operand)
Push x onto stack
• If(x is operator)
{
Opnd2=pop(stack)
Opnd1=pop(stack)
Evaluate(opnd2,opnd1,operator x);
}
x=readnexttoken;
}
Application
• Stacks in the Java Virtual Machine
– Each process running in a Java program has its own Java
Method Stack.
– Each time a method is called, it is pushed onto the stack.
– The choice of a stack for this operation allows Java to do
several useful things:
- Perform recursive method calls
- Print stack traces to locate an error
• Java also includes an operand stack which is used to
evaluate arithmetic instructions, i.e.
Integer add(a, b):
OperandStack Op
Op.push(a)
Op.push(b)
temp1 ¬ Op.pop()
temp2 ¬ Op.pop()
Op.push(temp1 + temp2)
Outcome
• After successful completion of this
assignment, student will be able to
apply and implement algorithm to
illustrate use of stack linear data
structures.
Assignment 2
• Aim:
– Implement priority queue as ADT using
single linked list for servicing patients in
an hospital with priorities as i) Serious
(top priority) ii) medium illness (medium
priority) iii) General (Least priority).
What is Queue?
• Linear data structure which follows
FIFO (First In First ) principle.
• Allocate memory for each new
element dynamically
• Link the queue elements together
• Use two pointers, qFront and qRear
to mark the front and rear of the
queue
Queue as ADT
• A queue is an abstract data type
(ADT) that supports two main
methods:
– Enqueue(x): Inserts object x from rear
end
– Dequeue(): Removes the object x from
front end
Node & Class structure
Node Structure
• struct node
{
int data;
node* next;
};
Class Structure
• class queue
{
private:
struct node * front,
*rear;
public:
queue()
{
front=rear=NULL;
} // Default
Constructor
void enqueue();
void dequeue();
Algorithm
Enqueue()
{
struct node *ptr;
ptr=new node;
ptr->data=value;
ptr->next=NULL;
if(front == NULL)
{
front = rear = ptr;
rear->next = NULL;
}
else
{
rear->next = ptr;
rear = ptr;
rear->next = NULL;
}
}
Dequeue
{
struct node *ptr;
if(front==NULL)
{
cout<<"Queue is empty";
}
else
{
ptr=front;
x=ptr->data
front=front->next;
delete ptr;
}
}
Priority Queue
• Priority queues are a generalization of queues.
• Rather than inserting and deleting elements in
a fixed order, each element is assigned a
priority represented by an integer.
• We always remove an element with the
highest priority, which is given by the minimal
integer priority assigned.
•  If two elements have the same priority, they
are served according to their order in the
queue.
Priority queue as ADT
Node Structure
• struct node
{
int priority;
int info; struct
node *link;
};
Class Structure
class Priority_Queue
{
private:
node *front;
public:
Priority_Queue()
{
front = NULL;
}
}
Algorithm
Enqueue
• void insert(int item, int priority)
{
node *tmp, *q;
tmp = new node;
tmp->info = item;
tmp->priority = priority;
if (front == NULL || priority < front->priority)
{
tmp->link = front;
front = tmp;
}
else
{
q = front;
while (q->link != NULL && q->link->priority <=
priority)
q=q->link;
tmp->link = q->link;
q->link = tmp;
}
}
Dequeue
• void del()
{
node *tmp;
if(front == NULL)
cout<<"Queue Underflown";
else
{
tmp = front;
cout<<"Deleted item is: "<<tmp-
>info<<endl;
front = front->link;
free(tmp);
}
}
Applications
• In an operating system the runnable
processes might be stored in a priority
queue, where certain system processes are
given a higher priority than user processes.
• CPU Scheduling
http://cs.uttyler.edu/Faculty/Rainwater/COSC
3355/Animations/priority.htm
• In a network router packets may be routed
according to some assigned priorities.
• Priority Queuing:
– classes have different priorities
– class may depend on explicit marking or
other header info, eg IP source or
destination, TCP Port numbers, etc.
• Transmit a packet from the highest
priority class with a non-empty
queue
Outcome
• After successful completion of this
assignment, student will be able to
apply and implement algorithm to
illustrate use of queue linear data
structures.

More Related Content

What's hot

Standard Template Library
Standard Template LibraryStandard Template Library
Standard Template Library
GauravPatil318
 
C++ STL 概觀
C++ STL 概觀C++ STL 概觀
C++ STL 概觀
PingLun Liao
 
Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)
Roman Rodomansky
 
Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structures
agorolabs
 
Chapter 4 ds
Chapter 4 dsChapter 4 ds
Chapter 4 ds
Hanif Durad
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Zidny Nafan
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
Mekk Mhmd
 
STL in C++
STL in C++STL in C++
STL in C++
Surya Prakash Sahu
 
Queue
QueueQueue
Stl Containers
Stl ContainersStl Containers
Stl Containers
ppd1961
 
Collections in .net technology (2160711)
Collections in .net technology (2160711)Collections in .net technology (2160711)
Collections in .net technology (2160711)
Janki Shah
 
17. Trees and Tree Like Structures
17. Trees and Tree Like Structures17. Trees and Tree Like Structures
17. Trees and Tree Like Structures
Intro C# Book
 
Machine Learning - Dataset Preparation
Machine Learning - Dataset PreparationMachine Learning - Dataset Preparation
Machine Learning - Dataset Preparation
Andrew Ferlitsch
 
Chapter 7 ds
Chapter 7 dsChapter 7 ds
Chapter 7 ds
Hanif Durad
 
Collections
CollectionsCollections
Collections
Manav Prasad
 
Talk on Standard Template Library
Talk on Standard Template LibraryTalk on Standard Template Library
Talk on Standard Template Library
Anirudh Raja
 
Notes DATA STRUCTURE - queue
Notes DATA STRUCTURE - queueNotes DATA STRUCTURE - queue
Notes DATA STRUCTURE - queue
Farhanum Aziera
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
blessyboban92
 
Packages and Datastructures - Python
Packages and Datastructures - PythonPackages and Datastructures - Python
Packages and Datastructures - Python
hemalatha athinarayanan
 

What's hot (20)

Standard Template Library
Standard Template LibraryStandard Template Library
Standard Template Library
 
C++ STL 概觀
C++ STL 概觀C++ STL 概觀
C++ STL 概觀
 
Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)
 
Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structures
 
Chapter 4 ds
Chapter 4 dsChapter 4 ds
Chapter 4 ds
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
STL in C++
STL in C++STL in C++
STL in C++
 
Queue
QueueQueue
Queue
 
Stl Containers
Stl ContainersStl Containers
Stl Containers
 
Collections in .net technology (2160711)
Collections in .net technology (2160711)Collections in .net technology (2160711)
Collections in .net technology (2160711)
 
17. Trees and Tree Like Structures
17. Trees and Tree Like Structures17. Trees and Tree Like Structures
17. Trees and Tree Like Structures
 
Machine Learning - Dataset Preparation
Machine Learning - Dataset PreparationMachine Learning - Dataset Preparation
Machine Learning - Dataset Preparation
 
Chapter 7 ds
Chapter 7 dsChapter 7 ds
Chapter 7 ds
 
Collections
CollectionsCollections
Collections
 
264finalppt (1)
264finalppt (1)264finalppt (1)
264finalppt (1)
 
Talk on Standard Template Library
Talk on Standard Template LibraryTalk on Standard Template Library
Talk on Standard Template Library
 
Notes DATA STRUCTURE - queue
Notes DATA STRUCTURE - queueNotes DATA STRUCTURE - queue
Notes DATA STRUCTURE - queue
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
 
Packages and Datastructures - Python
Packages and Datastructures - PythonPackages and Datastructures - Python
Packages and Datastructures - Python
 

Similar to Data Structures and Files

9 python data structure-2
9 python data structure-29 python data structure-2
9 python data structure-2
Prof. Dr. K. Adisesha
 
Stack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADTStack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADT
Soumen Santra
 
Ch03_stacks_and_queues.ppt
Ch03_stacks_and_queues.pptCh03_stacks_and_queues.ppt
Ch03_stacks_and_queues.ppt
OliverKane3
 
Data Structure Using C
Data Structure Using CData Structure Using C
Data Structure Using C
cpjcollege
 
05-stack_queue.ppt
05-stack_queue.ppt05-stack_queue.ppt
05-stack_queue.ppt
Sarojkumari55
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queue
Rajkiran Nadar
 
Revisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queueRevisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queue
ssuser7319f8
 
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptx
chandankumar364348
 
Presentation on Elementary data structures
Presentation on Elementary data structuresPresentation on Elementary data structures
Presentation on Elementary data structures
Kuber Chandra
 
Data Structures
Data StructuresData Structures
Data Structures
Dr.Umadevi V
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
Balwant Gorad
 
stack presentation
stack presentationstack presentation
Unit II - LINEAR DATA STRUCTURES
Unit II -  LINEAR DATA STRUCTURESUnit II -  LINEAR DATA STRUCTURES
Unit II - LINEAR DATA STRUCTURES
Usha Mahalingam
 
Stack and queue
Stack and queueStack and queue
Stack and queue
LavanyaJ28
 
Queues
Queues Queues
Queues
nidhisatija1
 
Stacks
StacksStacks
Stacks
sweta dargad
 
Data structure
Data  structureData  structure
Data structure
Arvind Kumar
 
data structure
data structuredata structure
data structure
Arvind Kumar
 

Similar to Data Structures and Files (20)

9 python data structure-2
9 python data structure-29 python data structure-2
9 python data structure-2
 
Stack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADTStack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADT
 
Ch03_stacks_and_queues.ppt
Ch03_stacks_and_queues.pptCh03_stacks_and_queues.ppt
Ch03_stacks_and_queues.ppt
 
Data Structure Using C
Data Structure Using CData Structure Using C
Data Structure Using C
 
05-stack_queue.ppt
05-stack_queue.ppt05-stack_queue.ppt
05-stack_queue.ppt
 
2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queue
 
Revisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queueRevisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queue
 
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptx
 
Presentation on Elementary data structures
Presentation on Elementary data structuresPresentation on Elementary data structures
Presentation on Elementary data structures
 
Data Structures
Data StructuresData Structures
Data Structures
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
 
stack presentation
stack presentationstack presentation
stack presentation
 
Unit II - LINEAR DATA STRUCTURES
Unit II -  LINEAR DATA STRUCTURESUnit II -  LINEAR DATA STRUCTURES
Unit II - LINEAR DATA STRUCTURES
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Queues
Queues Queues
Queues
 
ELEMENTARY DATASTRUCTURES
ELEMENTARY DATASTRUCTURESELEMENTARY DATASTRUCTURES
ELEMENTARY DATASTRUCTURES
 
Stacks
StacksStacks
Stacks
 
Data structure
Data  structureData  structure
Data structure
 
data structure
data structuredata structure
data structure
 

More from KanchanPatil34

Unit 2_2 Binary Tree as ADT_General Tree.pdf
Unit 2_2 Binary Tree as ADT_General Tree.pdfUnit 2_2 Binary Tree as ADT_General Tree.pdf
Unit 2_2 Binary Tree as ADT_General Tree.pdf
KanchanPatil34
 
Unit 2_1 Tree.pdf
Unit 2_1 Tree.pdfUnit 2_1 Tree.pdf
Unit 2_1 Tree.pdf
KanchanPatil34
 
Unit 2_3 Binary Tree Traversals.pdf
Unit 2_3 Binary Tree Traversals.pdfUnit 2_3 Binary Tree Traversals.pdf
Unit 2_3 Binary Tree Traversals.pdf
KanchanPatil34
 
Unit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdfUnit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdf
KanchanPatil34
 
Unit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdfUnit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdf
KanchanPatil34
 
PAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 MicroporcessorPAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 Microporcessor
KanchanPatil34
 
PAI Unit 3 Multitasking in 80386
PAI Unit 3 Multitasking in 80386PAI Unit 3 Multitasking in 80386
PAI Unit 3 Multitasking in 80386
KanchanPatil34
 
PAI Unit 2 Segmentation in 80386 microprocessor
PAI Unit 2 Segmentation in 80386 microprocessorPAI Unit 2 Segmentation in 80386 microprocessor
PAI Unit 2 Segmentation in 80386 microprocessor
KanchanPatil34
 
PAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentationPAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentation
KanchanPatil34
 
SE PAI Unit 2_Data Structures in 80386 segmentation
SE PAI Unit 2_Data Structures in 80386 segmentationSE PAI Unit 2_Data Structures in 80386 segmentation
SE PAI Unit 2_Data Structures in 80386 segmentation
KanchanPatil34
 
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
KanchanPatil34
 
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
KanchanPatil34
 
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
KanchanPatil34
 
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
KanchanPatil34
 
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
KanchanPatil34
 
SE PAI Unit 5_IO programming in 8051
SE PAI Unit 5_IO programming in 8051SE PAI Unit 5_IO programming in 8051
SE PAI Unit 5_IO programming in 8051
KanchanPatil34
 
Unit 5_Interrupt programming in 8051 micro controller - part 2
Unit 5_Interrupt programming in 8051 micro controller - part 2Unit 5_Interrupt programming in 8051 micro controller - part 2
Unit 5_Interrupt programming in 8051 micro controller - part 2
KanchanPatil34
 
Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1
KanchanPatil34
 
8051 interfacing
8051 interfacing8051 interfacing
8051 interfacing
KanchanPatil34
 
Unit 3 se pai_ivt and idt
Unit 3 se pai_ivt and idtUnit 3 se pai_ivt and idt
Unit 3 se pai_ivt and idt
KanchanPatil34
 

More from KanchanPatil34 (20)

Unit 2_2 Binary Tree as ADT_General Tree.pdf
Unit 2_2 Binary Tree as ADT_General Tree.pdfUnit 2_2 Binary Tree as ADT_General Tree.pdf
Unit 2_2 Binary Tree as ADT_General Tree.pdf
 
Unit 2_1 Tree.pdf
Unit 2_1 Tree.pdfUnit 2_1 Tree.pdf
Unit 2_1 Tree.pdf
 
Unit 2_3 Binary Tree Traversals.pdf
Unit 2_3 Binary Tree Traversals.pdfUnit 2_3 Binary Tree Traversals.pdf
Unit 2_3 Binary Tree Traversals.pdf
 
Unit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdfUnit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdf
 
Unit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdfUnit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdf
 
PAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 MicroporcessorPAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 Microporcessor
 
PAI Unit 3 Multitasking in 80386
PAI Unit 3 Multitasking in 80386PAI Unit 3 Multitasking in 80386
PAI Unit 3 Multitasking in 80386
 
PAI Unit 2 Segmentation in 80386 microprocessor
PAI Unit 2 Segmentation in 80386 microprocessorPAI Unit 2 Segmentation in 80386 microprocessor
PAI Unit 2 Segmentation in 80386 microprocessor
 
PAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentationPAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentation
 
SE PAI Unit 2_Data Structures in 80386 segmentation
SE PAI Unit 2_Data Structures in 80386 segmentationSE PAI Unit 2_Data Structures in 80386 segmentation
SE PAI Unit 2_Data Structures in 80386 segmentation
 
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
 
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
 
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
 
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
 
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
 
SE PAI Unit 5_IO programming in 8051
SE PAI Unit 5_IO programming in 8051SE PAI Unit 5_IO programming in 8051
SE PAI Unit 5_IO programming in 8051
 
Unit 5_Interrupt programming in 8051 micro controller - part 2
Unit 5_Interrupt programming in 8051 micro controller - part 2Unit 5_Interrupt programming in 8051 micro controller - part 2
Unit 5_Interrupt programming in 8051 micro controller - part 2
 
Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1
 
8051 interfacing
8051 interfacing8051 interfacing
8051 interfacing
 
Unit 3 se pai_ivt and idt
Unit 3 se pai_ivt and idtUnit 3 se pai_ivt and idt
Unit 3 se pai_ivt and idt
 

Recently uploaded

Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 

Recently uploaded (20)

Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 

Data Structures and Files

  • 1. A Presentation on Data Structure and Files Laboratory (214455) Prepared By Ms. K.D. Patil Assistant Professor, Dept. of IT Sanjivani College of Engineering, Kopargaon.
  • 2. Teaching & Examination Scheme • Teaching Scheme: – Practical : 4 Hours/Week • Credits: – 02 • Examination Scheme: – Term Work : 25 Marks – External Practical : 50 Marks
  • 3. Course Objectives • To study data structures and their implementations using OOP (C++) and their applications • To study some advanced data structures such as trees, graphs and tables • To learn different file organizations
  • 4. Course Outcomes • After successful completion of this course, student will be able to – Apply and implement algorithm to illustrate use of linear data structures such as stack, queue – Apply and implement algorithms to create/represent and traverse non-linear data structures such as trees, graphs etc – Apply and implement algorithms to create and manipulate database using different file organizations – Learn and apply the concept of hashing in database creation and manipulation
  • 5. Assignment No. 1 • Aim: – To implement stack as an abstract data type using linked list and use this ADT for conversion of infix expression to postfix, prefix and evaluation of postfix and prefix expression.
  • 6. What is stack?? • It is a linear data structure in which the insertion and deletion operations are performed at only one end called as ‘top’ • Inserting an item is known as “pushing” onto the stack. “Popping” off the stack is removing an item • It is called as Last in First Out Data structure.
  • 7. Disadvantages of Stack using Array • The size of the stack must be determined when a stack object is declared • Space is wasted if we use less elements • We cannot "push" more elements than the array can hold
  • 8. Stack as ADT • Allocate memory for each new element dynamically using linked list • Each node in the stack should contain two parts: – data: the user's data – next: the address of the next element in the stack
  • 9. Stack as ADT • A stack is an abstract data type (ADT) that supports two main methods: – push(x): Inserts object x onto top of stack – pop(): Removes the top object of stack and returns it; if stack is empty an error occurs • The following support methods should also be defined: – size(): Returns the number of objects in stack – isEmpty(): Return a boolean indicating if stack is empty. – top(): return the top object of the stack, without removing it; if the stack is empty an error occurs.
  • 10. Node & Class Structure Node Structure • struct node { int data; node* next; }; Class Structure •class Stack { private: struct node * top; // Will always point to the head of the list (First element) public: Stack() { top=NULL; } // Default Constructor void push(int); int pop(); int getTop(); // returns the top-most element. int isEmpty(); // returns true if the Stack is Empty, else return false. };
  • 11. Algorithm push { struct node *p; p = new node; p->data=value; p->next = top; top = p; } isEmpty() { If (top == NULL) Return true; Else Return False; } pop if(top != NULL) { Struct node *p; p = top->data; p = top; top = top->next; delete p; } getTop() { if(top) return top->data; else return -1; }
  • 12. Expressions (Polish Notations) • An expression is a collection of operators and operands that represents a specific value. • Based on the operator position, expressions are divided into THREE types. They are as follows... • Infix Expression eg. a+b • Postfix Expression eg. ab+ • Prefix Expression eg. +ab
  • 13. Algorithm: Infix to Postfix Conversion • Algorithm(infixtopostfix) • Create stack • Set postfix to null string • i=0 • for all tokens ‘ch’ in the infix expression • token=ch[i] • if(token=‘(’) – Push(stack, token) • elseif(token=‘)’) – Pop(stack, token) – while(token!=‘(’) - append token to postfix expression - pop(stack, token)
  • 14. • elseif(token==‘operator’) –// test the priority of token to token at top of stack –Stacktop(stack, toptoken) –While(!stack.isEmpty() && priority(token)<=priority(toptoken)) -Pop(stack, tokenout) -Append tokenout to postfix expression -Stacktop(stack, toptoken) –End while –Push(stack,token) • else –// token is operand –Append it to the postfix expression • endif • i=i+1 • end loop • while(!stack.isempty()) –popstack(stack,token) –Append token to postfix expression • end while • return postfix • end infixtopostfix
  • 15. Algorithm: Postfix Evaluation • exprsize=length of string • Initialize(stack s) • x=readtoken() • while(x) • If(x is operand) Push x onto stack • If(x is operator) { Opnd2=pop(stack) Opnd1=pop(stack) Evaluate(opnd1,opnd2,operator x); } x=readnexttoken; }
  • 16. Algorithm: Prefix Evaluation • exprsize=length of string • Initialize(stack s) • x=readtoken() // read token from right to left • while(x) • If(x is operand) Push x onto stack • If(x is operator) { Opnd2=pop(stack) Opnd1=pop(stack) Evaluate(opnd2,opnd1,operator x); } x=readnexttoken; }
  • 17. Application • Stacks in the Java Virtual Machine – Each process running in a Java program has its own Java Method Stack. – Each time a method is called, it is pushed onto the stack. – The choice of a stack for this operation allows Java to do several useful things: - Perform recursive method calls - Print stack traces to locate an error • Java also includes an operand stack which is used to evaluate arithmetic instructions, i.e. Integer add(a, b): OperandStack Op Op.push(a) Op.push(b) temp1 ¬ Op.pop() temp2 ¬ Op.pop() Op.push(temp1 + temp2)
  • 18. Outcome • After successful completion of this assignment, student will be able to apply and implement algorithm to illustrate use of stack linear data structures.
  • 19. Assignment 2 • Aim: – Implement priority queue as ADT using single linked list for servicing patients in an hospital with priorities as i) Serious (top priority) ii) medium illness (medium priority) iii) General (Least priority).
  • 20. What is Queue? • Linear data structure which follows FIFO (First In First ) principle. • Allocate memory for each new element dynamically • Link the queue elements together • Use two pointers, qFront and qRear to mark the front and rear of the queue
  • 21. Queue as ADT • A queue is an abstract data type (ADT) that supports two main methods: – Enqueue(x): Inserts object x from rear end – Dequeue(): Removes the object x from front end
  • 22. Node & Class structure Node Structure • struct node { int data; node* next; }; Class Structure • class queue { private: struct node * front, *rear; public: queue() { front=rear=NULL; } // Default Constructor void enqueue(); void dequeue();
  • 23. Algorithm Enqueue() { struct node *ptr; ptr=new node; ptr->data=value; ptr->next=NULL; if(front == NULL) { front = rear = ptr; rear->next = NULL; } else { rear->next = ptr; rear = ptr; rear->next = NULL; } } Dequeue { struct node *ptr; if(front==NULL) { cout<<"Queue is empty"; } else { ptr=front; x=ptr->data front=front->next; delete ptr; } }
  • 24. Priority Queue • Priority queues are a generalization of queues. • Rather than inserting and deleting elements in a fixed order, each element is assigned a priority represented by an integer. • We always remove an element with the highest priority, which is given by the minimal integer priority assigned. •  If two elements have the same priority, they are served according to their order in the queue.
  • 25. Priority queue as ADT Node Structure • struct node { int priority; int info; struct node *link; }; Class Structure class Priority_Queue { private: node *front; public: Priority_Queue() { front = NULL; } }
  • 26. Algorithm Enqueue • void insert(int item, int priority) { node *tmp, *q; tmp = new node; tmp->info = item; tmp->priority = priority; if (front == NULL || priority < front->priority) { tmp->link = front; front = tmp; } else { q = front; while (q->link != NULL && q->link->priority <= priority) q=q->link; tmp->link = q->link; q->link = tmp; } } Dequeue • void del() { node *tmp; if(front == NULL) cout<<"Queue Underflown"; else { tmp = front; cout<<"Deleted item is: "<<tmp- >info<<endl; front = front->link; free(tmp); } }
  • 27. Applications • In an operating system the runnable processes might be stored in a priority queue, where certain system processes are given a higher priority than user processes. • CPU Scheduling http://cs.uttyler.edu/Faculty/Rainwater/COSC 3355/Animations/priority.htm • In a network router packets may be routed according to some assigned priorities.
  • 28. • Priority Queuing: – classes have different priorities – class may depend on explicit marking or other header info, eg IP source or destination, TCP Port numbers, etc. • Transmit a packet from the highest priority class with a non-empty queue
  • 29. Outcome • After successful completion of this assignment, student will be able to apply and implement algorithm to illustrate use of queue linear data structures.