DS-Chap-1 - Introduction To Data Structure
DS-Chap-1 - Introduction To Data Structure
∙ Definition Of DS
∙ Types Of DS
∙ Characteristics of DS
Definition of DS:
A data structure is an arrangement of data in a computer’s memory or even disk storage so
that it can be used efficiently.
An example of several common data structures are arrays, linked lists, queues, stacks,
binary trees, and hash tables. Data structure has a different way of storing and
organizing data in a computer so that it can be used efficiently.
Data Structures is about rendering data elements in terms of some relationship, for better
organization and storage. For example, we have some data which has, player's name "Virat"
and age 26. Here "Virat" is of String data type and 26 is of integer data type.
We can organize this data as a record like Player record, which will have both player's name
and age in it. Now we can collect and store player's records in a file or database as a data
structure. For example: "Dhoni" 30, "Gambhir" 31, "Sehwag" 33.
The pointers, however don’t hold a data value, instead, they hold memory addresses of
the data values. These are also called the reference data types.
The Non-primitive data structures are further divided into the following categories:
iii) Stack:
∙ Stack is a linear Data Structure, which is similar to array having orderly collection
of data elements but unlike array, here we can enter and retrieve data from
one end only.
∙ These two operations of entering or retrieving data from Stack is called Push and
Pop.
∙ To enter the value in Stack, we perform Push operation and similarly, to retrieve
or access the value from stack, we use Pop operation. ∙ Here, important thing to
note is that we can perform Push and Pop operation from only one end.
iv) Queue:
∙ Queue is also a linear Data Structure, which is similar to array but here we can
enter the value from one end and access the value from the other end only. ∙ The
node from which we enter or add the element is called Rear End and its opposite
node from which we can access the element is called Front End.
b.
Non-Linear Data Structure:
i) Tree:
∙ As the name suggest, Tree is a Non-Linear Data Structure which store its
elements in the hierarchical manner.
∙ So, it is not required to have elements in tree in a sequence as tree is a Non
Linear Data Structure.
∙ In Tree, there will be one Root Node in top, followed by its Child Node and
those Child Nodes can also form as many sub-trees as required.
ii) Graph:
∙ Graph is a Non-Linear Data Structure which is represented as G={V,E}. Here, V
represents Vertices and E represents Edges.
∙ In Graph, different Vertices are connected with the help of Edges. ∙ We can assign
different weight or cost to different Edges which are connecting the Vertices.
∙ For example – if E1 is the edge connecting V1 and v2, then we can write
E1={V1,V2}.
2. Searching : Finding the location of the record with a given key value or finding the
location of all records which fulfill a certain condition.
6. Merging : Combining the records in two different sorted lists into one sorted list.
Characteristics of Data Structure OR Advantages and Disadvatages:
Data Structure Advantages Disadvantages
Array
∙ Quick inserts ∙ Slow search
stack
∙ Last-in, first-out access ∙ Slow access to other
items
Queue
∙ First-in, first-out access ∙ Slow access to other
items
Linked List
∙ Quick inserts ∙ Quick deletes
∙ Slow search
*********