SlideShare a Scribd company logo
1 of 41
Download to read offline
Preliminaries Chapter-2
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Mathematical Notations and Functions
• The following mathematical functions appear very
often in the analysis of algorithms and in computer
science.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Floor & Ceiling Functions
• Let x be any real number.
• Then x lies between two integers called the floor and the ceiling of x.
• Լ x┘ called the floor of x, denotes the greatest integer that does not exceed x.
• Floor(3.14)=3
• Floor(-8.5)=-9
• ΓxꞀ called the ceiling of x, denotes the least integer that is not less than x.
• Example
• Ceiling(3.14)=4
• Ceiling(-8.5)=-8
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Remainder Function; Modular Arithmetic
• Let k be any integer and let M be a positive integer, then
• K Mod M
• Will denote the integer remainder when k is divided by M.
• More exactly, k Mod M is the unique integer r such that
• k = Mq + r where 0 ≤ r < M
• Example:
• 25 Mod 7 = 4 (25 = 7*3 + 4)
• 35 Mod 11 = 2 (35 = 11*3 + 2)
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Integer Function
• Let x be any real number.
• The integer value of x, written as INT(x) converts x into an
integer by deleting the fractional part of the number.
• INT(3.14)=3
• INT(-8.5)=-8
• OBSERVE:
• INT(x) = Floor(x)
• Or
• INT(x) = Ceiling(x)
o according to whether x is positive or negative.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Absolute Value Function
• The absolute value of the real number x, written as ABS(x) or |x|
is defined as the greater of x or –x.
• ABS(0) = 0
• |-15| = 15
• |4.44| = 4.44
• Note that |x| = |-x|
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Summation
• The summation symbol is ∑ (sigma).
• Consider the sequence a1,a2,a3,… then the sums
• a1+a2+a3…+an
and
• am+am+1+…+an
• Will be denoted respectively by
• σ𝒋=𝟏
𝒏
𝒂𝒋
• σ𝒋=𝒎
𝒏
𝒂𝒋
• Here j is called as the dummy index or dummy variable.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Factorial Function
• The product of the positive integers from 1 to n, inclusive, is
denoted by n!
• That is
• n! = 1 x 2 x . . . X (n-2) x (n-1) x n
• Example:
• 4 ! = 1 x 2 x 3 x 4 = 24
• 5 ! = 5 x 4! = 5 x 24 = 120
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Permutations
❖A permutation of a set of n elements is an arrangement of
the elements in a given order.
❖For example, the permutations of the set consisting of the
elements a, b and c are as follows:
❖Abc
❖Acb
❖Bac
❖Bca
❖Cab
❖Cba
❖There are n! permutations of a set of n elements.M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Exponents & Logarithms:
• Recall for any integer m,
• am= a . a. . . . a (m times)
• a0 = 1
• a-m =
1
𝑎 𝑚
• Exponents are extended to include all rational numbers by
defining, for any rational number m/n,
• am/n = 𝑛
𝑎 𝑚 = ( 𝑛
𝑎 )m
• Exponents are extended to include all real numbers by
defining for any real number x,
• ax = lim
𝑟→𝑥
𝑎 𝑟
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
• Logarithms are related to exponents as follows.
• Let b be a positive number the logarithm of any positive
number x to the base b written as
• log 𝑏 𝑥
• Represents the exponent to which b must be raised to
obtain x. that is
• Y = log 𝑏 𝑥
and
• by = x
• The logarithm of 0 and the logarithm of negative number
are NOT DEFINED.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Algorithmic Notations.
1. Identifying Number
✓Each algorithm is assigned an identifying number.
✓Example Algorithm 4.3 refers to the 3rd algorithm in chapter 4.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Algorithmic Notations.
2. Steps, Control, Exit
✓Each steps of the algorithm are executed one after the other, beginning
with step-1.
✓Control may be transferred to step n of the algorithm by the statement
“Go to Step n”.
✓These “goto” statements may be eliminated by using certain control
structures.
✓If several statements appear in the same step like SET K:=1, LOC:=1,
then they are executed from left to right.
✓The algorithm is completed with the statement EXIT.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Algorithmic Notations.
3. Comments
✓Each step may contain a comment in brackets which indicates the
main purpose of the step.
✓The comment will usually appear at the beginning or at the end of
the step.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Algorithmic Notations.
4. Variable Names
✓Variable names will use capital letters (Eg. MAX, DATA)
✓Single letter names of variables used as counters or subscripts will
also be capitalized in the algorithms.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Algorithmic Notations.
5. Assignment statement
✓Assignment statements will use the dots-equal notation :=
✓Example MAX := DATA[1]
✓Will assign the value in DATA[1] to MAX.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Algorithmic Notations.
6. Input and output
✓Data may be input and assigned to variables by means of Read
statement with the following form.
✓Read: Variable_names
✓Message placed in quotation marks and data in variables may be
output by means of a Write or Print statement with the following
form.
✓Write: Message and/or variable_names
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Algorithmic Notations.
7. Procedures
✓This term is used for an independent algorithmic module which
solves a particular problem.
✓The use of the word Procedure or Module denotes it.
✓It is used to describe a certain type of sub-algorithm.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
2.4 CONTROL STRUCTURES
Three types of logic or flow-of-control are used:
Sequence Logic (or) Sequential Flow
Selection Logic (or) Conditional Flow
Iteration Logic (or) Repratitive Flow
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Sequence Logic
• Unless instructions given to the
contrary, the modules are executed in
the obvious sequence.
• The sequence may be preseted
explicitly, by means of numbered
steps, or implicitly, by the order in
which the modules are written.
• Most processing will generally follow
this elementary flow pattern.
Module A
Module B
Module CM.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Selection Logic
• Employs a number of conditions which lead to a selection of one out of
several alternative modules.
• The structures which implement this logic are called conditional structures
or IF structures.
• Most processing will generally follow this elementary flow pattern.
• These condition structures fall into three categories.
• Single alternative
• Double alternative
• Multiple alternatives
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Selection Logic – Single Alternative.
• If the given condition holds, then Module-A,
which may consist of one or more statements,
is executed;
• Otherwise Module-A is skipped and control
transfers to the next step of the algorithm.
Structure
If condition then:
[ Module-A]
[End of If Structure]
Condition?
Module - A
Yes
No
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Selection Logic – Double Alternative.
• If the given condition holds, then Module-A,
gets executed;
• Otherwise Module-B is is executed.
Structure
If condition then:
[ Module-A]
Else:
[ Module-B]
[End of If Structure]
Condition?
Module - A
Yes
No
Module - B
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Selection Logic – Multiple Alternatives.
• The logic of this structure allows only one of the modules to be executed.
• Either the modulewhich follows the first condition which holds is executed, or the
module which follows the final Else statement is executed.
Structure
If condition-1 then:
[ Module-A1]
Else If condition-2 then :
[ Module-A2]
…
Else:
[ Module-B]
[End of If Structure]
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Iteration Logic (Repetitive Flow)
• Refers to either of 2 types of structures involving loops.
• Each type begins with a Repeat statement and is followed by a
module, called the body of the loop.
• 2 Types:
• Repeat-for loop
• Repeat-while loop.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Iteration Logic – Repeat-for Loop
• Uses an index variable to control the loop (such
as I,j or k).
• Format:
Repeat for K = R to S by T:
[Module]
[End of loop]
• Here R is called the initial value, S the end
value or test value and T the increment.
• The body of the loop is executed first with K=R,
then with K=R+T, then with K=R+2T and so on.
• The cycling ends when K>s.
Is K > S ?
Module
[ body of loop]
No
Yes
K = K + T
K = R
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Iteration Logic – Repeat-while Loop
• Uses a ocndition to control the loop.
• Format:
Repeat while condition:
[Module]
[End of loop]
• The cycling continues until the condition si
false.
• There must be a statement before the structure
that initializes the condition controlling the
loop.
• There must be a statement in the body of the
loop that changes the condition.
Yes
condition?
Module
[ body of loop]
No
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
2.5 COMPLEXITY OF ALGORITHMS
• Inorder to compare algorithms, we must have some criteria to
measure the efficiency of out algorithm.
• Suppose
• M is an algorithm, and
• n is he size of input data
• The time & space used by the algorithm M are the two main measures for
the efficiency of M.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
2.5 COMPLEXITY OF ALGORITHMS
• The complexity of an algorithm M is the function f(x) which gives
the running time and/or storage space requirement of the
algorithm in terms of the size n of the input data.
• The storage space required by an algorithm is simply a multiple of
the data size n.
• So mostly the term “complexity” refer to the running time of the
algorithm.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
2.5 COMPLEXITY OF ALGORITHMS
• Finding the complexity function f(x) deals with 3 cases in
complexity theory.
• Worst case: the maximum value of f(n) for any possible input.
• Average case: the expected value of f(n)
• Best case: the minimum value of f(n).
Example – Searching an element in Linear search fashion:
• Worst case: The ITEM is at the LAST position or NOT PRESENT in the list.
• Average case: The ITEM appears in the list.
• Best case: The ITEM appears at the FIRST position in the list.M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Rate of Growth; Big O Notation
• Suppose M is an algorithm with the size of input n, the complexity
f(n) of M increases as n increases.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Rate of Growth; Big O Notation
• The rate of increase of f(n) is done by comparing f(n) with some
standard function such as log2 n, n log2 n, n2 , n3 , 2n
• The rate of growth of these standard functions are indicated in
the below table
G(n)
Log n N N log n n2 n3 2n
N
5 3 5 15 25 125 32
10 4 10 40 100 103 103
3100 7 100 700 104 106 1030
1000 10 103 104 106 109 10300M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Rate of Growth; Big O Notation
• Supposef(n) and g(n) are functions with property that f(n) is
bounded by some multiple of g(n) for almost all n,
• Then we may write as
• F(n) = O(g(n))
• This is called as the “big O” notation.
• Example complexity functions of well-known searching and sorting
algorithms:
• Linear search : O(n)
• Binary search : O(log n)
• Bubble sort : O(n2)
• Merge sort : O(n log n)M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
2.6 OTHER ASYMPTOTIC NOTATIONS FOR COMPLEXITY
OF ALGORITHMS Ω , 𝜃 , 𝜊
Omega Notation (Ω)
• The omega notation is used when the function g(n) defines a lower
bound for the function f(n).
• F(n) = Ω (g(n) ), iff there exists a positive integer n0 and a positive
integer M such that |f(n)| >= M|g(n)|, for all n>= n0
• For f(n)=18n+9, f(n)>18n for all n, hence f(n)= Ω(n)
• For f(n)=90n2+18n+6, f(n)>90n2 for n2=0 and therefore f(n)= Ω(n2)
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
2.6 OTHER ASYMPTOTIC NOTATIONS FOR COMPLEXITY
OF ALGORITHMS Ω , 𝜃 , 𝜊
Theta Notation (𝜃)
• The theta notation is used when the function f(n) is bounded both
from the above and below by the function g(n).
• It implies that the function g(n) is both an upper bound and a
lower bound for the function f(n) for all values of n, n>= n0.
• That is f(n) is such that f(n) = O(g(n)) and f(n) = Ω(g(n))
• F(n) = 𝜃 (g(n) ), iff there exists two positive constants c1 and c2
and a positive integer n0 such that c1|g(n)| <= c2 |g(n)|, for all
n>= n0.
• For f(n)=18n+9, f(n)>18n for all n, hence f(n)= Ω(n)
• For f(n)=90n2+18n+6, f(n)>90n2 for n2=0 and therefore f(n)= Ω(n2)
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
2.6 OTHER ASYMPTOTIC NOTATIONS FOR COMPLEXITY
OF ALGORITHMS Ω , 𝜃 , 𝜊
Little Oh Notation (o)
• F(n) = 𝑜(g(n) ), iff f(n)=O(g(n)) and f(n) ≠ Ω(g(n)).
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
2.7 SUBALGORITHMS
• A subalgorithm is a complete and independently defined
algorithmic module which is used by some main module or by
some other subalgorithm.
• A subalgorithm
• receives values called arguments, from an originating algorithm,
• performs calculations, and then
• sends back the result to the calling algorithm.
• The subalgorithm is defined independently so that it may be
called by many different algorithms or called at different times in
the same algorithm.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
2.7 SUBALGORITHMS
• The subalgorithm will have a RETURN statement instead of EXIT
statement. It implies that the control is transferred back to the
calling program when execution of the subalgorithm is completed.
• Subalgorithms fall into 2 basic categories:
• Function subalgorithms – return only a single value to the calling algorithm.
• Procedure subalgorithms – can send back more than one value to the calling
algorithm.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
2.8 VARIABLES, DATA TYPES
• Each variable in any of our algorithms has a data type which
determines the code that is used for storing its value. Four such
data types are:
• Character
• Real (floating point)
• Integer (fixed point)
• Logical
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Local & Global Variables
• The organization of a computer program into a main program and
various subprograms has led to the notion of local and global
variables.
• Each program module contains its own lis of variables called local
variables, which can be accessed only by the particular module.
• Variables that can be accessed by all program modules are called
global variables.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
Local & Global Variables
• There are 2 basic ways for modules to communicate with each
other:
• Directly, by means of well-defined parameters.
• Indirectly, by means of non-local and global variables.
M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.

