The document discusses different data structures including stacks, queues, linked lists, and their implementations. It defines stacks as LIFO structures that can add and remove items from one end only. Queues are FIFO structures that add to one end and remove from the other. Linked lists store data in nodes that point to the next node. Stacks, queues and linked lists can all be implemented using arrays or by linking nodes. Priority queues and deques are also discussed.
queue datastructure made easy and datastructure explained in java. visit http://technoexplore.blogspot.com and http://hotjobstuff.blogspot.com for some other important presentations.
Data Structure Introduction
Data Structure Definition
Data Structure Types
Data Structure Characteristics
Need for Data Structure
Stack Definition
Stack Representation
Stack Operations
Stack Algorithm
Program for Stack in C++
Linked List Definition
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
Linked List Defination
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
queue datastructure made easy and datastructure explained in java. visit http://technoexplore.blogspot.com and http://hotjobstuff.blogspot.com for some other important presentations.
Data Structure Introduction
Data Structure Definition
Data Structure Types
Data Structure Characteristics
Need for Data Structure
Stack Definition
Stack Representation
Stack Operations
Stack Algorithm
Program for Stack in C++
Linked List Definition
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
Linked List Defination
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
Stacks and Queues: Introduction to stacks
applications of stacks
implementation and comparison of stack implementations.
Introduction to queues
applications of queues and implementations
Priority Queues and applications
a presentation covering all the topics on Stacks and Queues in Data Structures using C++. Includes self explanatory diagrams, algorithms and program pieces.
Linked List Static and Dynamic Memory AllocationProf Ansari
Static variables are declared and named while writing the program. (Space for them exists as long as the program, in which they are declared, is running.) Static variables cannot be created or destroyed during execution of the program in which they are declared.
Dynamic variables are created (and may be destroyed) during program execution since dynamic variables do not exist while the program is compiled, but only when it is run, they cannot be assigned names while it is being written. The only way to access dynamic variables is by using pointers. Once it is created, however, a dynamic variable does contain data and must have a type like any other variable. If a dynamic variable is created in a function, then it can continue to exist even after the function terminates.
Linked Linear List
We saw in previous chapters how static representation of linear ordered list through Array leads to wastage of memory and in some cases overflows. Now we don't want to assign memory to any linear list in advance instead we want to allocate memory to elements as they are inserted in list. This requires Dynamic Allocation of memory and it can be achieved by using malloc() or calloc() function.
But memory assigned to elements will not be contiguous, which is a requirement for linear ordered list, and was provided by array representation. How we could achieve this?
Stacks and Queues: Introduction to stacks
applications of stacks
implementation and comparison of stack implementations.
Introduction to queues
applications of queues and implementations
Priority Queues and applications
a presentation covering all the topics on Stacks and Queues in Data Structures using C++. Includes self explanatory diagrams, algorithms and program pieces.
Linked List Static and Dynamic Memory AllocationProf Ansari
Static variables are declared and named while writing the program. (Space for them exists as long as the program, in which they are declared, is running.) Static variables cannot be created or destroyed during execution of the program in which they are declared.
Dynamic variables are created (and may be destroyed) during program execution since dynamic variables do not exist while the program is compiled, but only when it is run, they cannot be assigned names while it is being written. The only way to access dynamic variables is by using pointers. Once it is created, however, a dynamic variable does contain data and must have a type like any other variable. If a dynamic variable is created in a function, then it can continue to exist even after the function terminates.
Linked Linear List
We saw in previous chapters how static representation of linear ordered list through Array leads to wastage of memory and in some cases overflows. Now we don't want to assign memory to any linear list in advance instead we want to allocate memory to elements as they are inserted in list. This requires Dynamic Allocation of memory and it can be achieved by using malloc() or calloc() function.
But memory assigned to elements will not be contiguous, which is a requirement for linear ordered list, and was provided by array representation. How we could achieve this?
Queue is a Linear list which has two ends, one for insertion of elements and other for deletion of elements. The first end is called 'Rear' and the later is called 'Front'. Elements are inserted from Rear End and Deleted from Front End. Queues are called First In First Out (FIFO) List, since the first element in a queue will be the first element out of the queue. In other words, the order in which the elements enter a queue is the order in which they leave.
In Batch Processing the jobs are "Queued up" as they are read in and executed, one after another in the order they were received. This ignores the possible existence of priorities.
Rai University provides high quality education for MSc, Law, Mechanical Engineering, BBA, MSc, Computer Science, Microbiology, Hospital Management, Health Management and IT Engineering.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
Andreas Schleicher presents at the OECD webinar ‘Digital devices in schools: detrimental distraction or secret to success?’ on 27 May 2024. The presentation was based on findings from PISA 2022 results and the webinar helped launch the PISA in Focus ‘Managing screen time: How to protect and equip students against distraction’ https://www.oecd-ilibrary.org/education/managing-screen-time_7c225af4-en and the OECD Education Policy Perspective ‘Students, digital devices and success’ can be found here - https://oe.cd/il/5yV
The Indian economy is classified into different sectors to simplify the analysis and understanding of economic activities. For Class 10, it's essential to grasp the sectors of the Indian economy, understand their characteristics, and recognize their importance. This guide will provide detailed notes on the Sectors of the Indian Economy Class 10, using specific long-tail keywords to enhance comprehension.
For more information, visit-www.vavaclasses.com
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
This is a presentation by Dada Robert in a Your Skill Boost masterclass organised by the Excellence Foundation for South Sudan (EFSS) on Saturday, the 25th and Sunday, the 26th of May 2024.
He discussed the concept of quality improvement, emphasizing its applicability to various aspects of life, including personal, project, and program improvements. He defined quality as doing the right thing at the right time in the right way to achieve the best possible results and discussed the concept of the "gap" between what we know and what we do, and how this gap represents the areas we need to improve. He explained the scientific approach to quality improvement, which involves systematic performance analysis, testing and learning, and implementing change ideas. He also highlighted the importance of client focus and a team approach to quality improvement.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
2. DEFINITION: STACK
An ordered collection of data items
Can be accessed at only one end (the top)
Stacks are LIFO structures, providing
Add Item (=PUSH) Methods
Remove Item (=POP) Methods
They are a simple way to build a collection
No indexing necessary
Size of collection must not be predefined
But: extremely reduced accessibility
3. initializeStack: Initializes the stack to an empty state
destroyStack: Removes all the elements from the
stack, leaving the stack empty
isEmptyStack: Checks whether the stack is empty. If
empty, it returns true; otherwise, it returns false
BASIC OPERATIONS ON A STACK
4. CONT..
isFullStack: Checks whether the stack is full.
If full, it returns true; otherwise, it returns false
push:
Add new element to the top of the stack
The input consists of the stack and the new
element.
Prior to this operation, the stack must exist
and must not be full
5. CONT..
top: Returns the top element of the stack. Prior
to this operation, the stack must exist and must
not be empty.
pop: Removes the top element of the stack. Prior
to this operation, the stack must exist and must
not be empty.
7. Examples:
Finding Palindromes
Bracket Parsing
RPN
RECURSION !
APPLICATIONS USING A STACK
8. • Sometimes, the best way to solve a problem is by
solving a smaller version of the exact same
problem first
• Recursion is a technique that solves a problem by
solving a smaller problem of the same type
• A procedure that is defined in terms of itself
RECURSION
9. FACTORIAL
a! = 1 * 2 * 3 * ... * (a-1) * a
a! = a * (a-1)!
a!
a * (a-1)!
remember
...splitting up the problem into a smaller problem of the
same type...
10. INFIX: From our schools times we have been familiar with the
expressions in which operands surround the operator,
e.g. x+y, 6*3 etc this way of writing the Expressions is called
infix notation.
POSTFIX: Postfix notation are also Known as Reverse Polish
Notation (RPN). They are different from the infix and prefix
notations in the sense that in the postfix notation, operator
comes after the operands,
e.g. xy+, xyz+* etc.
PREFIX: Prefix notation also Known as Polish notation.In the
prefix notation, as the name only suggests, operator comes
before the operands,
e.g. +xy, *+xyz etc.
INFIX, POSTFIX AND PREFIX EXPRESSIONS
11. Using a Queue
Representation Of Queue
Operations On Queue
Circular Queue
Priority Queue
Array Representation of Priority Queue
Double Ended Queue
Applications of Queue
12. WHAT IS A QUEUE?
A queue system is a linear list in which deletions can take
place only at one end the “front” of the list, and the
insertions can take place only at the other end of the list,
the “back” .
Is called a First-In-First-Out(FIFO)
13. THE QUEUE OPERATIONS
A queue is like a line of people waiting for a bank teller.
The queue has a front and a rear.
14. THE QUEUE OPERATIONS
New people must enter the queue at the rear.
The C++ queue class calls this a push, although it is
usually called an enqueue operation.
15. THE QUEUE OPERATIONS
When an item is taken from the queue, it always
comes from the front.
The C++ queue calls this a pop, although it is
usually called a dequeue operation.
$ $
Front
Rear
16. OPERATIONS ON QUEUES
Insert(item): (also called enqueue)
It adds a new item to the tail of the queue
Remove( ): (also called delete or dequeue)
It deletes the head item of the queue, and returns to the
caller.
If the queue is already empty, this operation returns NULL
getHead( ):
Returns the value in the head element of the queue
getTail( ):
Returns the value in the tail element of the queue
isEmpty( )
Returns true if the queue has no items
size( )
Returns the number of items in the queue
17. The Queue Class
The C++ standard template
library has a queue template
class.
The template parameter is
the type of the items that can
be put in the queue.
template <class Item>
class queue<Item>
{
public:
queue( );
void push(const Item& entry);
void pop( );
bool empty( ) const;
Item front( ) const;
…
};
18. ARRAY IMPLEMENTATION
A queue can be implemented with an array, as shown here.
For example, this queue contains the integers 4 (at the
front), 8 and 6 (at the rear).
[ 0 ] [1] [ 2 ] [ 3 ] [ 4 ] [ 5 ] . . .
An array of integers
to implement a
queue of integers
4 8 6
We don't care what's in
this part of the array.
19. ARRAY IMPLEMENTATION
The easiest implementation also keeps track
of the number of items in the queue and the
index of the first element (at the front of the
queue), the last element (at the rear).
[ 0 ] [1] [ 2 ] [ 3 ] [ 4 ] [ 5 ] . . .
4 8 6
size3
first0
last2
20. AN ENQUEUE OPERATION
When an element enters the queue, size is
incremented, and last changes, too.
[ 0 ] [1] [ 2 ] [ 3 ] [ 4 ] [ 5 ] . . .
28 6
size3
first1
last3
21. AT THE END OF THE ARRAY
There is special behaviour at the end of the
array.
For example, suppose we want to add a new
element to this queue, where the last index is
[5]:
[ 0 ] [1] [ 2 ] [ 3 ] [ 4 ] [ 5 ]
2 16
size3
first3
last5
22. AT THE END OF THE ARRAY
The new element goes at the front of the
array (if that spot isn’t already used):
[ 0 ] [1] [ 2 ] [ 3 ] [ 4 ] [ 5 ]
2 16
size4
first3
last0
4
23. ARRAY IMPLEMENTATION
Easy to implement
But it has a limited capacity with a fixed array
Or you must use a dynamic array for an
unbounded capacity
Special behavior is needed when the rear reaches
the end of the array.
[ 0 ] [1] [ 2 ] [ 3 ] [ 4 ] [ 5 ] . . .
4 8 6
size3
first0
last2
24. CIRCULAR QUEUE
When the queue reaches the end of the array, it “wraps around”
and the rear of the queue starts from index 0.
A The figure below demonstrates the situation.
25. 25
PRIORITY QUEUES
A priority queue is a collection of zero or more
elements each element has a priority or value
Unlike the FIFO queues, the order of deletion from
a priority queue (e.g., who gets served next) is
determined by the element priority
Elements are deleted by increasing or decreasing
order of priority rather than by the order in which
they arrived in the queue
26. 26
PRIORITY QUEUES
Operations performed on priority queues
1) Find an element, 2) insert a new element, 3) delete an element,
etc.
Two kinds of (Min, Max) priority queues exist
In a Min priority queue, find/delete operation finds/deletes the
element with minimum priority
In a Max priority queue, find/delete operation finds/deletes the
element with maximum priority
Two or more elements can have the same priority
27. DEQUES
A deque is a double-ended queue
Insertions and deletions can occur at either end
Implementation is similar to that for queues
Deques are not heavily used
You should know what a deque is, but we won’t
explore them much further
28. Ucommuting pipes
DEQUE (DOUBLE-ENDED QUEUE)[1]
Implemented by the class Arraydeque in Java 6 seen as a
doubly linked list with a head (right) and a tail (left) and
insert and remove at either ends.
head
tail
..... 43 1 625
5
1 2
4
6
headtail
3
29. QUEUE APPLICATIONS
Real life examples
Waiting in line
Waiting on hold for tech support
Applications related to Computer Science
Threads
Job scheduling (e.g. Round-Robin algorithm for CPU
allocation)
33. LINKED LIST
Linkedlist an ordered collection of data in which each
element contains the location of the next element.
Each element contains two parts: data and link.
The link contains a pointer (an address) that identifies
the next element in the list.
Singly linked list
The link in the last element contains a null pointer,
indicating the end of the list.
34. Node[5]
Nodes : the elements in a linked list.
The nodes in a linked list are called self-referential records.
Each instance of the record contains a pointer to another
instance of the same structural type.
35. 35
SENTINEL NODES
To simplify programming, two special nodes have been added at
both ends of the doubly-linked list.
Head and tail are dummy nodes, also called sentinels, do not store
any data elements.
Head: header sentinel has a null-prev reference (link).
Tail: trailer sentinel has a null-next reference (link).
36. 36
header trailer
Empty Doubly-Linked List:[6]
Using sentinels, we have no null-
links; instead, we have:
head.next = tail
tail.prev = head
Singl Node List:
Size = 1
This single node is the first node,
and also is the last node:
first node is head.next
last node is tail.prev
trailerheader
first last
37. In linear linked lists if a list is traversed (all the elements visited)
an external pointer to the list must be preserved in order to be
able to reference the list again.
Circular linked lists can be used to help the traverse the same list
again and again if needed.
A circular list is very similar to the linear list where in the
circular list the pointer of the last node points not NULL but the
first node.
CIRCULAR LINKED LISTS
38. CIRCULAR LINKED LISTS
In a circular linked list there are two methods to know if a
node is the first node or not.
Either a external pointer, list, points the first node or
A header node is placed as the first node of the circular
list.
The header node can be separated from the others by either
heaving a sentinel value as the info part or having a
dedicated flag variable to specify if the node is a header node
or not.
39. REFERENCES
An introduction to Datastructure with application by jean Trembley and
sorrenson
Data structures by schaums and series –seymour lipschutz
http://en.wikipedia.org/wiki/Book:Data_structures
http://www.amazon.com/Data-Structures-Algorithms
http://www.amazon.in/Data-Structures-Algorithms-Made-
Easy/dp/0615459811/
http://www.amazon.in/Data-Structures-SIE-Seymour-Lipschutz/dp
List of images
1) http://whttp://www.amazon.in/Data-Structures-SIE-Seymour-
Lipschutz/dq
2) ww.amazon.in/Data-Structures-linkedlist
3) ww.amazon.in/Data-Structures-linkedlist
4) ww.amazon.in/Data-Structures-linkedlist
5) ww.amazon.in/Data-Structures-linkedlist
6) ww.amazon.in/Data-Structures-doubly linkedlist