0% found this document useful (0 votes)
21 views

DS-Chap-1 - Introduction To Data Structure

Uploaded by

Jesica D'cruz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

DS-Chap-1 - Introduction To Data Structure

Uploaded by

Jesica D'cruz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Chapter-1

Introduction to Data Structure

The chapter covers:

∙ Definition Of DS

∙ Types Of DS

∙ Data structure Operations

∙ 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.

The data Structures mainly deal with the study of:

∙ How the data is organized in the memory.

∙ How efficiently the data can be stored in the memory.

∙ How efficiently the data can be retrieved and manipulated.

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.

Types of Data Structure:

1. Primitive data structure:


These are the structures which are supported at the machine level, they can be used to
make non-primitive data structures. These are integral and are pure in form. They have
predefined behavior and specifications.

Examples: Integer, float, character, pointers.

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.

2. Non-primitive Data Structures:


The non-primitive data structures cannot be performed without the primitive data
structures. Although, they too are provided by the system itself yet they are derived
data structures and cannot be formed without using the primitive data structures.

The Non-primitive data structures are further divided into the following categories:

a. Linear data structure


b. Non-linear data structure
a. Linear data structure:
In linear data structures, values are arranged in linear fashion. Arrays, linked lists,
stacks and queues are examples of linear data structures in which values are stored in
a sequence.
i) Array:
∙ Array is collection of data of similar data type and all the data of an array are
stored at consecutive (sequential) memory locations.
∙ If we do not know the memory to be allocated in advance then array can lead to
wastage of memory.
∙ Also, insertions and deletions are complex in arrays since elements are stored in
consecutive memory allocations.

ii) Linked List:


∙ The lists support dynamic memory allocation. The memory space allocated, can
be changed at run time also.
∙ Like arrays, Linked List is a linear data structure. Unlike arrays, linked list
elements are not stored at a contiguous location; the elements are
linked using pointers.
∙ Linked List is a linear Data Structure, which consist of many nodes. ∙ Each node is
consist of Data Item and a Pointer which contains address to it next node.
∙ A pointer variable in the node is used to point to it next node.

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}.

Data Structures Operations:


The different operations that are to be carried out on data are nothing but designing of
data structures. Following are the data structure operations

1. Traversing : accessing each record exactly once.

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.

3. Inserting : Adding a new record into the data structure

4. Deleting : Deleting record from the data structure

5. Sorting : Arranging the records in some logical order.

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

∙ Fast access if index is ∙ Slow deletes


known

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

*********

You might also like