More Related Content

What's hot

Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & DeletionAfaq Mansoor Khan
 
Dbms Notes Lecture 9 : Specialization, Generalization and Aggregation
Dbms Notes Lecture 9 : Specialization, Generalization and AggregationDbms Notes Lecture 9 : Specialization, Generalization and Aggregation
Dbms Notes Lecture 9 : Specialization, Generalization and AggregationBIT Durg
 
Applications of stack
Applications of stackApplications of stack
Applications of stackeShikshak
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in pythoneShikshak
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTUREArchie Jamwal
 
File handling in Python
File handling in PythonFile handling in Python
File handling in PythonMegha V
 
Java Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECJava Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECSreedhar Chowdam
 
Protection and Security in Operating Systems
Protection and Security in Operating SystemsProtection and Security in Operating Systems
Protection and Security in Operating Systemsvampugani
 
Control structure C++
Control structure C++Control structure C++
Control structure C++Anil Kumar
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]Muhammad Hammad Waseem
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Treekhabbab_h
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler DesignKuppusamy P
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translationAkshaya Arunan
 
Priority queue in DSA
Priority queue in DSAPriority queue in DSA
Priority queue in DSAjunnubabu
 

What's hot (20)

Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & Deletion
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 
Dbms Notes Lecture 9 : Specialization, Generalization and Aggregation
Dbms Notes Lecture 9 : Specialization, Generalization and AggregationDbms Notes Lecture 9 : Specialization, Generalization and Aggregation
Dbms Notes Lecture 9 : Specialization, Generalization and Aggregation
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Predicate logic
 Predicate logic Predicate logic
