SlideShare a Scribd company logo
1 of 29
Download to read offline
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 LibraryGauravPatil318
 
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 structuresagorolabs
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data StructureZidny Nafan
 
Queue data structure
Queue data structureQueue data structure
Queue data structureMekk Mhmd
 
Stl Containers
Stl ContainersStl Containers
Stl Containersppd1961
 
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 StructuresIntro C# Book
 
Machine Learning - Dataset Preparation
Machine Learning - Dataset PreparationMachine Learning - Dataset Preparation
Machine Learning - Dataset PreparationAndrew Ferlitsch
 
Talk on Standard Template Library
Talk on Standard Template LibraryTalk on Standard Template Library
Talk on Standard Template LibraryAnirudh Raja
 
Notes DATA STRUCTURE - queue
Notes DATA STRUCTURE - queueNotes DATA STRUCTURE - queue
Notes DATA STRUCTURE - queueFarhanum Aziera
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1blessyboban92
 

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

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 ADTSoumen Santra
 
Ch03_stacks_and_queues.ppt
Ch03_stacks_and_queues.pptCh03_stacks_and_queues.ppt
Ch03_stacks_and_queues.pptOliverKane3
 
Data Structure Using C
Data Structure Using CData Structure Using C
Data Structure Using Ccpjcollege
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queueRajkiran 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 queuessuser7319f8
 
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxchandankumar364348
 
Presentation on Elementary data structures
Presentation on Elementary data structuresPresentation on Elementary data structures
Presentation on Elementary data structuresKuber Chandra
 
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 QueueBalwant Gorad
 
Unit II - LINEAR DATA STRUCTURES
Unit II -  LINEAR DATA STRUCTURESUnit II -  LINEAR DATA STRUCTURES
Unit II - LINEAR DATA STRUCTURESUsha Mahalingam
 
Stack and queue
Stack and queueStack and queue
Stack and queueLavanyaJ28
 

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.pdfKanchanPatil34
 
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.pdfKanchanPatil34
 
Unit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdfUnit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdfKanchanPatil34
 
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.pdfKanchanPatil34
 
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 MicroporcessorKanchanPatil34
 
PAI Unit 3 Multitasking in 80386
PAI Unit 3 Multitasking in 80386PAI Unit 3 Multitasking in 80386
PAI Unit 3 Multitasking in 80386KanchanPatil34
 
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 microprocessorKanchanPatil34
 
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 segmentationKanchanPatil34
 
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 segmentationKanchanPatil34
 
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 1KanchanPatil34
 
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 2KanchanPatil34
 
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 3KanchanPatil34
 
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 2KanchanPatil34
 
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 1KanchanPatil34
 
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 8051KanchanPatil34
 
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 2KanchanPatil34
 
Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1KanchanPatil34
 
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 idtKanchanPatil34
 

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

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Recently uploaded (20)

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

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.