You are on page 1of 33

DATA STRUCTURES USING C [CSIT124]

LECTURE NOTES
MODULE- I
INTRODUCTION TO DATA STRUCTURES

By Dr. Nancy Girdhar


In this session we will talk… ASET

• Course outline and overview


– What is your ideas on Data Structures
– What are we going to study
– Why we will study this
– What are we going to learn
• Quizzes and assignments
• And about you all………

2
Before we Start….. ASET

• Email: ngirdhar@amity.edu

• Google Classroom Codes:

X Batch_Lab: v5t3ftw

Y Batch_Lab: tugcd3b

Theory_Lectures: dogxhmu
3
Course Content
Module 1: Introduction to Data Structures

Module 2: Stacks and Queues

Module 3: Programming with Linked Lists

Module 4: Trees

Module 5: Searching and Sorting

Module 6: Graph and their Applications


Module I : Introduction to Data Structures
• Definition, Types. Algorithm design, Complexity, Time-Space
Tradeoffs. Use of pointers in data structures.

• Array Definition and Analysis, Representation of Linear Arrays in


Memory, Traversing of Linear Arrays, Insertion And Deletion, Single
Dimensional Arrays, Two Dimensional Arrays, Multidimensional
Arrays, Function Associated with Arrays, Character String in C,
Character String Operations, Arrays as parameters, Implementing One
Dimensional Array, Sparse matrix.
Books and References
Textbook:
• Yashwant Kanetkar, ”Data Structure using C”, BPB Publication, 5th Edition ,2011
• A.Tannenbaum,Y. Lanhgsam and A.J. Augenstein ,” Data Structures Using C And C++ “,Prentice Hall of
India,2nd Edition,2009.
• Jean-Paul Tremblay, P.G Sorenson, “An Introduction to Data Structures with applications”, Mcgraw-Hill ,2nd
Edition ,1984.

References:
• Robert L Kruse, “Data Structure and Program Design in C”, Prentice Hall (1991).
• Noel Kalicharan ,“Data Structure in C” ,Ist Edition Create space publisher, 2008.
• Mark Allen Weiss,“Data Structure and algorithm Analysis in C”,2nd Edition AddisonWesley,1996.
• E. Balagurusamy, “Problem Solving through C language”, TMH publication, Fourth Edition, 2008.
• R.S Salaria ,“Data Structures & Algorithms using C”,Khanna Publication,4th Edition,2009
• E.Horowitz and S.Sahni,”Fundamentals of Data Structures in C “,2nd Edition, Universities Press,2008
Introduction : Definitions
What is an Algorithm ?
What is an Algorithm ?

An algorithm is a sequence of instructions that one must


perform in order to solve a well formulated problem.
Algorithm Vs Program?

A program is an implementation of
an algorithm to be run on a specific
computer and operating system.

An algorithm is more abstract - it


does not deal with machine specific
details- think of it as a method to
solve a problem.
What is Data ?
Data Vs Data Structures ?

Data is a collection of raw facts


and figures.

Data structure is a way to


organize - and store the data in
computer memory so that it can
be managed and/or processed
by the computer effectively.
Basic Terminology
• Datum is singular form of data refers to single unit of values eg., 1, 4, 5, a, A,
Datum Z, a, b etc.

• Data means value or set of values eg., 45


Data
• Data is a collection of data items.

• Information is processed data which provides some meaning eg., Roll no:
Information 45

• Knowledge is collection of relevant information (when we apply


Knowledge it).
Basic Terminology
• Data Structure is a way of collecting and organizing data in such a
way that we can perform operations on these data in an effective
Data
way.
Structure

• Data item refers to single unit of values


• Group item : Data item that can be subdivided into sub item. Ex
Name : First Name, Middle initial and Last Name
• Elementary item: Data item that cannot be sub divided into sub
Data Item item Ex : PAN card number / Bank Pass-Book Number is treated as
single item
Basic Terminology
• Entity with similar attributes ( eg., all employees of an
Entity organization) form an entity set.

Informa • Information processed data or data with given attribute.


tion:

• Record is the collection of field values of a given entity.


Record

• Field is a single elementary unit of information representing an


Field attribute of an entity.

• File is the collection of records of the entities in a given entity set.


File
Basic Terminology

Record
 Fixed Length Record: is
where the length of the field
for each record is same i.e,
same amount of space
assigned to each data items
 Variable Length Record:
file records may contain
different lengths
Data Structures and Algorithm
Linear ordered data.
Linked list Not in consecutive memory
Representation or location
organization of data/
data structures
Arrays Linear ordered data in
consecutive memory location

Program Non-linear data structure


Trees
Stored on hierarchal order

Step by step procedure/ Select and use suitable data


algorithm structure depending on the
problem
Types of Data Structures
Different types of Data Structures
Types of Data Structures
There are two major categories of data structures:

1) Simple or basic or primitive


e.g., char, short, int, long, float, double etc.

2) Complex or compound
(i) Linear
e.g. arrays, stacks, queues, linked list etc.
(ii) Non-Linear
e.g. trees, graphs etc.
Classification Data Structures

Linked
i
Basic Operation on Data Structures
Basic Operations on Data Structures
Traversing

Searching
The data in the data
structures are processed
by certain operations:
Insertion

Deletion

Sorting

Merging
Operations on Data Structures
Accessing each record exactly once so that
Traversing certain items in the record may be processed.

Finding the location of a particular record with a


Searching given key value, or finding the location of all
records which satisfy one or more conditions.

Insertion Adding a new record to the structure


Operations on Data Structures

Deletion Removing the record from the structure

Managing the data or record in some logical order


Sorting
(ascending or descending order).

Combining the record in two different sorted


Merging files into a single sorted file.
Lets’ Summarize!

Let’s Revise
collecting and _________
• Data Structure is a way of ________ organizing data in such

operations on these data in an


a way that we can perform ___________
effective way.
value
• Data means ________ values
or set of _______ or Data is a collection
raw facts
of __________
Let’s Revise
• Record

Fixed Length Record


1. _______________ all records contain the same data items with the
same amount of space assigned to each data items

Variable Length Record


2. ________________ file records may contain different lengths
Let’s Revise

Exactly once
• Traversing: Accessing each record _______________ so that certain items in the record
may be processed.
Searching
• ___________ Finding the location of a particular record with a given key value, or finding the

location of all records which satisfy one or more conditions.


Inserting Adding a new record to the structure.
• __________:
Deleting Removing the record from the structure.
• __________
Logical order
• Sorting: Managing the data or record in some _____________
Merging
• ____________: Combining the record in two different sorted files into a single sorted file.
Match the Following

1 Information a address
2 Record b Collection of field values
3 File c Collection of records
4 Data d Family
5 Data item e mobile number
6 Group item f pincode
7 Elementary item g processed data
h Single unit of values
i Value
Let’s Revise
Fill positions marked in numbers to classify types of
data structures
Let’s Revise
Thank you !

You might also like