Charles Lee - C Promgramming Presentation
Charles Lee - C Promgramming Presentation
STRUCTURES
Submitted byShrema Garg
Adity Dahal
Abhishek
Farrukh
WHAT IS A COMPUTER
PROGRAM?
To exactly know, what is data structure? We must know:
What is a computer program?
Input
Some mysterious
processing
Output
INTRODUCTION
A data structure is a scheme for organizing data
in the memory of a computer.
The way in which the data is organized affects
the performance of a program for different tasks.
Computer programmers decide which data
structures to use based on the nature of the
data and the processes that need to be
performed on that data.
tree
queue
stack
STACKS
Allows access to only the last item
inserted.
An item is inserted or removed from the
stack from one end called the top of
the stack.
This mechanism is called Last-In-FirstOut (LIFO).
STACK OPERATIONS
Placing a data item on the top is called
pushing, while removing an item from
the top is called popping it.
push and pop are the primary stack
operations.
Some of the applications are :
microprocessors, some older calculators
etc.
QUEUES
Queue is an ADT data structure similar to stack, except that
the first item to be inserted is the first one to be removed.
This mechanism is called First-In-First-Out (FIFO).
Placing an item in a queue is called insertion or enqueue,
which is done at the end of the queue called rear.
Removing an item from a queue is called deletion or
dequeue, which is done at the other end of the queue
called front.
Some of the applications are : printer queue, keystroke
queue, etc.
VARIOUS QUEUES
Normal queue (FIFO)
Circular Queue (Normal Queue)
Double-ended Queue (Deque)
Priority Queue
CIRCULAR QUEUE
When a new item is inserted at the rear, the
pointer to rear moves upwards.
Similarly, when an item is deleted from the
queue the front arrow moves downwards.
After a few insert and delete operations the
rear might reach the end of the queue and
no more items can be inserted although the
items from the front of the queue have been
deleted and there is space in the queue.
CIRCULAR QUEUE
To solve this problem, queues implement
wrapping around. Such queues are called
Circular Queues.
Both the front and the rear pointers wrap
around to the beginning of the array.
It is also called as Ring buffer.
Items can inserted and deleted from a queue
in O(1) time.
DEQUE
It is a double-ended queue.
Items can be inserted and deleted from
either ends.
More versatile data structure than stack
or queue.
E.g. policy-based application (e.g. low
priority go to the end, high go to the
front)
PRIORITY QUEUES
More specialized data structure.
Similar to Queue, having front and rear.
Items are removed from the front.
Items are ordered by key value so that
the item with the lowest key (or
highest) is always at the front.
Items are inserted in proper position to
maintain the order.
Lets discuss complexity
ARRAYS
An array is an indexed set of variable. It is like
a set of boxes that hold things.
A list is a set of items.
An array is a set of variables that each store
an item.
THANK YOU