Predicate logic
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
 
Semaphores
SemaphoresSemaphores
Semaphores
 
Java Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECJava Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPREC
 
Protection and Security in Operating Systems
Protection and Security in Operating SystemsProtection and Security in Operating Systems
Protection and Security in Operating Systems
 
Control structure C++
Control structure C++Control structure C++
Control structure C++
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
 
Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
Priority queue in DSA
Priority queue in DSAPriority queue in DSA
Priority queue in DSA
 

Similar to Data Structures Chapter-2

Lecture 4 - Linear Regression, a lecture in subject module Statistical & Mach...
Lecture 4 - Linear Regression, a lecture in subject module Statistical & Mach...Lecture 4 - Linear Regression, a lecture in subject module Statistical & Mach...
Lecture 4 - Linear Regression, a lecture in subject module Statistical & Mach...Maninda Edirisooriya
 
Operators and expressons
Operators and expressonsOperators and expressons
Operators and expressonsSatveer Mann
 
Machine learning for Data Science
Machine learning for Data ScienceMachine learning for Data Science
Machine learning for Data ScienceDr. Vaibhav Kumar
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning IntroductionKuppusamy P
 
Data mining 8 estimasi linear regression
Data mining 8   estimasi linear regressionData mining 8   estimasi linear regression
Data mining 8 estimasi linear regressionIrwansyahSaputra1
 
