Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
37 views46 pages

Unit 1

Uploaded by

vsjadhav1085
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views46 pages

Unit 1

Uploaded by

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

MRS.

RAJANEE KAVATHEKAR
LECTURER (COMPUTER DEPT.)
LESP, KUPWAD, SANGLI
COURSE TITLE Data Structure using 'C' (DSU)

COURSE CODE 22317

ACADEMIC YEAR 2020-21

150
Theory – 70 ESE + 30 PA
TOTAL MARKS
Practical – 25# ESE + 25 PA
# - External Assessment
Course Outcomes:
Syllabus
Unit - 01
Introduction to Data Structure

1 Concept & Need of DS, Abstract Data Type

2 Types of Data Structure: Linear, Non Linear DS

3 Algorithm Complexity: Time, Space

Operations on DS: Traversing, searching, insertion,


4 deletion, sorting
Syllabus
Unit - 02

Searching & Sorting


Searching : searching an item in data set
1 using following methods: linear Search,
binary Search

Sorting: sorting of data set in an order using


2 following method: bubble sort, selection sort,
insertion sort, quick sort, radix sort
Syllabus
Unit - 03
Stacks & Queues

Introduction to Stack: stack representation in memory using array;


stack as an ADT; stack operations- PUSH & POP; stack operations
1 conditions - stack full, stack overflow, stack empty, stack underflow;
Applications of stack- reversing a string, polish notations

Conversion of infix to postfix expression, evaluation of postfix


2 expression, converting an infix into prefix expression, evaluation of
prefix expression, recursion, tower of Hanoi

Introduction to Queue: Queue representation in memory using array;


queue as an ADT; types of queue- linear, circular queue, priority of
3 queue; queue operations - INSERT & DELETE; queue operation
conditions- queue full, queue empty; applications of queue
Syllabus
Unit - 04
Linked List
Introduction to Linked List; terminologies- node,
1 address, pointer, information field/data field, next
pointer, null pointer, empty list

2 Types of List: linear list, circular list

Operations on singly linked list: traversing a singly


3 linked list, searching a key in linked list, inserting a
new node in a list, deleting a node from a linked list
Syllabus
Unit - 05
Trees & Graphs
Introduction to Trees: Terminogies : tree, degree
of a node, degree of a tree, level of a node, leaf
1 node, depth/height of a tree, indegree/outdegree,
path, ancestor & descendant nodes
Tree types & traversal methods: types of trees -
General tree, binary tree, BST; Binary tree
2 traversal - in order, preorder and post order
traversal
3 Expression Tree
Syllabus
Unit - 05

Trees & Graphs


Introduction to graph terminologies: graph, node
(vertices), arcs (edges), directed graph,
4 undirected graph, indegree, outdegree, adjacent,
successor, predecessor, relation, path, sink,
articulation point

Adjacency List, Adjacency matrix of


5 directed/undirected graph
Data Representation:
✓ Data is a collection of numbers, alphabets and symbols
✓ Binary System Representation of Data

✓ An Integer Number is represented by its binary


equivalent
✓ A negative Number is represented using 2’s
compliment representation
✓ A Character is represented ASCII number

✓ A Real Number is represented using IEEE


representation format
Data:
✓ Data is a collection of
numbers, alphabets and
symbols.
Data
Atomic Data
Ex: Non
decomposable

Composite Data
Ex: Date of
birth
Data:
✓ Data is a collection
of numbers, alphabets
and symbols. ✓ Composite Data -
Example

Month

Day Year

Date-of-
Birth
Data types in ‘C’
Syntax :
data_type variable name;
Example:
int x;

[‘x’ variable can hold , integer type


data]
Data types in ‘C’:
Abstract Data Type (ADT):
✓ Abstract data type (ADT) is a data type that is
organized in a such a way that the specification of the
objects and the operations on the objects is separated
from the representation of the objects and the
implementation of the object.
Concept of Data Structure
 Data Structure is a data organization,
management and storage format that
enable efficient access & modification.
 Data Structure is a way in which data is
stored on computer.
The data structure is concerned with the
following things –
 Organization of data

 Associativity among data elements

 Accessing Methods

 Operations on data
Need of Data Structure
 Each Data Structure allows data to
be stored in specific manner.
 Data Structure allow efficient data
search and retrieval.
 It allows to manage large amount of
data.
Linear & Non Linear Data
Structure
Linear & Non Linear Data Structure
Linear data Structure
 Elements are arranged in linear fashion. A
data structure in which all data elements are
stored in a particular sequence is known as
linear data structure.
 Examples: Array, Stack, Queue

Array:-

Queue:-
Non-Linear Data Structure
 A data structure in which all data elements
are not stored in any particular sequence is
known as nonlinear data structure.

 All one-many, many-one, many-many


relations are handled through non linear
data structure.

 Every data element can have number of


predecessors as well as successors.
 Examples: Tree, Graph

Tree:-

Graph:-
Classification of Data
Structure
 Primitive Data Structure:- These data
types are available in programming language
as built in type.
 They are operated upon machine level
