SlideShare a Scribd company logo
Chapter 5-1
Data Structures
Assoc. Prof. Dr. Oğuz FINDIK
2016-2017
KBUZEM
KARABUK UNIVERSITY
1
İf we look at the arithmetic expressions, we encounter operand, operator
and parenthesis.
2+3 , (p*q), 2+5*6
For evaluting this expressions, we should parse and them calculate.
<operand><operator><operand> (infix)
Operand: Any object that operation is performed.
Operator: In mathematics and sometimes in computer programming, an
operator is a character that represents an action, as for example x is an
arithmetic operator that represents multiplication.
2
Evaluation of Expressions
 For example 2+3*5-1*4
 To evaluate this expressions you should know precedence of
operator.
 Order of operations
1. Parentheses {()}
2. Exponents 2^3^2 (right to left)
3. Multiplication and division (left to right)
4. Addition and subtraction (left to right)
2*6/3+5-2+8/4*2
3
Evaluation of Expressions
 Prefix (Polish Notation)
 <operator><operand><operand>
 İnfix prefix
 4+5 +45
 p/q /pq
 a*b+c +*abc
4
Evaluation of Expressions
 Postfix (Reverse Polish Notation)
 <operand><operand><operator>
 İnfix prefix postfix
 4+5 +45 45+
 p/q /pq pq/
 a*b+c +*abc ab*c+
5
Evaluation of Expressions
 a*b+c*d-2
 First step we should add parentheses
 {(a*b)+(c*d)}-2
 Next step is that operator will place to end of expression
 {(ab*)+(cd*)}-2
 {ab*cd*+}-2
 ab*cd*+2-
6
Evaluation of prefix and postfix
 2*3+4*5-6=>23*45*+6- (postfix)
 evaluatePostfix(exp){
create a Stack S
for i<-0 to length(exp)-1
{
if (exp[i] is operand)
push(exp[i])
else if (exp[i] is operator){
op2<-pop()
op1<-pop()
temp<perform(op1,op2,exp[i])
push(temp)
}
} return S[top]
}
7
Evaluation of Postfix with Stack
 2*3+4*5-6=>-+*23*456 (prefix)
 This algorithm is same with postfix algorithm. But this
algorithm starts from end of expression.
8
Evaluation of Prefix with Stack
 A+B*C-D*E
 InfixToPostfix(exp){
create a Stack S
String temp<-empty String
for i<-0 to length(exp)-1{
if exp[i] is operand
temp <-temp+exp[i]
else if exp[i] is operator
while(!S.empty()&&HasHigherPrecedence(s.top(),exp[i])){
temp <-temp + s.pop();
}
s.push(exp[i])
}
while(!s.empty()) temp<-temp+s.pop();
Return 1;
}
9
Infix to postfix
 ((A+B)*C-D)*E
 A+(B*C)
10
Infix With parentheses to Postfix

More Related Content

What's hot

Java presentation on insertion sort
Java presentation on insertion sortJava presentation on insertion sort
Java presentation on insertion sort_fahad_shaikh
 
2.1.1 functions and their graphs
2.1.1 functions and their graphs2.1.1 functions and their graphs
2.1.1 functions and their graphsNorthside ISD
 
Coin Changing, Binary Search , Linear Search - Algorithm
Coin Changing, Binary Search , Linear Search - AlgorithmCoin Changing, Binary Search , Linear Search - Algorithm
Coin Changing, Binary Search , Linear Search - Algorithm
Md Sadequl Islam
 
Relations and functions (Mariam)
Relations and functions (Mariam)Relations and functions (Mariam)
Relations and functions (Mariam)Mariam Bosraty
 
Chapter 14 Searching and Sorting
Chapter 14 Searching and SortingChapter 14 Searching and Sorting
Chapter 14 Searching and Sorting
MuhammadBakri13
 
Sorting algorithm
Sorting algorithmSorting algorithm
Sorting algorithm
Balaji Nangare
 
Relational algebra calculus
Relational algebra  calculusRelational algebra  calculus
Relational algebra calculus
Vaibhav Kathuria
 
Data Structures & Algorithm design using C
Data Structures & Algorithm design using C Data Structures & Algorithm design using C
Data Structures & Algorithm design using C
Emertxe Information Technologies Pvt Ltd
 