Supervised Machine learning Algorithm.pptx
Supervised Machine learning Algorithm.pptxSupervised Machine learning Algorithm.pptx
Supervised Machine learning Algorithm.pptxKing Khalid University
 
supervised-learning.pptx
supervised-learning.pptxsupervised-learning.pptx
supervised-learning.pptxGandhiMathy6
 
Introduction to Regression . pptx
Introduction     to    Regression . pptxIntroduction     to    Regression . pptx
Introduction to Regression . pptxHarsha Patel
 
Curve Fitting - Linear Algebra
Curve Fitting - Linear AlgebraCurve Fitting - Linear Algebra
Curve Fitting - Linear AlgebraGowtham Cr
 
Unit 3 – AIML.pptx
Unit 3 – AIML.pptxUnit 3 – AIML.pptx
Unit 3 – AIML.pptxhiblooms
 
Application of Machine Learning in Agriculture
Application of Machine  Learning in AgricultureApplication of Machine  Learning in Agriculture
Application of Machine Learning in AgricultureAman Vasisht
 

Similar to Data Structures Chapter-2 (20)

Lecture 4 - Linear Regression, a lecture in subject module Statistical & Mach...
Lecture 4 - Linear Regression, a lecture in subject module Statistical & Mach...Lecture 4 - Linear Regression, a lecture in subject module Statistical & Mach...
Lecture 4 - Linear Regression, a lecture in subject module Statistical & Mach...
 
