Introduction
to
Data Structures
Definition
Data structure is representation of the logical relationship
existing between individual elements of data.
In other words, a data structure is a way of organizing all data
items that considers not only the elements stored but also
their relationship to each other.
Data structure affects the design of both structural &
functional aspects of a program.
Program=algorithm + Data Structure
You know that a algorithm is a step by step procedure to solve
a particular function.
Introduction
That means, algorithm is a set of instruction
written to carry out certain tasks & the data
structure is the way of organizing the data with
their logical relationship retained.
To develop a program of an algorithm, we should
select an appropriate data structure for that
algorithm.
Therefore algorithm and its associated data
structures from a program.
Classification of Data Structure
Data structure are normally divided into
two broad categories:
Primitive Data Structure
Non-Primitive Data Structure
Classification of Data Structure
Data structure
Primitive DS Non-Primitive DS
Integer Float Character Pointer
Classification of Data Structure
Non-Primitive DS
Linear List Non-Linear List
Array Queue Graph Trees
Link List Stack
Primitive Data Structure
There are basic structures and directly
operated upon by the machine instructions.
In general, there are different representation
on different computers.
Integer, Floating-point number, Character
constants, string constants, pointers etc, fall
in this category.
Non-Primitive Data Structure
There are more sophisticated data structures.
These are derived from the primitive data
structures.
The non-primitive data structures emphasize on
structuring of a group of homogeneous (same
type) or heterogeneous (different type) data
items.
Non-Primitive Data Structure
Lists,
Stack, Queue, Tree, Graph are example of
non-primitive data structures.
The design of an efficient data structure must
take operations to be performed on the data
structure.
Non-Primitive Data Structure
The most commonly used operation on data
structure are broadly categorized into following
types:
Create
Selection
Updating
Searching
Sorting
Merging
Destroy or Delete
Difference
A primitive data structure is generally a basic structure
that is usually built into the language, such as an integer,
a float.
A non-primitive data structure is built out of primitive
data structures linked together in meaningful ways, such
as a or a linked-list, binary search tree, AVL Tree, graph
etc.
Operations on different Data Structure:
There are different types of operations that can be performed for
the manipulation of data in every data structure. Some operations
are explained and illustrated below:
Traversing: Traversing a Data Structure means to visit the element
stored in it. This can be done with any type of DS.
Searching: Searching means to find a particular element in the
given data-structure. It is considered as successful when the
required element is found. Searching is the operation which we can
performed on data-structures like array, linked-list, tree, graph, etc.
Operations on different Data Structure:
Insertion: It is the operation which we apply on all the data-
structures. Insertion means to add an element in the given data
structure. The operation of insertion is successful when the
required element is added to the required data-structure. It is
unsuccessful in some cases when the size of the data structure is
full and when there is no space in the data-structure to add any
additional element.
Deletion: It is the operation which we apply on all the data-structures.
Deletion means to delete an element in the given data structure. The
operation of deletion is successful when the required element is deleted
from the data structure.
Operations on different Data Structure:
Insertion: It is the operation which we apply on all the data-
structures. Insertion means to add an element in the given data
structure. The operation of insertion is successful when the
required element is added to the required data-structure. It is
unsuccessful in some cases when the size of the data structure is
full and when there is no space in the data-structure to add any
additional element.
Deletion: It is the operation which we apply on all the data-structures.
Deletion means to delete an element in the given data structure. The
operation of deletion is successful when the required element is deleted
from the data structure.
Operations on different Data
Structure:
Insertion: Insertion means addition of a new data element in a data
structure.
Deletion: Deletion means removal of a data element from a data
structure if it is found.
Searching: Searching involves searching for the specified data
element in a data structure.
Traversal: Traversal of a data structure means processing all the data
elements present in it.
Sorting: Arranging data elements of a data structure in a specified
order is called sorting.
Merging: Combining elements of two similar data structures to form a
new data structure of the same type, is called merging.