Functions
FunctionsFunctions
7 searching injava-binary
7 searching injava-binary7 searching injava-binary
7 searching injava-binaryirdginfo
 
Unit 8 searching and hashing
Unit   8 searching and hashingUnit   8 searching and hashing
Unit 8 searching and hashing
Dabbal Singh Mahara
 
A Variant of Modified Diminishing Increment Sorting: Circlesort and its Perfo...
A Variant of Modified Diminishing Increment Sorting: Circlesort and its Perfo...A Variant of Modified Diminishing Increment Sorting: Circlesort and its Perfo...
A Variant of Modified Diminishing Increment Sorting: Circlesort and its Perfo...
CSCJournals
 
operators in c++
operators in c++operators in c++
operators in c++
Kartik Fulara
 
stacks in algorithems and data structure
stacks in algorithems and data structurestacks in algorithems and data structure
stacks in algorithems and data structure
faran nawaz
 
A simple presentation on Relational Algebra
A simple presentation on Relational AlgebraA simple presentation on Relational Algebra
A simple presentation on Relational Algebra
Arman Hossain
 
Binary search
Binary searchBinary search
Binary search
AparnaKumari31
 

What's hot (19)

Logarithms
LogarithmsLogarithms
Logarithms
 
Java presentation on insertion sort
Java presentation on insertion sortJava presentation on insertion sort
Java presentation on insertion sort
 
2.1.1 functions and their graphs
2.1.1 functions and their graphs2.1.1 functions and their graphs
2.1.1 functions and their graphs
 
Coin Changing, Binary Search , Linear Search - Algorithm
Coin Changing, Binary Search , Linear Search - AlgorithmCoin Changing, Binary Search , Linear Search - Algorithm
Coin Changing, Binary Search , Linear Search - Algorithm
 
Alg2 lesson 2.1
Alg2 lesson 2.1Alg2 lesson 2.1
Alg2 lesson 2.1
 
Relations and functions (Mariam)
Relations and functions (Mariam)Relations and functions (Mariam)
Relations and functions (Mariam)
 
Chapter 14 Searching and Sorting
Chapter 14 Searching and SortingChapter 14 Searching and Sorting
Chapter 14 Searching and Sorting
 
Sorting algorithm
Sorting algorithmSorting algorithm
Sorting algorithm
 
Alg2 lesson 2.1
Alg2 lesson 2.1Alg2 lesson 2.1
Alg2 lesson 2.1
 
Relational algebra calculus
Relational algebra  calculusRelational algebra  calculus
Relational algebra calculus
 
Data Structures & Algorithm design using C
Data Structures & Algorithm design using C Data Structures & Algorithm design using C
Data Structures & Algorithm design using C
 
Functions
FunctionsFunctions
Functions
 
7 searching injava-binary
7 searching injava-binary7 searching injava-binary
7 searching injava-binary
 
Unit 8 searching and hashing
Unit   8 searching and hashingUnit   8 searching and hashing
Unit 8 searching and hashing
 
A Variant of Modified Diminishing Increment Sorting: Circlesort and its Perfo...
A Variant of Modified Diminishing Increment Sorting: Circlesort and its Perfo...A Variant of Modified Diminishing Increment Sorting: Circlesort and its Perfo...
A Variant of Modified Diminishing Increment Sorting: Circlesort and its Perfo...
 
operators in c++
operators in c++operators in c++
operators in c++
 
stacks in algorithems and data structure
stacks in algorithems and data structurestacks in algorithems and data structure
stacks in algorithems and data structure
 
A simple presentation on Relational Algebra
A simple presentation on Relational AlgebraA simple presentation on Relational Algebra
A simple presentation on Relational Algebra
 
Binary search
Binary searchBinary search
Binary search
 

Similar to Data structure week y 5 1

11 EXPRESSIONS.pptx
11 EXPRESSIONS.pptx11 EXPRESSIONS.pptx
11 EXPRESSIONS.pptx
RodmanCajes
 
Introduction to Programming in LISP
Introduction to Programming in LISPIntroduction to Programming in LISP
Introduction to Programming in LISP
Knoldus Inc.
 