Operators and expressons
Operators and expressonsOperators and expressons
Operators and expressons
 
Machine learning for Data Science
Machine learning for Data ScienceMachine learning for Data Science
Machine learning for Data Science
 
Data structures chapter 1
Data structures chapter  1Data structures chapter  1
Data structures chapter 1
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
 
Data mining 8 estimasi linear regression
Data mining 8   estimasi linear regressionData mining 8   estimasi linear regression
Data mining 8 estimasi linear regression
 
Supervised Machine learning Algorithm.pptx
Supervised Machine learning Algorithm.pptxSupervised Machine learning Algorithm.pptx
Supervised Machine learning Algorithm.pptx
 
supervised-learning.pptx
supervised-learning.pptxsupervised-learning.pptx
supervised-learning.pptx
 
Linear Regression
Linear RegressionLinear Regression
Linear Regression
 
Python Operators.pptx
Python Operators.pptxPython Operators.pptx
Python Operators.pptx
 
Introduction to Regression . pptx
Introduction     to    Regression . pptxIntroduction     to    Regression . pptx
Introduction to Regression . pptx
 
Curve Fitting - Linear Algebra
Curve Fitting - Linear AlgebraCurve Fitting - Linear Algebra
Curve Fitting - Linear Algebra
 
Unit 3 – AIML.pptx
Unit 3 – AIML.pptxUnit 3 – AIML.pptx
Unit 3 – AIML.pptx
 
Caculus
CaculusCaculus
Caculus
 
Caculus.pptx
Caculus.pptxCaculus.pptx
Caculus.pptx
 
Machine learning meetup
Machine learning meetupMachine learning meetup
Machine learning meetup
 
Machine learning
Machine learningMachine learning
Machine learning
 
Application of Machine Learning in Agriculture
Application of Machine  Learning in AgricultureApplication of Machine  Learning in Agriculture
Application of Machine Learning in Agriculture
 
STATISTICS AND PROBABILITY.pptx
STATISTICS AND PROBABILITY.pptxSTATISTICS AND PROBABILITY.pptx
STATISTICS AND PROBABILITY.pptx
 
Tom Teaching Portfolio 20150506
Tom Teaching Portfolio 20150506Tom Teaching Portfolio 20150506
Tom Teaching Portfolio 20150506
 

Recently uploaded

Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 

Recently uploaded (20)

Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 