instructions.

 Non-Primitive Data Structure:-These


Data Structures are Derived from Primitive
data structures.
 A set of homogeneous and heterogeneous
data elements are stored together
Operations on Data Structure
Operations on Data Structure
 There are 8 operations that can be performed on
Data Structures.
 These are:

1. Creation: Creating a data structure according to
the requirement.
eg: an integer array of 5 values.

int ar[5]; //ar is the name of array
Operations on Data Structure
2. Insertion: Inserting values into data
structure.

There can be three ways to insert elements into


data structure:

at the beginning,
at the end and
at the desired location.
Operations on Data Structure

3. Traversal: Visiting each element of the data


structure at least once.
Operations on Data Structure
4. Search: Searching of an element in the
given number of elements.

The elements can be searched in two ways:

a. Linear Search: Simplest way of


searching an element.
b. Binary Search: It works on divide and
conquer rule.
Operations on Data Structure
5. Sorting: Rearranging the elements in a
paritcular order, ascending or descending order.

There are several sorting algorithms:


a. Bubble Sort
b. Selection Sort
c. Quick Sort
d. Merge Sort
e. Radix Sort etc.
Operations on Data Structure

6. Merging: Combining the data items of two


sorted files into single file in the sorted form.
Operations on Data Structure

7. Updation: Updating the current value in the


data structure with some new value.
Operations on Data Structure
8. Deletion: Deleting the undesired value
from the data structure.

There are 3 ways to delete a value from data


structure.
These are:
from the beginning,
from the end and
from the given location.
Introduction to Algorithms
 An Algorithm is a mathematical
process to solve a problem using a
finite number of steps.
How to Design an Algorithm?
 In-order to write an algorithm, following
things are needed as a pre-requisite:
✓ The problem that is to be solved by this
algorithm.
✓ The constraints of the problem that must
be considered while solving the problem.
✓ The input to be taken to solve the
problem.
✓ The output to be expected when the
problem the is solved.
✓ The solution to this problem, in the given
constraints.
Example: Consider the example to add three
numbers and print the sum.
•Step 1: Fulfilling the pre-requisites
As discussed above, in order to write an algorithm, its
pre-requisites must be fulfilled.
1)The problem that is to be solved by this algorithm:
Add 3 numbers and print their sum.
2)The constraints of the problem that must be
considered while solving the problem: The numbers
must contain only digits and no other characters.
3)The input to be taken to solve the problem: The
three numbers to be added.
4)The output to be expected when the problem the is
solved: The sum of the three numbers taken as the
input.
5)The solution to this problem, in the given
constraints: The solution consists of adding the 3
numbers. It can be done with the help of ‘+’ operator,
or bit-wise, or any other method.
•Step 2: Designing the algorithm
Now let’s design the algorithm with the help of above pre-
requisites:

Algorithm to add 3 numbers and print their sum:

1)START
2)Declare 3 integer variables num1, num2 and num3.
3)Take the three numbers, to be added, as inputs in
variables num1, num2, and num3 respectively.
4)Declare an integer variable sum to store the resultant
sum of the 3 numbers.
5)Add the 3 numbers and store the result in the variable
sum.
6)Print the value of variable sum
7)END
Different Approaches to Design an
Algorithm?
1. Top down 2. Bottom up
Approach Approach
What is Algorithm Complexity and How to find
it?
An algorithm is defined as complex based on the
amount of Space and Time it consumes.

The two factors of Algorithm Complexity are:

✓ Time Factor: Time is measured by counting the


number of key operations such as comparisons in the
sorting algorithm.

✓ Space Factor: Space is measured by counting the


maximum memory space required by the algorithm.
What is Algorithm Complexity and How to find
it?
Therefore the complexity of an algorithm can be divided
into two types:
1)Space Complexity: Space complexity of an algorithm
refers to the amount of memory that this algorithm
requires to execute and get the result. This can be for
inputs, temporary operations, or outputs.

How to calculate Space Complexity?

1)Fixed Part: For example, input variables, output


variables, program size, etc.

2. Variable Part: For example, temporary variables,


dynamic memory allocation, recursion stack space, etc.
What is Algorithm Complexity and How to find it?
2 )Time Complexity:

Time complexity of an algorithm refers to the amount of


time that this algorithm requires to execute and get the
result. This can be for normal operations, conditional if-
else statements, loop statements, etc.

How to calculate Time Complexity?

1. Constant time part: For example, input, output, if-else,


switch, etc.

2. Variable Time Part: For example, loops, recursion,


etc.
Analysis of Algorithms
We can have three cases to analyze an
algorithm:

1) Worst Case
2) Average Case
3) Best Case
Assignment 1
1)Give classification of data structure. (W-19)
2) Define the terms : linear data structure and non-
linear data structure. (W-18)
3) Differentiate between linear and non-linear data
structures on any two parameters. (S-19)
4) List any four operations on data structure. (S-19)(W-
19)
5) Define the term algorithm. (W-18)
6) Explain time and space complexity with an example.
(w-19)

You might also like