Although people may be very accustomed to reading and understanding .docx
Although people may be very accustomed to reading and understanding .docxAlthough people may be very accustomed to reading and understanding .docx
Although people may be very accustomed to reading and understanding .docx
milissaccm
 
Python.pptx
Python.pptxPython.pptx
Functional Programming by Examples using Haskell
Functional Programming by Examples using HaskellFunctional Programming by Examples using Haskell
Functional Programming by Examples using Haskell
goncharenko
 
INTRODUCTION TO LISP
INTRODUCTION TO LISPINTRODUCTION TO LISP
INTRODUCTION TO LISP
Nilt1234
 
STACK Applications in DS
STACK Applications in DSSTACK Applications in DS
STACK Applications in DS
NARESH GUMMAGUTTA
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
Self-Employed
 
Module 2 - Lists, Tuples, Files.pptx
Module 2 - Lists, Tuples, Files.pptxModule 2 - Lists, Tuples, Files.pptx
Module 2 - Lists, Tuples, Files.pptx
GaneshRaghu4
 
Functional programming
Functional programmingFunctional programming
Functional programming
Hideshi Ogoshi
 
The Ring programming language version 1.5.4 book - Part 19 of 185
The Ring programming language version 1.5.4 book - Part 19 of 185The Ring programming language version 1.5.4 book - Part 19 of 185
The Ring programming language version 1.5.4 book - Part 19 of 185
Mahmoud Samir Fayed
 
Polish
PolishPolish
Polish
joie rocker
 
Operator.ppt
Operator.pptOperator.ppt
Operator.ppt
Darshan Patel
 
Class_IX_Operators.pptx
Class_IX_Operators.pptxClass_IX_Operators.pptx
Class_IX_Operators.pptx
rinkugupta37
 
Introduction to Python Values, Variables Data Types Chapter 2
Introduction to Python  Values, Variables Data Types Chapter 2Introduction to Python  Values, Variables Data Types Chapter 2
Introduction to Python Values, Variables Data Types Chapter 2
Raza Ul Mustafa
 
Variables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailVariables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detail
gourav kottawar
 
lecture4 pgdca.pptx
lecture4 pgdca.pptxlecture4 pgdca.pptx
lecture4 pgdca.pptx
classall
 
Lecture_04.2.pptx
Lecture_04.2.pptxLecture_04.2.pptx
Lecture_04.2.pptx
RockyIslam5
 
lecture1.ppt
lecture1.pptlecture1.ppt
lecture1.ppt
MdMahediHasan54
 
C# p2
C# p2C# p2

Similar to Data structure week y 5 1 (20)

11 EXPRESSIONS.pptx
11 EXPRESSIONS.pptx11 EXPRESSIONS.pptx
11 EXPRESSIONS.pptx
 
Introduction to Programming in LISP
Introduction to Programming in LISPIntroduction to Programming in LISP
Introduction to Programming in LISP
 
Although people may be very accustomed to reading and understanding .docx
Although people may be very accustomed to reading and understanding .docxAlthough people may be very accustomed to reading and understanding .docx
Although people may be very accustomed to reading and understanding .docx
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
 
Functional Programming by Examples using Haskell
Functional Programming by Examples using HaskellFunctional Programming by Examples using Haskell
Functional Programming by Examples using Haskell
 
INTRODUCTION TO LISP
INTRODUCTION TO LISPINTRODUCTION TO LISP
INTRODUCTION TO LISP
 
STACK Applications in DS
STACK Applications in DSSTACK Applications in DS
STACK Applications in DS
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
 
Module 2 - Lists, Tuples, Files.pptx
Module 2 - Lists, Tuples, Files.pptxModule 2 - Lists, Tuples, Files.pptx
Module 2 - Lists, Tuples, Files.pptx
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
The Ring programming language version 1.5.4 book - Part 19 of 185
The Ring programming language version 1.5.4 book - Part 19 of 185The Ring programming language version 1.5.4 book - Part 19 of 185
The Ring programming language version 1.5.4 book - Part 19 of 185
 
Polish
PolishPolish
Polish
 
Operator.ppt
Operator.pptOperator.ppt
Operator.ppt
 
Class_IX_Operators.pptx
Class_IX_Operators.pptxClass_IX_Operators.pptx
Class_IX_Operators.pptx
 