Data Structures Chapter-2

  • 2. Mathematical Notations and Functions • The following mathematical functions appear very often in the analysis of algorithms and in computer science. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 3. Floor & Ceiling Functions • Let x be any real number. • Then x lies between two integers called the floor and the ceiling of x. • Լ x┘ called the floor of x, denotes the greatest integer that does not exceed x. • Floor(3.14)=3 • Floor(-8.5)=-9 • ΓxꞀ called the ceiling of x, denotes the least integer that is not less than x. • Example • Ceiling(3.14)=4 • Ceiling(-8.5)=-8 M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 4. Remainder Function; Modular Arithmetic • Let k be any integer and let M be a positive integer, then • K Mod M • Will denote the integer remainder when k is divided by M. • More exactly, k Mod M is the unique integer r such that • k = Mq + r where 0 ≤ r < M • Example: • 25 Mod 7 = 4 (25 = 7*3 + 4) • 35 Mod 11 = 2 (35 = 11*3 + 2) M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 5. Integer Function • Let x be any real number. • The integer value of x, written as INT(x) converts x into an integer by deleting the fractional part of the number. • INT(3.14)=3 • INT(-8.5)=-8 • OBSERVE: • INT(x) = Floor(x) • Or • INT(x) = Ceiling(x) o according to whether x is positive or negative. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 6. Absolute Value Function • The absolute value of the real number x, written as ABS(x) or |x| is defined as the greater of x or –x. • ABS(0) = 0 • |-15| = 15 • |4.44| = 4.44 • Note that |x| = |-x| M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 7. Summation • The summation symbol is ∑ (sigma). • Consider the sequence a1,a2,a3,… then the sums • a1+a2+a3…+an and • am+am+1+…+an • Will be denoted respectively by • σ𝒋=𝟏 𝒏 𝒂𝒋 • σ𝒋=𝒎 𝒏 𝒂𝒋 • Here j is called as the dummy index or dummy variable. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 8. Factorial Function • The product of the positive integers from 1 to n, inclusive, is denoted by n! • That is • n! = 1 x 2 x . . . X (n-2) x (n-1) x n • Example: • 4 ! = 1 x 2 x 3 x 4 = 24 • 5 ! = 5 x 4! = 5 x 24 = 120 M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 9. Permutations ❖A permutation of a set of n elements is an arrangement of the elements in a given order. ❖For example, the permutations of the set consisting of the elements a, b and c are as follows: ❖Abc ❖Acb ❖Bac ❖Bca ❖Cab ❖Cba ❖There are n! permutations of a set of n elements.M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 10. Exponents & Logarithms: • Recall for any integer m, • am= a . a. . . . a (m times) • a0 = 1 • a-m = 1 𝑎 𝑚 • Exponents are extended to include all rational numbers by defining, for any rational number m/n, • am/n = 𝑛 𝑎 𝑚 = ( 𝑛 𝑎 )m • Exponents are extended to include all real numbers by defining for any real number x, • ax = lim 𝑟→𝑥 𝑎 𝑟 M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 11. • Logarithms are related to exponents as follows. • Let b be a positive number the logarithm of any positive number x to the base b written as • log 𝑏 𝑥 • Represents the exponent to which b must be raised to obtain x. that is • Y = log 𝑏 𝑥 and • by = x • The logarithm of 0 and the logarithm of negative number are NOT DEFINED. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 12. Algorithmic Notations. 1. Identifying Number ✓Each algorithm is assigned an identifying number. ✓Example Algorithm 4.3 refers to the 3rd algorithm in chapter 4. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 13. Algorithmic Notations. 2. Steps, Control, Exit ✓Each steps of the algorithm are executed one after the other, beginning with step-1. ✓Control may be transferred to step n of the algorithm by the statement “Go to Step n”. ✓These “goto” statements may be eliminated by using certain control structures. ✓If several statements appear in the same step like SET K:=1, LOC:=1, then they are executed from left to right. ✓The algorithm is completed with the statement EXIT. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 14. Algorithmic Notations. 3. Comments ✓Each step may contain a comment in brackets which indicates the main purpose of the step. ✓The comment will usually appear at the beginning or at the end of the step. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 15. Algorithmic Notations. 4. Variable Names ✓Variable names will use capital letters (Eg. MAX, DATA) ✓Single letter names of variables used as counters or subscripts will also be capitalized in the algorithms. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 16. Algorithmic Notations. 5. Assignment statement ✓Assignment statements will use the dots-equal notation := ✓Example MAX := DATA[1] ✓Will assign the value in DATA[1] to MAX. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 17. Algorithmic Notations. 6. Input and output ✓Data may be input and assigned to variables by means of Read statement with the following form. ✓Read: Variable_names ✓Message placed in quotation marks and data in variables may be output by means of a Write or Print statement with the following form. ✓Write: Message and/or variable_names M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 18. Algorithmic Notations. 7. Procedures ✓This term is used for an independent algorithmic module which solves a particular problem. ✓The use of the word Procedure or Module denotes it. ✓It is used to describe a certain type of sub-algorithm. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 19. 2.4 CONTROL STRUCTURES Three types of logic or flow-of-control are used: Sequence Logic (or) Sequential Flow Selection Logic (or) Conditional Flow Iteration Logic (or) Repratitive Flow M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 20. Sequence Logic • Unless instructions given to the contrary, the modules are executed in the obvious sequence. • The sequence may be preseted explicitly, by means of numbered steps, or implicitly, by the order in which the modules are written. • Most processing will generally follow this elementary flow pattern. Module A Module B Module CM.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 21. Selection Logic • Employs a number of conditions which lead to a selection of one out of several alternative modules. • The structures which implement this logic are called conditional structures or IF structures. • Most processing will generally follow this elementary flow pattern. • These condition structures fall into three categories. • Single alternative • Double alternative • Multiple alternatives M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 22. Selection Logic – Single Alternative. • If the given condition holds, then Module-A, which may consist of one or more statements, is executed; • Otherwise Module-A is skipped and control transfers to the next step of the algorithm. Structure If condition then: [ Module-A] [End of If Structure] Condition? Module - A Yes No M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 23. Selection Logic – Double Alternative. • If the given condition holds, then Module-A, gets executed; • Otherwise Module-B is is executed. Structure If condition then: [ Module-A] Else: [ Module-B] [End of If Structure] Condition? Module - A Yes No Module - B M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 24. Selection Logic – Multiple Alternatives. • The logic of this structure allows only one of the modules to be executed. • Either the modulewhich follows the first condition which holds is executed, or the module which follows the final Else statement is executed. Structure If condition-1 then: [ Module-A1] Else If condition-2 then : [ Module-A2] … Else: [ Module-B] [End of If Structure] M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 25. Iteration Logic (Repetitive Flow) • Refers to either of 2 types of structures involving loops. • Each type begins with a Repeat statement and is followed by a module, called the body of the loop. • 2 Types: • Repeat-for loop • Repeat-while loop. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 26. Iteration Logic – Repeat-for Loop • Uses an index variable to control the loop (such as I,j or k). • Format: Repeat for K = R to S by T: [Module] [End of loop] • Here R is called the initial value, S the end value or test value and T the increment. • The body of the loop is executed first with K=R, then with K=R+T, then with K=R+2T and so on. • The cycling ends when K>s. Is K > S ? Module [ body of loop] No Yes K = K + T K = R M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 27. Iteration Logic – Repeat-while Loop • Uses a ocndition to control the loop. • Format: Repeat while condition: [Module] [End of loop] • The cycling continues until the condition si false. • There must be a statement before the structure that initializes the condition controlling the loop. • There must be a statement in the body of the loop that changes the condition. Yes condition? Module [ body of loop] No M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 28. 2.5 COMPLEXITY OF ALGORITHMS • Inorder to compare algorithms, we must have some criteria to measure the efficiency of out algorithm. • Suppose • M is an algorithm, and • n is he size of input data • The time & space used by the algorithm M are the two main measures for the efficiency of M. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 29. 2.5 COMPLEXITY OF ALGORITHMS • The complexity of an algorithm M is the function f(x) which gives the running time and/or storage space requirement of the algorithm in terms of the size n of the input data. • The storage space required by an algorithm is simply a multiple of the data size n. • So mostly the term “complexity” refer to the running time of the algorithm. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 30. 2.5 COMPLEXITY OF ALGORITHMS • Finding the complexity function f(x) deals with 3 cases in complexity theory. • Worst case: the maximum value of f(n) for any possible input. • Average case: the expected value of f(n) • Best case: the minimum value of f(n). Example – Searching an element in Linear search fashion: • Worst case: The ITEM is at the LAST position or NOT PRESENT in the list. • Average case: The ITEM appears in the list. • Best case: The ITEM appears at the FIRST position in the list.M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 31. Rate of Growth; Big O Notation • Suppose M is an algorithm with the size of input n, the complexity f(n) of M increases as n increases. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 32. Rate of Growth; Big O Notation • The rate of increase of f(n) is done by comparing f(n) with some standard function such as log2 n, n log2 n, n2 , n3 , 2n • The rate of growth of these standard functions are indicated in the below table G(n) Log n N N log n n2 n3 2n N 5 3 5 15 25 125 32 10 4 10 40 100 103 103 3100 7 100 700 104 106 1030 1000 10 103 104 106 109 10300M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 33. Rate of Growth; Big O Notation • Supposef(n) and g(n) are functions with property that f(n) is bounded by some multiple of g(n) for almost all n, • Then we may write as • F(n) = O(g(n)) • This is called as the “big O” notation. • Example complexity functions of well-known searching and sorting algorithms: • Linear search : O(n) • Binary search : O(log n) • Bubble sort : O(n2) • Merge sort : O(n log n)M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 34. 2.6 OTHER ASYMPTOTIC NOTATIONS FOR COMPLEXITY OF ALGORITHMS Ω , 𝜃 , 𝜊 Omega Notation (Ω) • The omega notation is used when the function g(n) defines a lower bound for the function f(n). • F(n) = Ω (g(n) ), iff there exists a positive integer n0 and a positive integer M such that |f(n)| >= M|g(n)|, for all n>= n0 • For f(n)=18n+9, f(n)>18n for all n, hence f(n)= Ω(n) • For f(n)=90n2+18n+6, f(n)>90n2 for n2=0 and therefore f(n)= Ω(n2) M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 35. 2.6 OTHER ASYMPTOTIC NOTATIONS FOR COMPLEXITY OF ALGORITHMS Ω , 𝜃 , 𝜊 Theta Notation (𝜃) • The theta notation is used when the function f(n) is bounded both from the above and below by the function g(n). • It implies that the function g(n) is both an upper bound and a lower bound for the function f(n) for all values of n, n>= n0. • That is f(n) is such that f(n) = O(g(n)) and f(n) = Ω(g(n)) • F(n) = 𝜃 (g(n) ), iff there exists two positive constants c1 and c2 and a positive integer n0 such that c1|g(n)| <= c2 |g(n)|, for all n>= n0. • For f(n)=18n+9, f(n)>18n for all n, hence f(n)= Ω(n) • For f(n)=90n2+18n+6, f(n)>90n2 for n2=0 and therefore f(n)= Ω(n2) M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 36. 2.6 OTHER ASYMPTOTIC NOTATIONS FOR COMPLEXITY OF ALGORITHMS Ω , 𝜃 , 𝜊 Little Oh Notation (o) • F(n) = 𝑜(g(n) ), iff f(n)=O(g(n)) and f(n) ≠ Ω(g(n)). M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 37. 2.7 SUBALGORITHMS • A subalgorithm is a complete and independently defined algorithmic module which is used by some main module or by some other subalgorithm. • A subalgorithm • receives values called arguments, from an originating algorithm, • performs calculations, and then • sends back the result to the calling algorithm. • The subalgorithm is defined independently so that it may be called by many different algorithms or called at different times in the same algorithm. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 38. 2.7 SUBALGORITHMS • The subalgorithm will have a RETURN statement instead of EXIT statement. It implies that the control is transferred back to the calling program when execution of the subalgorithm is completed. • Subalgorithms fall into 2 basic categories: • Function subalgorithms – return only a single value to the calling algorithm. • Procedure subalgorithms – can send back more than one value to the calling algorithm. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 39. 2.8 VARIABLES, DATA TYPES • Each variable in any of our algorithms has a data type which determines the code that is used for storing its value. Four such data types are: • Character • Real (floating point) • Integer (fixed point) • Logical M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 40. Local & Global Variables • The organization of a computer program into a main program and various subprograms has led to the notion of local and global variables. • Each program module contains its own lis of variables called local variables, which can be accessed only by the particular module. • Variables that can be accessed by all program modules are called global variables. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.
  • 41. Local & Global Variables • There are 2 basic ways for modules to communicate with each other: • Directly, by means of well-defined parameters. • Indirectly, by means of non-local and global variables. M.Priyavani,MCA,DCHN,M.Phil, V.V.V.College for Women, Virudhunagar.