review 1 polish notation prefix infix postfix precedence of operators converting infix to postfix...

53
Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Upload: edwin-boone

Post on 21-Jan-2016

275 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Review

1

Polish NotationPrefixInfixPostfix

Precedence of OperatorsConverting Infix to PostfixEvaluating Postfix

Page 2: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Polish Notation

2

Converting Infix to PostfixConverting Postfix to InfixConverting Infix to PrefixExamples

Page 3: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Examples

3

Converting Infix to Postfix

Page 4: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Examples

4

Converting Infix to Postfix

Page 5: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Examples

5

Converting Infix to Postfix

Page 6: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Examples

6

Converting Postfix to Infix

Page 7: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Examples

7

Converting Postfix to Infix

Page 8: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Examples

8

Converting Infix to Prefix

Page 9: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Examples

9

Converting Infix to Prefix

Page 10: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Summary

10

Converting Infix to PostfixConverting Postfix to InfixConverting Infix to PrefixExamples

Page 11: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Review

11

Polish NotationPrefixInfixPostfix

Precedence of OperatorsConverting Infix to PostfixEvaluating Postfix

Page 12: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Polish Notation

12

Converting Infix to PostfixConverting Postfix to InfixConverting Infix to PrefixExamples

Page 13: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Linked ListsIntroductionInsertion DescriptionDeletion DescriptionBasic Node ImplementationConclusion

Page 14: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

OutlineIntroductionInsertion DescriptionDeletion DescriptionBasic Node ImplementationConclusion

Page 15: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

IntroductionDefinitions

Lists and arraysNodes and pointersSingle Linked ListsDouble Linked ListsCircular Lists

Advantages

Page 16: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

IntroductionDefinitions

Lists and arraysNodes and pointersSingle Linked ListsDouble Linked ListsCircular Lists

Advantages

Page 17: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Lists and arraysLists:

Page 18: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Lists and arraysArrays: {Size of the following array is = 4}

Index 0 1 2 3

Value 44 5 96 3

Page 19: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

IntroductionDefinitions

Lists and arraysNodes and pointersSingle Linked ListsDouble Linked ListsCircular Lists

Advantages

Page 20: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Nodes and pointers

Page 21: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

IntroductionDefinitions

Lists and arraysNodes and pointersSingle Linked ListsDouble Linked ListsCircular Lists

Advantages

Page 22: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Single linked lists

Page 23: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

IntroductionDefinitions

Lists and arraysNodes and pointersSingle Linked ListsDouble Linked ListsCircular Lists

Advantages

Page 24: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Double Linked Lists

Page 25: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

IntroductionDefinitions

Lists and arraysNodes and pointersSingle Linked ListsDouble Linked ListsCircular Lists

Advantages

Page 26: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Circular Lists

Page 27: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

IntroductionDefinitions

Lists and arraysNodes and pointersSingle Linked ListsDouble Linked ListsCircular Lists

Advantages

Page 28: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

AdvantagesThe Linked List advantages are collected

because of the array disadvantages, array disadvantages are:

1. Array Size2. Memory allocation3. Insertion and Deletion

Page 29: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

OutlineIntroductionInsertion DescriptionDeletion DescriptionBasic Node ImplementationConclusion

Page 30: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Insertion DescriptionInsertion at the top of the listInsertion at the end of the listInsertion in the middle of the list

Page 31: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Insertion DescriptionInsertion at the top of the listInsertion at the end of the listInsertion in the middle of the list

Page 32: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Insertion at the topSteps:Create a NodeSet the node data ValuesConnect the pointers

Page 33: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Insertion Description

Follow the previous steps and we get

48 17 142head //

head 93

Step 1 Step 2

Step 3

Page 34: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Insertion DescriptionInsertion at the top of the listInsertion at the end of the listInsertion in the middle of the list

Page 35: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Insertion at the endSteps:Create a NodeSet the node data ValuesConnect the pointers

Page 36: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Insertion Description

Follow the previous steps and we get

48 17 142head //

Step 1 Step 2

Step 3

Page 37: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Insertion DescriptionInsertion at the top of the listInsertion at the end of the listInsertion in the middle of the list

Page 38: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Insertion in the middleSteps:Create a NodeSet the node data ValuesBreak pointer connectionRe-connect the pointers

Page 39: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Insertion Description

Step 1 Step 2

Step 3

Step 4

Page 40: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

OutlineIntroductionInsertion DescriptionDeletion DescriptionBasic Node ImplementationConclusion

Page 41: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Deletion DescriptionDeleting from the top of the listDeleting from the end of the listDeleting from the middle of the list

Page 42: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Deletion DescriptionDeleting from the top of the listDeleting from the end of the listDeleting from the middle of the list

Page 43: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Deleting from the topStepsBreak the pointer connectionRe-connect the nodesDelete the node

Page 44: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Deletion Description

4 17

head

426

4 17

head

426

4 17

head

42

Page 45: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Deletion DescriptionDeleting from the top of the listDeleting from the end of the listDeleting from the middle of the list

Page 46: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Deleting from the endStepsBreak the pointer connectionSet previous node pointer to NULLDelete the node

Page 47: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Deletion Description

4 17

head

426

4 17

head

426

4 176

head

Page 48: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Deletion DescriptionDeleting from the top of the listDeleting from the end of the listDeleting from the middle of the list

Page 49: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Deleting from the MiddleStepsSet previous Node pointer to next nodeBreak Node pointer connectionDelete the node

Page 50: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Deletion Description

4 17 42

head

4 17

head

42

4

head

42

Page 51: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

OutlineIntroductionInsertion DescriptionDeletion DescriptionBasic Node ImplementationConclusion

Page 52: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

Basic Node ImplementationThe following code is written in C++:

Struct Node{

int data; //any type of data could be another struct

Node *next; //this is an important piece of code “pointer”

};

Page 53: Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix

SummaryIntroductionInsertion DescriptionDeletion DescriptionBasic Node ImplementationConclusion