SlideShare une entreprise Scribd logo
1  sur  11
Muhammad Muzammal

E – Mail : hello_hi99@hotmail.com

    Gc University Faisalabad
Intro uc n
            d tio

• An algorithm, named after the ninth century Muslim
  scholar Abu Jafar Muhammad Ibn Musu Al-
  Khowarizmi, is defined as follows:
• An algorithm is a finite step-by-step procedure to
  achieve a required result.
• An algorithm is a sequence of computational steps
  that transform the input into the output.
• An algorithm is a sequence of operations performed
  on data that have to be organized in data structures.
Algorithmic Notations

• variable:=expression
• if condition then statements {elsif condition then statements}
  [else statements]
• case switch of {sub case: statements}
• while condition do statements
• repeat statements until condition
• for variable:=initial value [step step] to final value do statements
• proc procedure name (parameters) [returns type] statements
• procedure name (arguments)
• return expression
• read variable
• write expression
Algorithmic Notations



1.    Programming notation

2.    Specification notation
Programming notation


General purpose algorithmic notations
    Pascal, C, C++, Java
• Declarations:
int i, j = 3; double sum = 0; real x;
int a[n]               // array of n integers
int b[1:n]             # array of n integers5
double c[n,n] = ([n] ([n] 1.0))
Programming notation (2)


• Sequential statements
(look: Java)
for [quantifier1, quantifier2 , ….] {
(list of statements)
}
quantifiers:
i=0 to N i=1 to N by 2
i=0 to n-1 st i!=x    #every value except x
Programming notation (3)

• Concurrent statements
– co statement1;         #N parallel processes
// ...
// statementN;
oc
– process foo {          # a process in the ...
(list of statements)     # ... background
}
process bar [i=1 to n]   # n processes
Programming notation (4)
• Functions and Procedures
• int addone(int v) {          # an integer fnct
return (v+1);
}
• main () {                     # a “void" procedure
int n, sum;
read(n);
for [i = 1 to n]
sum = sum + addone(i);
write (“the final value is”, sum);
}
Specification notation (1)

• Specifying atomic transactions
   process_state_1           #state of computation
   <S1; … Sn;>               #list of statements
   process_state_2           #state of computation
   the execution is atomic: the other processes see
   either state_1 or state_2
• Example: x = 0; y = 10;
   < x = x+1; y = y + 1; >
   For other processes:
   either x==0 & y==10 or x==1 & y==11
Specification notation (2)

• Specification of await
   < await (B) S; >
   – B delay condition
   – S sequence of statements
• B is guaranteed to be true when execution of S
  begins
• S is guaranteed to terminate
• No internal state of S is visible to other processes
• Example: <await ( s>0 ) s = s - 1; >

Contenu connexe

Tendances

Elementary data organisation
Elementary data organisationElementary data organisation
Elementary data organisation
Muzamil Hussain
 

Tendances (20)

Elementary data organisation
Elementary data organisationElementary data organisation
Elementary data organisation
 
Array data structure
Array data structureArray data structure
Array data structure
 
Operator precedence
Operator precedenceOperator precedence
Operator precedence
 
Computability - Tractable, Intractable and Non-computable Function
Computability - Tractable, Intractable and Non-computable FunctionComputability - Tractable, Intractable and Non-computable Function
Computability - Tractable, Intractable and Non-computable Function
 
structured programming
structured programmingstructured programming
structured programming
 
RECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSINGRECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSING
 
Recursive algorithms
Recursive algorithmsRecursive algorithms
Recursive algorithms
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
 
Data structures
Data structuresData structures
Data structures
 
Analysis of algorithm
Analysis of algorithmAnalysis of algorithm
Analysis of algorithm
 
Applications of data structures
Applications of data structuresApplications of data structures
Applications of data structures
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm Analysis
 
stack & queue
stack & queuestack & queue
stack & queue
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
 
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)
 
Arrays
ArraysArrays
Arrays
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler Design
 

Similaire à Algorithmic Notations

Verilog-Behavioral Modeling .pdf
Verilog-Behavioral Modeling .pdfVerilog-Behavioral Modeling .pdf
Verilog-Behavioral Modeling .pdf
UsssshaaaMehta
 

Similaire à Algorithmic Notations (20)

Operating System Lab Manual
Operating System Lab ManualOperating System Lab Manual
Operating System Lab Manual
 
