1. B.Sc III Year (IT)
Paper II- Software
Data Structure
Unit I:- Introduction to Data Structure
By :
Vidya Classes
Asstt Professor
Department of Computer Science & IT
1
2. Contents
• What is Data Structure
• Types of Data Structure
• Operations of Data Structure
• Abstract Data structure
• Analysis of Algorithm
• Characteristics of Algorithm
• Criteria of Algorithm Analysis
• Time Complexity
• Space Complexity
• Concept of List and array
2
3. What is Data Structure
• A data structure is a particular way of organizing data in a computer
so that it can be used effectively.
• For example, we can store a list of items having the same data-type
using the array data structure.
• The data structures mainly deal with the study of
1. How the data is organized in the memory
2. How efficiently the data can be retrieved and manipulated
3. How efficiently the data can be stored in the memory
4. The possible ways in which different data items are logically related
3
4. Types of Data Structure
The Data structures can be classified into two parts
1. Primitive
The primitive Data structures are data structures that can be manipulated directly by
machine instructions
Example-Integers , Floating point number, Character, Double, Pointer
2. Non Primitive
The Non-primitive data structures are data structures that cannot be manipulated directly
by machine instructions
Non-primitive data structure are further classified as below
1. Linear Data Structure
Data structure which is arranged in a sequence to represent given information is
called Linear Data Structure
Example-Array ,Queues ,Stacks , Linked list
2. Non-linear Data structure
Data Structure which is arranged in any form is called Non-linear Data structure.
Example-Graph,Tree 4
5. Operations of Data Structure
• Traversing
Processing each element in the array or list .
• Insertion
Adding a new element to the list.
• Deletion
Removing an element from the list.
• Updation
This allows the user to modify the given set of element in the list.
• Searching
Finding the location of the element with a given value with a given key.
• Sorting
Arranging the data in a proper order that is in ascending or descending.
5
6. Abstract Data structure
• It focus on the essentials of a data storage structure without knowing
about its implementation.
• Focusing on what it does and ignoring how it does it
• Example-Stacks and Queues
6
7. Analysis of Algorithm
• The procedure of writing an algorithm is called designing of algorithm.
• Written in human understandable code to solve problem
• For one problem many algorithms can be designed
• Performance of the program depend on algorithm
• Design the algorithm ,it can be analysed then find out the performance of
an algorithm is called analysis of algorithm
7
9. Criteria of Algorithm Analysis
9
Criteria of Algorithm Analysis
Computation Time(Time complexity)
Storage needs or Requirements(Space complexity
10. Time Complexity
• The total amount of computer time(compilation time and run time)
needed to complete the execution of an algorithm is called time
complexity
10
Operation Unit of Run Time Remark
Num=10 1 1 for assignment
Sum=sum+10 2 1 for addition and 1 for assignment
SI=PTR/100 4 2 for multiplication,1 for division and 1 for assignment
Num!=0 1 1 for condition
Return Sum 1 1 for return statement
11. Space Complexity
• The total amount of computer memory needed to complete the execution of
an algorithm is called as space complexity
• S(A)=C +Sa
Where S(A) is space complexity of algorithm
C is constant ,space for fixed component of algorithm A
Sa is the Variable space required for variable component+STACK space
11
Space complexity
Fixed
Variable
Space for code
Space for constants
Space for Fixed variable
Space for problem dependent variables
Space for the STACK in case of recursion
12. Concept of List and array
• List:-
Grouping or listing of same type of objects or things to identify as a
single unit
• Example-1.List of employees in ‘Sales’ department
2.List of marks obtained by students
• Array:-
Collection of similar elements
• Array is synonym for list
• The lists of the real life are converted into arrays in data structure
12