In computer science, a stack is a last in, first out (LIFO) abstract data type and data structure. A stack can have any abstract data type as an element, but is characterized by only two fundamental operations: push and pop. The push operation adds to the top of the list, hiding any items already on the stack, or initializing the stack if it is empty. The pop operation removes an item from the top of the list, and returns this value to the caller. A pop either reveals previously concealed items, or results in an empty list.
A stack is a restricted data structure, because only a small number of operations are performed on it. The nature of the pop and push operations also means that stack elements have a natural order. Elements are removed from the stack in the reverse order to the order of their addition: therefore, the lower elements are typically those that have been in the list the longest.
Data Structure
Data structure is collection of data elements which are characterised by accessing functions. The accessing functions are used to store and retrieve data elements. For example if the data is organised as an array A of 100 elements then it's elements are represented as A(1),A(2),.....A(100). In this example accessing function is A(K), which refers to Kth element of the array A.
Types of data structures
Data structures can be classified as :
1. Primitive data structures
Basic data types such as integer,real ,character and boolean are
known as primitive data structures or simple data types. They are
known to be simple data types as they consists of those charac
ters that can not be divided.
2. Non-Primitive data structures
The simplest example of the non-primitive data structure is the
processing of complex numbers. Very few computers are capable of
doing arithmetic on complex numbers. The other examples are
linked-lists,stacks,queues,trees and graphs.
Logical versus physical implementation
Logical implementation
At the logical level, the user treats the given data whether it
is primitive or structured from programming point of view. The
user may not have any knowledge about the storage of data in the
memory or how the operations are performed on this data. For a
user, logically 2*3=6. He knows that 2*3 gives the result 6 But
he is not aware where and how the operations, namely 2,3,and
multiplication are stored in the memory or how the computer is
performing this operation.
Physical implementation
By the physical implementation of data structure , it is meant
the mode of storage of data. This physical implementation of data
structure is discussed below :
There are many modes of stroage of data in computer memory. For
example integers are stored in :
1. Signed bit magnitued form
2. One's complement form
3. Two's complement form
4. Binary coded decimal(BCD).
This knowledge of physical storage of data along with the valid
opertaions permitted, permits the user to create , access and
change the data.
Presentation Transcript
Your Facebook Friends on WizIQ