02 functions, variables, basic input and output of c++
02   functions, variables, basic input and output of c++02   functions, variables, basic input and output of c++
02 functions, variables, basic input and output of c++
 
Python programming –part 3
Python programming –part 3Python programming –part 3
Python programming –part 3
 
Python ppt
Python pptPython ppt
Python ppt
 
computer programming and utilization
computer programming and utilizationcomputer programming and utilization
computer programming and utilization
 
DSA
DSADSA
DSA
 
DAA-Unit1.pptx
DAA-Unit1.pptxDAA-Unit1.pptx
DAA-Unit1.pptx
 
Verilog-Behavioral Modeling .pdf
Verilog-Behavioral Modeling .pdfVerilog-Behavioral Modeling .pdf
Verilog-Behavioral Modeling .pdf
 
C fundamental
C fundamentalC fundamental
C fundamental
 
Computational Complexity.pptx
Computational Complexity.pptxComputational Complexity.pptx
Computational Complexity.pptx
 
3 Function & Storage Class.pptx
3 Function & Storage Class.pptx3 Function & Storage Class.pptx
3 Function & Storage Class.pptx
 
Lecture 3 insertion sort and complexity analysis
Lecture 3   insertion sort and complexity analysisLecture 3   insertion sort and complexity analysis
Lecture 3 insertion sort and complexity analysis
 
07 control+structures
07 control+structures07 control+structures
07 control+structures
 
Oop lec 1
Oop lec 1Oop lec 1
Oop lec 1
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++
 
Problem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study materialProblem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study material
 
85ec7 session2 c++
85ec7 session2 c++85ec7 session2 c++
85ec7 session2 c++
 
Mbd2
Mbd2Mbd2
Mbd2
 
Operators
OperatorsOperators
Operators
 
Java introduction
Java introductionJava introduction
Java introduction
 

Dernier

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Dernier (20)

Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 

Algorithmic Notations

  • 1.
  • 2. Muhammad Muzammal E – Mail : hello_hi99@hotmail.com Gc University Faisalabad
  • 3. Intro uc n d tio • An algorithm, named after the ninth century Muslim scholar Abu Jafar Muhammad Ibn Musu Al- Khowarizmi, is defined as follows: • An algorithm is a finite step-by-step procedure to achieve a required result. • An algorithm is a sequence of computational steps that transform the input into the output. • An algorithm is a sequence of operations performed on data that have to be organized in data structures.
  • 4. Algorithmic Notations • variable:=expression • if condition then statements {elsif condition then statements} [else statements] • case switch of {sub case: statements} • while condition do statements • repeat statements until condition • for variable:=initial value [step step] to final value do statements • proc procedure name (parameters) [returns type] statements • procedure name (arguments) • return expression • read variable • write expression
  • 5. Algorithmic Notations 1. Programming notation 2. Specification notation
  • 6. Programming notation General purpose algorithmic notations Pascal, C, C++, Java • Declarations: int i, j = 3; double sum = 0; real x; int a[n] // array of n integers int b[1:n] # array of n integers5 double c[n,n] = ([n] ([n] 1.0))
  • 7. Programming notation (2) • Sequential statements (look: Java) for [quantifier1, quantifier2 , ….] { (list of statements) } quantifiers: i=0 to N i=1 to N by 2 i=0 to n-1 st i!=x #every value except x
  • 8. Programming notation (3) • Concurrent statements – co statement1; #N parallel processes // ... // statementN; oc – process foo { # a process in the ... (list of statements) # ... background } process bar [i=1 to n] # n processes
  • 9. Programming notation (4) • Functions and Procedures • int addone(int v) { # an integer fnct return (v+1); } • main () { # a “void" procedure int n, sum; read(n); for [i = 1 to n] sum = sum + addone(i); write (“the final value is”, sum); }
  • 10. Specification notation (1) • Specifying atomic transactions process_state_1 #state of computation <S1; … Sn;> #list of statements process_state_2 #state of computation the execution is atomic: the other processes see either state_1 or state_2 • Example: x = 0; y = 10; < x = x+1; y = y + 1; > For other processes: either x==0 & y==10 or x==1 & y==11
  • 11. Specification notation (2) • Specification of await < await (B) S; > – B delay condition – S sequence of statements • B is guaranteed to be true when execution of S begins • S is guaranteed to terminate • No internal state of S is visible to other processes • Example: <await ( s>0 ) s = s - 1; >