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

Lecture 1 - Introduction

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Lecture 1 - Introduction

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Data Structures -1

G Bharathi Mohan
Assistant Professor
Primitive data structures
• Primitive data structure is a fundamental type of data structure that
stores the data of only one type
• Primitive data structure is a data structure that can hold a single value
in a specific location
• The examples of primitive data structure are float, character, integer
and Boolean

Data Structures-1 3
Non primitive Data Structures
• The non-primitive data structure is a kind of data structure that can
hold multiple values either in a contiguous or random location.
• The non-primitive data types are defined by the programmer.
• The non-primitive data structure is further classified into two
categories, i.e., linear and non-linear data structure
• Linear data structure is a sequential type of data structure-all the
elements in the memory are stored in a sequential manner - Array,
Linked list, Stack, Queue.
• Non-linear data structure is a kind of random type of data structure.
The non-linear data structures are Tree and Graph.
Data Structures-1 4
Data Structures- Linear and non- linear

• Data structure is a method of organizing a large amount of data more


efficiently so that any operation on that data becomes easy.
• Based on the organizing method of data structure, data structures are divided
into two types.
• Linear Data Structures-If a data structure organizes the data in sequential
order, then that data structure is called a Linear Data Structure.
• Example- Arrays,List (Linked List), Stack, Queue
• Non - Linear Data Structures-If a data structure organizes the data in random
order, then that data structure is called as Non-Linear Data Structure.
• Example - Tree, Graph, Dictionaries, Heaps

Data Structures-1 5
Introduction to Algorithms
• What is an algorithm?
• An algorithm is a step by step procedure to solve a problem
• algorithm is defined as a sequence of statements which are used to
perform a task.
• An algorithm is a sequence of unambiguous instructions used for
solving a problem, which can be implemented (as a program) on a
computer.

Data Structures-1 6
Introduction to algorithms
• Specifications of Algorithms
• Input - Every algorithm must take zero or more number of
input values from external.
• Output - Every algorithm must produce an output as result.
• Definiteness - Every statement/instruction in an algorithm
must be clear and unambiguous (only one interpretation).
• Finiteness - For all different cases, the algorithm must
produce result within a finite number of steps.
• Effectiveness - Every instruction must be basic enough to be
carried out and it also must be feasible.

Data Structures-1 7
Example for an Algorithm
• Problem Statement : Find the • Algorithm
largest number in the given list • Step 1: Define a variable 'max'
of numbers? and initialize with '0'.
• Input : A list of positive integer • Step 2: Compare first number (say
numbers. (List must contain at 'x') in the list 'L' with 'max', if 'x' is
least one number). larger than 'max', set 'max' to 'x'.
• Output : The largest number in • Step 3: Repeat step 2 for all
the given list of positive integer numbers in the list 'L'.
numbers. • Step 4: Display the value of 'max'
as a result.
Data Structures-1 8
Performance Analysis
• we have more than one algorithm • Whether it is easy to
to solve a problem. understand?
• we need to select the best one. • Whether it is easy to
• Performance analysis helps us to implement?
select the best algorithm from
• How much space (memory) it
multiple algorithms to solve a
problem. requires to solve the problem?
• performance of an algorithm • How much time it takes to solve
depends the problem? Etc.,
• Whether that algorithm is providing • we consider only the space and
the exact solution for the problem? time required
Data Structures-1 9
Performance Analysis
• Performance analysis of an algorithm is the process of calculating
space and time required by that algorithm.
• Performance analysis of an algorithm is performed by using the
following measures.
• Space required to complete the task of that algorithm (Space
Complexity). It includes program space and data space
• Time required to complete the task of that algorithm (Time
Complexity)

Data Structures-1 10
Asymptotic Notation-
Asymptotic notation of an algorithm is a mathematical representation of its
complexity.
• complexity of an algorithm it • we use only the most significant
does not provide the exact terms to represent the time
amount of resource required. complexity of an algorithm.
• represent that complexity in a • THREE types of Asymptotic
general form (Notation) Notations
• Algorithm 1 : 5n2 + 2n + 1 • Big - Oh (O)
• for larger value of 'n' the term • Big - Omega (Ω)
'2n + 1' in algorithm 1 has least • Big - Theta (Θ)
significance than the term '5n2'

Data Structures-1 11
Asymptotic Notation
• Big - Oh notation is used to define • Big - Theta Notation (Θ)
the upper bound of an algorithm • Big - Theta notation is used to
in terms of Time Complexity. define the average bound of an
• describes the worst case of an algorithm in terms of Time
algorithm time complexity. Complexity.
• Big - Omege Notation (Ω) • Big - Theta notation always
• Big - Omega notation is used to indicates the average time
define the lower bound of an required by an algorithm for all
algorithm in terms of Time input values
Complexity.

Data Structures-1 12

You might also like