Introduction to Python Values, Variables Data Types Chapter 2
Introduction to Python  Values, Variables Data Types Chapter 2Introduction to Python  Values, Variables Data Types Chapter 2
Introduction to Python Values, Variables Data Types Chapter 2
 
Variables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailVariables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detail
 
lecture4 pgdca.pptx
lecture4 pgdca.pptxlecture4 pgdca.pptx
lecture4 pgdca.pptx
 
Lecture_04.2.pptx
Lecture_04.2.pptxLecture_04.2.pptx
Lecture_04.2.pptx
 
lecture1.ppt
lecture1.pptlecture1.ppt
lecture1.ppt
 
C# p2
C# p2C# p2
C# p2
 

More from karmuhtam

Devre analizi deney malzeme listesi
Devre analizi deney malzeme listesiDevre analizi deney malzeme listesi
Devre analizi deney malzeme listesi
karmuhtam
 
Deney 6
Deney 6Deney 6
Deney 6
karmuhtam
 
Deney 5
Deney 5Deney 5
Deney 5
karmuhtam
 
Deney 3 ve 4
Deney 3 ve 4Deney 3 ve 4
Deney 3 ve 4
karmuhtam
 
Deney 1 ve 2
Deney 1 ve 2Deney 1 ve 2
Deney 1 ve 2
karmuhtam
 
Data structure week y 5
Data structure week y 5Data structure week y 5
Data structure week y 5
karmuhtam
 
Data structure week y 4
Data structure week y 4Data structure week y 4
Data structure week y 4
karmuhtam
 
Data structure week 3
Data structure week 3Data structure week 3
Data structure week 3
karmuhtam
 
Data structure week 2
Data structure week 2Data structure week 2
Data structure week 2
karmuhtam
 
Data structure week 1
Data structure week 1Data structure week 1
Data structure week 1
karmuhtam
 
13. sınıfları başlık dosyaları
13.  sınıfları başlık dosyaları13.  sınıfları başlık dosyaları
13. sınıfları başlık dosyaları
karmuhtam
 
12. stl örnekler
12.  stl örnekler12.  stl örnekler
12. stl örnekler
karmuhtam
 
11. stl kütüphanesi
11. stl kütüphanesi11. stl kütüphanesi
11. stl kütüphanesi
karmuhtam
 
10. istisna isleme
10. istisna isleme10. istisna isleme
10. istisna isleme
karmuhtam
 
9. şablonlar
9. şablonlar9. şablonlar
9. şablonlar
karmuhtam
 
8. çok biçimlilik
8. çok biçimlilik8. çok biçimlilik
8. çok biçimlilik
karmuhtam
 
7. kalıtım
7. kalıtım7. kalıtım
7. kalıtım
karmuhtam
 
6. this işaretçisi ve arkadaşlık
6. this işaretçisi ve arkadaşlık6. this işaretçisi ve arkadaşlık
6. this işaretçisi ve arkadaşlık
karmuhtam
 
5. kurucu, yok edici ve kopyalama fonksiyonları
5. kurucu, yok edici ve kopyalama fonksiyonları5. kurucu, yok edici ve kopyalama fonksiyonları
5. kurucu, yok edici ve kopyalama fonksiyonları
karmuhtam
 
4. yapılar
4. yapılar4. yapılar
4. yapılar
karmuhtam
 

More from karmuhtam (20)

Devre analizi deney malzeme listesi
Devre analizi deney malzeme listesiDevre analizi deney malzeme listesi
Devre analizi deney malzeme listesi
 
Deney 6
Deney 6Deney 6
Deney 6
 
Deney 5
Deney 5Deney 5
Deney 5
 
Deney 3 ve 4
Deney 3 ve 4Deney 3 ve 4
Deney 3 ve 4
 
Deney 1 ve 2
Deney 1 ve 2Deney 1 ve 2
Deney 1 ve 2
 
Data structure week y 5
Data structure week y 5Data structure week y 5
Data structure week y 5
 
Data structure week y 4
Data structure week y 4Data structure week y 4
Data structure week y 4
 
Data structure week 3
Data structure week 3Data structure week 3
Data structure week 3
 
Data structure week 2
Data structure week 2Data structure week 2
Data structure week 2
 
Data structure week 1
Data structure week 1Data structure week 1
Data structure week 1
 
