Subject Code: Subject Name:: CS8391 Data Structures

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Subject Code: CS8391

Subject Name : Data Structures

14-08-2021 CS8391-DataStructures 1
EVOCATION

14-08-2021 CS8391-DataStructures 2
EVOCATION

14-08-2021 CS8391-DataStructures 3
UNIT -1

LINEAR DATA STRUCTURES – LIST


Abstract Data Types (ADTs) – List ADT – array-based implementation – linked list implementation
–– singly linked lists- circularly linked lists - doubly-linked lists – applications of lists –Polynomial
Manipulation – All operations (Insertion, Deletion, Merge, Traversal).

14-08-2021 CS8391-DataStructures 4
Data Structures & Abstract Data Types(ADT)

14-08-2021 CS8391-DataStructures 5
History of Programming
SPAGHETTI CODE
(non structured ,Linear
Program)

MODULAR
PROGRAMMING
(Programs into function)

STRUCTURED
PROGRAMMING
(uses control flow constructs)

14-08-2021 CS8391-DataStructures 6
Atomic Data and Composite Data
Atomic data:
• Atomic data are data that consist of a single piece of information.

• cannot be divided into other meaningful pieces of data.

• For example, the integer 4562 may be considered a single integer value.

• we can decompose it into digits, but the decomposed digits do not have the same
characteristics of the original integer; they are four single-digit integers ranging from
0 to 9.

• In some languages atomic data are known as Scalar Data.

14-08-2021 CS8391-DataStructures 7
Composite Data:
• Composite data can be broken out into subfields that have meaning.

• Example : Consider your telephone number.

• A telephone number actually has three different parts. First, there is the area code.

• Then, what you consider to be your phone number is actually two different data items, a prefix
consisting of a three-digit exchange and the number within the exchange, consisting of 4 digits

14-08-2021 CS8391-DataStructures 8
Data Type
• A data type consists of two parts:

❖ a set of data and

❖ the operations that can be performed on the data.

TYPE VALUES OPERATION

Integer -∞, … , -2, -1, 0, 1, *, +, -, %, /, ++, - -,


2,… , ∞ …
Floating Point -∞, … , 0.0, … , ∞ *, +, -, /, …
Character \0, …, 'A', 'B', … , <, >, …
'a', 'b', … , ~

14-08-2021 CS8391-DataStructures 9
Data Structure

• A data structure is an aggregation of atomic and composite data into a set with defined
relationships.

• In this definition structure means a set of rules that holds the data together.

• Data structures can be nested. We can have a data structure that consists of other data structures.

14-08-2021 CS8391-DataStructures 10
Why Data Structures?
Program = DS + Algorithm

✔ Data structures and Algorithms are the nuts-and-bolts used by programmers to store and
manipulate the data efficiently in computer memory.

✔ Data structure is a particular way of storing and organizing information in a computer so that it
can be retrieved and used most productively.

✔ An algorithm is a step by step method or instructions to solve a problem.

14-08-2021 CS8391-DataStructures 11
Definition of Data Structures
• A data structure is a particular way of storing and organizing data in a computer memory
efficiently.

• Helps us to identify logical relationship between data.

• If the data are stored in a particular format, then it will be easy for processing and retrieval of
those data.

• Data structure is a key organizing factor in the software design.

14-08-2021 CS8391-DataStructures 12
What do you meant by Efficient Program?
Efficient program is determined by its time and space complexity.

• Time complexity states the time needed to execute (compile as well as run time) a given
program.

• Space complexity states the memory space needed to store and process the program.

Program-1 (LOC=4) Program-2 (LOC=7)


#include<stdio.h> #include<stdio.h>
void main() void main()
{
{
int a, b, c, d;
int a, b;
printf(“Enter 2 nos for addition\n”);
printf(“Enter 2 nos for scanf(“%d %d”, &a, &b);
addition\n”); c=a; d=b; e=c+d;
scanf(“%d %d”, &a, &b); printf(“Sum=%d\n”, e);
printf(“Sum=%d\n”, a+b); }
14-08-2021 } CS8391-DataStructures 13
Classification of Data Structures

14-08-2021 CS8391-DataStructures 14
Primitive Data Structures

• These are the predefined way of storing data in the system.

• All sets of operations are pre-defined.

• Char, int, float, double are examples of primitive data structures.

Non-Primitive Data Structures

• The data structures which are designed using primitive data structures are called non-primitive data
structures.

• They are used to store a collection of data. It can be categorized into two parts:

• Linear data structure

• Non-Linear data structure

14-08-2021 CS8391-DataStructures 15
Contd..

14-08-2021 CS8391-DataStructures 16
Contd..

14-08-2021 CS8391-DataStructures 17
• Array:

• Stack:

• Queue:

• Linked List:

14-08-2021 CS8391-DataStructures 18
• Graph:

• Tree:

14-08-2021 CS8391-DataStructures 19
Application of Data Structures
• The field of computer science will address the task of storing, accessing & manipulating data.

• DS & algorithm are common to almost all application of computer science. Some of the applications are,
Compiler design
Operating System
Data Base Management System
Networking
Graphics
Artificial Intelligence
Statistical analysis
System software design
Robotics etc.,

14-08-2021 CS8391-DataStructures 20
Contd..
Difference between datatype and data structure:
Data type:

• Represents what kind of data to be stored.

• Eg: integer, float, character, etc.

Data structure:

• How to store the data or in which format, data are to be stored.

• Eg: array, stack, queue, list, tree, graph, etc.

14-08-2021 CS8391-DataStructures 21
MIND MAP

14-08-2021 CS8391-DataStructures 22
Summary
Introduction to Data Structures
• Why data structures?
• Definition of Data Structure
• Classification of data structures
• Linear
• Non-linear
• Applications of Data Structures
• Abstract Data Types (ADTs)
• Definition of ADT
• Why ADT?
• Modular Programming

14-08-2021 CS8391-DataStructures 23

You might also like