1.Data structure
1.Data structure
DATA STRUCTURE:
Organization of data into computer memory is called data structure.
OR
The process of storing or retrieving of data in the computer memory is called
data structure. The structure deals with how data is organized in memory.
OR
Structure means particular way of data organization. So data structure refers to
the organization of data in computer memory.In other words, the way in which
data is efficiently stored processed and retrieved is called Data Structure.
OR
Data structure is “The logical or Mathematical representation of data in
computer memory”.
OR
In computer science, data structure is a data organization, management and
storage format that enable efficient access and modification.
1. Searching:
This operation is use to search the specific element in the data structure./Find the
location of data in data structure.
2. Insertion:
This operation is use to insert the element in the data structure./ Add a new data in the
data structure./ inserting new element in a given Data Structure.
3. Deleting:
This operation is use to delete the element from data structure. /Remove a data from
the data structure. /Removing an element from an existing data structure OR dropping
/deleting a record from the entity record form the entity is called deletion.
4. Sorting:
This operation is use to arrange the all elements in the specific order. /Arrange data in
increasing or decreasing order.
5. Merging:
This operation is use to combine two stored files in one stored. /Combing the data of
two different sorted files into a single sorted file.
Traversing/Accessing:
Accessing each data exactly one in the data structure so that each data item is
traversed or visited. /Traversing means accessing /processing. Accessing each
record from a relation exactly one.
QUEUE
It is a linear data structure; In which insertions are done at one end (rear) and
deletion are done at other end (front).
In which elements are inserted from the back end and deleted from front end.
The front end of Queue is called as front or head and the back end of
Queue is called Rear or tail.
Queue is a line of items waiting to be served in sequential order.
It follows the rule of First in First out (FIFO),Which means that
element inserted first will also be removed first .
In Queue, the order in which the data arrives is important.
The process to add an element into Queue is called Enqueue and the process of
removal of an element from Queue is called Dequeue.
Examples of Queue
1. In real life, call center phone systems will use Queues, to hold people
calling them in an order, until a service representative is free.
2. In daily life, we wait in Queues to buy pizza, to enter movies theaters.
Stack Definition:
It is a linear data structure where insertion of elements or deletion of
elements is done only one side/end which is called top of the stack.
Stack is a type of linear data structure .By linear we mean that elements
are stored in continuous memory location in computer memory. A stack
is a list of elements in which elements may be inserted or deleted only at
one end called ‘top of the stack’.
It means that the elements are removed from a stack in the reverse order
of which they were inserted into the stack.
Insertion of element to stack is called “Stacking or PUSH”. And deletion
of an element from the stack is called “Un stacking or POP.
Stack follows the rule “LIFO” (Last in First out) and “FILO” (First in
Last out).
EXAMPLES
Daily Life examples of Stack:
1. Stack of Plates
2. Stack of books
3. A pile of trays in cafeteria
4. Wearing of bangles
5. Wearing of cloths
6. Omission of employee form the organization on the basis of seniority
card.
Operations on Stack
The following operations are performed on the stack.
i. Create stack
ii. PUSH
iii.POP
iv. Empty stack:
v. Destroy stack:
i. Create stack:
This operation creates an empty stack.
ii. PUSH:
The term which is used to insert an element into stack is called PUSH or
stacking.
The steps are as follows:
i. Access the top or stack pointer
ii. If stack is full (overflow), refuse entry or stacking.
iii. Increment the top or stack pointer.
iv. Store the data at location specified by the top or stack pointer.
iii.POP:
It is the term used to delete or remove an element from a stack. The
steps are as follows:
i. Check the stack is empty (underflow), refuse pop un-stacking.
ii. Remove the top element from stack.
iii. Decrement the top or stack pointer.
iv. Empty stack:
The result of this operation is false because stack is not empty .it
Represents that the value return is logic (0).
OR
This Boolean operation checks whether the stack is empty or not.
If there is no element in the stack then this operation will return
True value.
v. Full Stack:
The stack of this operation is also false because the stack is not full
i.e Boolean value 0.
If the stack is full then the Boolean value will be true.
iv. Destroy stack:
This operation checks if the stack full then remove all the
elements from the stack leaving it empty.
Stack applications:
i. Expression Evaluation:
It is sued to evaluate prefix infix postfix expression.
ii. Expression conversion:
Stack can be used to convert one form of expression to another.
iii. String reversal:
It is used to reverse the string.
iv. Function call:
It is used to keep information about the active functions or subroutines,
v. Syntax Parsing:
Many compilers sue a Stack for parsing the syntax
of expressions, program block etc. before translating into low level code.
vi. Back tracking:
Stack can be used in backtracking.
vii. Parenthesis checking:
Stack is used to check the proper opening and closing of parenthesis.
viii. Memory Management:
Stack is also used in memory management.
1.Stack follow LIFO operation i.e last in 1.Queue follow FIFO operation i.e First
First out. in First Out.
--------------------------------------------------------------------------------