13. sınıfları başlık dosyaları
13.  sınıfları başlık dosyaları13.  sınıfları başlık dosyaları
13. sınıfları başlık dosyaları
 
12. stl örnekler
12.  stl örnekler12.  stl örnekler
12. stl örnekler
 
11. stl kütüphanesi
11. stl kütüphanesi11. stl kütüphanesi
11. stl kütüphanesi
 
10. istisna isleme
10. istisna isleme10. istisna isleme
10. istisna isleme
 
9. şablonlar
9. şablonlar9. şablonlar
9. şablonlar
 
8. çok biçimlilik
8. çok biçimlilik8. çok biçimlilik
8. çok biçimlilik
 
7. kalıtım
7. kalıtım7. kalıtım
7. kalıtım
 
6. this işaretçisi ve arkadaşlık
6. this işaretçisi ve arkadaşlık6. this işaretçisi ve arkadaşlık
6. this işaretçisi ve arkadaşlık
 
5. kurucu, yok edici ve kopyalama fonksiyonları
5. kurucu, yok edici ve kopyalama fonksiyonları5. kurucu, yok edici ve kopyalama fonksiyonları
5. kurucu, yok edici ve kopyalama fonksiyonları
 
4. yapılar
4. yapılar4. yapılar
4. yapılar
 

Recently uploaded

Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 

Recently uploaded (20)

Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 

Data structure week y 5 1

  • 1. Chapter 5-1 Data Structures Assoc. Prof. Dr. Oğuz FINDIK 2016-2017 KBUZEM KARABUK UNIVERSITY 1
  • 2. İf we look at the arithmetic expressions, we encounter operand, operator and parenthesis. 2+3 , (p*q), 2+5*6 For evaluting this expressions, we should parse and them calculate. <operand><operator><operand> (infix) Operand: Any object that operation is performed. Operator: In mathematics and sometimes in computer programming, an operator is a character that represents an action, as for example x is an arithmetic operator that represents multiplication. 2 Evaluation of Expressions
  • 3.  For example 2+3*5-1*4  To evaluate this expressions you should know precedence of operator.  Order of operations 1. Parentheses {()} 2. Exponents 2^3^2 (right to left) 3. Multiplication and division (left to right) 4. Addition and subtraction (left to right) 2*6/3+5-2+8/4*2 3 Evaluation of Expressions
  • 4.  Prefix (Polish Notation)  <operator><operand><operand>  İnfix prefix  4+5 +45  p/q /pq  a*b+c +*abc 4 Evaluation of Expressions
  • 5.  Postfix (Reverse Polish Notation)  <operand><operand><operator>  İnfix prefix postfix  4+5 +45 45+  p/q /pq pq/  a*b+c +*abc ab*c+ 5 Evaluation of Expressions
  • 6.  a*b+c*d-2  First step we should add parentheses  {(a*b)+(c*d)}-2  Next step is that operator will place to end of expression  {(ab*)+(cd*)}-2  {ab*cd*+}-2  ab*cd*+2- 6 Evaluation of prefix and postfix
  • 7.  2*3+4*5-6=>23*45*+6- (postfix)  evaluatePostfix(exp){ create a Stack S for i<-0 to length(exp)-1 { if (exp[i] is operand) push(exp[i]) else if (exp[i] is operator){ op2<-pop() op1<-pop() temp<perform(op1,op2,exp[i]) push(temp) } } return S[top] } 7 Evaluation of Postfix with Stack
  • 8.  2*3+4*5-6=>-+*23*456 (prefix)  This algorithm is same with postfix algorithm. But this algorithm starts from end of expression. 8 Evaluation of Prefix with Stack
  • 9.  A+B*C-D*E  InfixToPostfix(exp){ create a Stack S String temp<-empty String for i<-0 to length(exp)-1{ if exp[i] is operand temp <-temp+exp[i] else if exp[i] is operator while(!S.empty()&&HasHigherPrecedence(s.top(),exp[i])){ temp <-temp + s.pop(); } s.push(exp[i]) } while(!s.empty()) temp<-temp+s.pop(); Return 1; } 9 Infix to postfix
  • 10.  ((A+B)*C-D)*E  A+(B*C) 10 Infix With parentheses to Postfix