Stack Applications. Lecture 25 Sections Robb T. Koether. HampdenSydney College. Mon, Mar 30, 2015


 Louisa Tate
 1 years ago
 Views:
Transcription
1 Stack Applications Lecture 25 Sections Robb T. Koether HampdenSydney College Mon, Mar 30, 2015 Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
2 1 The Triangle Puzzle 2 Infix, Postfix, and Prefix Notation 3 Infix Expression Evaluation 4 Postfix Expressions 5 Function Calls 6 Assignment Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
3 Outline 1 The Triangle Puzzle 2 Infix, Postfix, and Prefix Notation 3 Infix Expression Evaluation 4 Postfix Expressions 5 Function Calls 6 Assignment Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
4 The Restaurant Triangle While waiting for your order in a restaurant, you pick up and play the Triangle Puzzle. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
5 The Triangle Puzzle There are fifteen holes. One hole is empty. The other 14 holes have pegs in them. You make moves by jumping, as in checkers. One peg jumps an adjacent peg, landing in an empty hole. Remove the jumped peg. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
6 The Restaurant Triangle Puzzle The goal is to remove all but one peg. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
7 The Restaurant Triangle Puzzle There are 36 possible moves 6 in each of 6 directions). Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
8 The Restaurant Triangle Puzzle Six moves up this diagonal. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
9 The Restaurant Triangle Puzzle Six moves down this diagonal. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
10 The Restaurant Triangle Puzzle Six moves up this diagonal. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
11 The Restaurant Triangle Puzzle Six moves down this diagonal. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
12 The Restaurant Triangle Puzzle Six moves right horizontally. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
13 The Restaurant Triangle Puzzle Six moves left horizontally. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
14 The Restaurant Triangle Puzzle List the 36 possible moves in some any) order. The program will systematically consider the moves until it finds a valid move. Then it will Make that move. Push that move onto the stack for future reference. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
15 The Restaurant Triangle Puzzle If no move if possible, then it will Pop the last move off the stack. Continue through the list of possible moves until it finds a legal move. Make that move and continue as before. When a single peg remains, the contents of the stack is a winning sequence of moves. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
16 Postfix Expression Evaluation Run the program TrianglePuzzle.cpp. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
17 Outline 1 The Triangle Puzzle 2 Infix, Postfix, and Prefix Notation 3 Infix Expression Evaluation 4 Postfix Expressions 5 Function Calls 6 Assignment Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
18 Infix Notation An infix expression is an arithmetic expression in which the binary operators are written in between the operands. For example, to add 3 and 4, we write Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
19 Postfix Expressions In a postfix expression, the operator is written after the operands. For example, to add 3 and 4, we write The infix expression would be written as in postfix notation. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
20 Prefix Expressions In a prefix expression, the operator is written before the operands. For example, to add 3 and 4, we write The infix expression would be written as in prefix notation. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
21 Outline 1 The Triangle Puzzle 2 Infix, Postfix, and Prefix Notation 3 Infix Expression Evaluation 4 Postfix Expressions 5 Function Calls 6 Assignment Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
22 Fully Parenthesized Infix Expressions With infix expressions, the operations are not necessarily performed from left to right. Infix expressions may require parentheses to specify the order of operation. Precedence and associativity rules allow us to omit some of the parentheses. A fully parenthesized expression assumes no precedence or associativity rules. In a fully parenthesized expression, there is a pair of parentheses for every operator. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
23 Examples The expression would be fully parenthesized as )). The expression /5 6 would be fully parenthesized as 2 3) + 4/5)) 6). Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
24 Infix Expression Evaluation We may use a pair of stacks to evaluate a fully parenthesized infix expression. The expression contains four types of token: Left parenthesis Right parenthesis ) Number, e.g., 123 Operator +,,, / Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
25 Infix Expression Evaluation To evaluate the expression we need a stack of numbers and a stack of operators. Read the tokens from left to right and process them as follows: Token Left parenthesis Number Operator Right Parenthesis Action No action Push the number onto the number stack Push the operator onto the operator stack 1. Pop two numbers off the number stack 2. Pop one operator off the operator stack 3. Perform the operation on the numbers 4. Push the result onto the number stack Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
26 Example Use the algorithm to evaluate the expression 2 5) + 6/3)) 8) Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
27 Example Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Token Number Stack Operator Stack Begin with an empty stack
28 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack 2 5) + 6/3)) 8)
29 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack 2 5) + 6/3)) 8)
30 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack 2 5) + 6/3)) 8)
31 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack ) + 6/3)) 8)
32 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack ) + 6/3)) 8)
33 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack ) + 6/3)) 8)
34 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack ) ) + 6/3)) 8)
35 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack ) ) + 6/3)) 8)
36 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack ) ) + 6/3)) 8)
37 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack ) ) + 6/3)) 8)
38 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack ) / / 2 5) + 6/3)) 8)
39 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack ) / / / 2 5) + 6/3)) 8)
40 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack ) / / / ) ) + 6/3)) 8)
41 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack ) / / / ) ) ) + 6/3)) 8)
42 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack ) / / / ) ) ) + 6/3)) 8)
43 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack ) / / / ) ) ) + 6/3)) 8)
44 Robb T. Koether HampdenSydney College) Stack caption Applications Mon, Mar 30, / 34 Example Token Number Stack Operator Stack ) / / / ) ) ) 4 2 5) + 6/3)) 8)
45 Infix Expression Evaluation Run the program InfixEvalFullParen.cpp. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
46 Outline 1 The Triangle Puzzle 2 Infix, Postfix, and Prefix Notation 3 Infix Expression Evaluation 4 Postfix Expressions 5 Function Calls 6 Assignment Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
47 Postfix Expression Evaluation Example Postfix Expressions) Expression: Left operand of is Right operand of is In postfix expressions, parentheses are never needed! Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
48 Postfix Expression Evaluation To evaluate a postfix expression we need a stack of numbers. Read the tokens from left to right and process them as follows: Token Number Operator Action Push the number onto the number stack 1. Pop two numbers off the number stack 2. Pop one operator off the operator stack 3. Perform the operation on the numbers 4. Push the result onto the number stack Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
49 Postfix Expression Evaluation Example Postfix Expressions) The fully parenthesized infix expression 2 5) + 6/3)) 8) can be written as /3 8 As a postfix expression, it is / + 8 Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
50 Example Token 2 2 Number Stack / + 8 Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
51 Example Token Number Stack / + 8 Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
52 Example Token Number Stack / + 8 Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
53 Example Token Number Stack / + 8 Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
54 Example Token Number Stack / + 8 Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
55 Example Token Number Stack / / + 8 Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
56 Example Token Number Stack / / + 8 Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
57 Example Token Number Stack / / + 8 Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
58 Example Token Number Stack / / + 8 Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
59 Postfix Expression Evaluation Run the program PostfixEvaluator.cpp. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
60 Outline 1 The Triangle Puzzle 2 Infix, Postfix, and Prefix Notation 3 Infix Expression Evaluation 4 Postfix Expressions 5 Function Calls 6 Assignment Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
61 Handling Function Calls When a function is called, the program Pushes the values of the parameters. Pushes the address of the next instruction to which the function should return later). Allocates space on the stack for the local variables. Branches to the first line in the function. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
62 Handling Function Calls The Stack Other Stuff Begin with the current stack Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
63 Handling Function Calls The Stack Other Stuff Function Parameters Push the function parameters Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
64 Handling Function Calls The Stack Other Stuff Function Parameters Return Address Push the return address Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
65 Handling Function Calls The Stack Other Stuff Function Parameters Return Address Local Variables Push the local variables Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
66 Handling Function Calls When a function returns, the program Pops and discards) the values of the local variables. Pops the return address and stores it in the IP register). Branches to the return address. Pops the parameters. The stack has now been returned to its previous state. Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
67 Handling Function Calls The Stack Other Stuff Function Parameters Return Address Pop the local variables Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
68 Handling Function Calls The Stack Other Stuff Function Parameters Pop the return address Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
69 Handling Function Calls The Stack Other Stuff Pop the function parameters Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
70 Outline 1 The Triangle Puzzle 2 Infix, Postfix, and Prefix Notation 3 Infix Expression Evaluation 4 Postfix Expressions 5 Function Calls 6 Assignment Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
71 Assignment Assignment Read Sections Robb T. Koether HampdenSydney College) Stack Applications Mon, Mar 30, / 34
Stack Applications. Lecture 27 Sections Robb T. Koether. HampdenSydney College. Wed, Mar 29, 2017
Stack Applications Lecture 27 Sections 18.718.8 Robb T. Koether HampdenSydney College Wed, Mar 29, 2017 Robb T. Koether HampdenSydney College) Stack Applications Wed, Mar 29, 2017 1 / 27 1 Function
More informationStacks and their Applications
Stacks and their Applications Lecture 23 Sections 18.118.2 Robb T. Koether HampdenSydney College Fri, Mar 16, 2018 Robb T. Koether HampdenSydney College) Stacks and their Applications Fri, Mar 16, 2018
More informationOperators. Lecture 12 Section Robb T. Koether. HampdenSydney College. Fri, Feb 9, 2018
Operators Lecture 12 Section 14.5 Robb T. Koether HampdenSydney College Fri, Feb 9, 2018 Robb T. Koether (HampdenSydney College) Operators Fri, Feb 9, 2018 1 / 21 Outline 1 Operators as Functions 2 Operator
More informationRecursive Sequences. Lecture 24 Section 5.6. Robb T. Koether. HampdenSydney College. Wed, Feb 27, 2013
Recursive Sequences Lecture 24 Section 5.6 Robb T. Koether HampdenSydney College Wed, Feb 27, 2013 Robb T. Koether (HampdenSydney College) Recursive Sequences Wed, Feb 27, 2013 1 / 21 1 Recursive Sequences
More informationRecursive Sequences. Lecture 24 Section 5.6. Robb T. Koether. HampdenSydney College. Wed, Feb 26, 2014
Recursive Sequences Lecture 24 Section 5.6 Robb T. Koether HampdenSydney College Wed, Feb 26, 2014 Robb T. Koether (HampdenSydney College) Recursive Sequences Wed, Feb 26, 2014 1 / 26 1 Recursive Sequences
More informationThe x86 Instruction Set
The x86 Instruction Set Lecture 25 Intel Manual, Vols. 2A & 2B Robb T. Koether HampdenSydney College Mon, Mar 23, 2015 Robb T. Koether (HampdenSydney College) The x86 Instruction Set Mon, Mar 23, 2015
More informationSTACKS. A stack is defined in terms of its behavior. The common operations associated with a stack are as follows:
STACKS A stack is a linear data structure for collection of items, with the restriction that items can be added one at a time and can only be removed in the reverse order in which they were added. The
More informationStacks. Chapter 5. Copyright 2012 by Pearson Education, Inc. All rights reserved
Stacks Chapter 5 Contents Specifications of the ADT Stack Using a Stack to Process Algebraic Expressions A Problem Solved: Checking for Balanced Delimiters in an Infix Algebraic Expression A Problem Solved:
More informationRecursion. Lecture 26 Sections , Robb T. Koether. HampdenSydney College. Mon, Apr 6, 2015
Recursion Lecture 26 Sections 14.114.5, 14.7 Robb T. Koether HampdenSydney College Mon, Apr 6, 2015 Robb T. Koether (HampdenSydney College) Recursion Mon, Apr 6, 2015 1 / 18 1 Recursion 2 Advantages
More informationScheduling and Digraphs
Scheduling and Digraphs Lecture 35 Sections 8.1, 8.2 Robb T. Koether HampdenSydney College Mon, Nov 21, 2016 Robb T. Koether (HampdenSydney College) Scheduling and Digraphs Mon, Nov 21, 2016 1 / 25 1
More informationFormal Languages and Automata Theory, SS Project (due Week 14)
Formal Languages and Automata Theory, SS 2018. Project (due Week 14) 1 Preliminaries The objective is to implement an algorithm for the evaluation of an arithmetic expression. As input, we have a string
More informationThe CriticalPath Algorithm
The CriticalPath Algorithm Lecture 32 Sections 8.38.4 Robb T. Koether HampdenSydney College Wed, Nov 19, 2014 Robb T. Koether (HampdenSydney College) The CriticalPath Algorithm Wed, Nov 19, 2014 1
More information09 STACK APPLICATION DATA STRUCTURES AND ALGORITHMS REVERSE POLISH NOTATION
DATA STRUCTURES AND ALGORITHMS 09 STACK APPLICATION REVERSE POLISH NOTATION IMRAN IHSAN ASSISTANT PROFESSOR, AIR UNIVERSITY, ISLAMABAD WWW.IMRANIHSAN.COM LECTURES ADAPTED FROM: DANIEL KANE, NEIL RHODES
More informationRecursive Descent Parsers
Recursive Descent Parsers Lecture 7 Robb T. Koether HampdenSydney College Wed, Jan 28, 2015 Robb T. Koether (HampdenSydney College) Recursive Descent Parsers Wed, Jan 28, 2015 1 / 18 1 Parsing 2 LL Parsers
More informationMinimal Spanning Trees
Minimal Spanning Trees Lecture 33 Sections 7.17.3 Robb T. Koether HampdenSydney College Wed, Apr 11, 20 Robb T. Koether (HampdenSydney College) Minimal Spanning Trees Wed, Apr 11, 20 1 / 17 1 Networks
More informationScope and Parameter Passing
Scope and Parameter Passing Lecture 16 Sections 6.5, 6.10, 6.13 Robb T. Koether HampdenSydney College Mon, Oct 7, 2013 Robb T. Koether (HampdenSydney College) Scope and Parameter Passing Mon, Oct 7,
More informationLR Parsing  Conflicts
LR Parsing  Conflicts Lecture 15 Sections 4.5, 4.6 Robb T. Koether HampdenSydney College Fri, Feb 20, 2015 Robb T. Koether (HampdenSydney College) LR Parsing  Conflicts Fri, Feb 20, 2015 1 / 15 1 Shift/Reduce
More informationThe PairwiseComparison Method
The PairwiseComparison Method Lecture 10 Section 1.5 Robb T. Koether HampdenSydney College Mon, Sep 11, 2017 Robb T. Koether (HampdenSydney College) The PairwiseComparison Method Mon, Sep 11, 2017
More informationList Iterator Implementation
List Iterator Implementation Lecture 28 Section 14.6 Robb T. Koether HampdenSydney College Fri, Apr 10, 2015 Robb T. Koether (HampdenSydney College) List Iterator Implementation Fri, Apr 10, 2015 1 /
More informationMarch 13/2003 Jayakanth Srinivasan,
Statement Effort MergeSort(A, lower_bound, upper_bound) begin T(n) if (lower_bound < upper_bound) Θ(1) mid = (lower_bound + upper_bound)/ 2 Θ(1) MergeSort(A, lower_bound, mid) T(n/2) MergeSort(A, mid+1,
More informationThe Traveling Salesman Problem NearestNeighbor Algorithm
The Traveling Salesman Problem NearestNeighbor Algorithm Lecture 31 Sections 6.4 Robb T. Koether HampdenSydney College Fri, Apr 6, 2018 Robb T. Koether (HampdenSydney College)The Traveling Salesman
More informationSome Applications of Stack. Spring Semester 2007 Programming and Data Structure 1
Some Applications of Stack Spring Semester 2007 Programming and Data Structure 1 Arithmetic Expressions Polish Notation Spring Semester 2007 Programming and Data Structure 2 What is Polish Notation? Conventionally,
More informationSampling Distribution Examples Sections 15.4, 15.5
Sampling Distribution Examples Sections 15.4, 15.5 Lecture 27 Robb T. Koether HampdenSydney College Wed, Mar 2, 2016 Robb T. Koether (HampdenSydney College)Sampling Distribution ExamplesSections 15.4,
More informationSTACKS AND QUEUES. Problem Solving with ComputersII
STACKS AND QUEUES Problem Solving with ComputersII 2 Stacks container class available in the C++ STL Container class that uses the Last In First Out (LIFO) principle Methods i. push() ii. iii. iv. pop()
More informationStack Abstract Data Type
Stacks Chapter 5 Chapter Objectives To learn about the stack data type and how to use its four methods: push, pop, peek, and empty To understand how Java implements a stack To learn how to implement a
More informationEC8393FUNDAMENTALS OF DATA STRUCTURES IN C Unit 3
UNIT 3 LINEAR DATA STRUCTURES 1. Define Data Structures Data Structures is defined as the way of organizing all data items that consider not only the elements stored but also stores the relationship between
More informationStacks Calculator Application. Alexandra Stefan
Stacks Calculator Application Alexandra Stefan Last modified 2/6/2018 1 Infix and Postfix Notation The standard notation we use for writing mathematical expressions is called infix notation. The operators
More informationThe x86 Architecture
The x86 Architecture Lecture 24 Intel Manual, Vol. 1, Chapter 3 Robb T. Koether HampdenSydney College Fri, Mar 20, 2015 Robb T. Koether (HampdenSydney College) The x86 Architecture Fri, Mar 20, 2015
More informationBinary Tree Applications
Binary Tree Applications Lecture 30 Section 19.2 Robb T. Koether HampdenSydney College Wed, Apr 15, 2015 Robb T. Koether (HampdenSydney College) Binary Tree Applications Wed, Apr 15, 2015 1 / 56 1 Binary
More informationInteger Overflow. Lecture 8 Section 2.5. Robb T. Koether. HampdenSydney College. Mon, Jan 27, 2014
Integer Overflow Lecture 8 Section 2.5 Robb T. Koether HampdenSydney College Mon, Jan 27, 2014 Robb T. Koether (HampdenSydney College) Integer Overflow Mon, Jan 27, 2014 1 / 32 1 Signed Addition and
More informationThe DecreasingTime Algorithm
The DecreasingTime Algorithm Lecture 36 Sections 8.4 Robb T. Koether HampdenSydney College Wed, Apr 18, 2018 Robb T. Koether (HampdenSydney College) The DecreasingTime Algorithm Wed, Apr 18, 2018 1
More informationThe Class Construct Part 1
The Class Construct Part 1 Lecture 23 Sections 7.57.6 Robb T. Koether HampdenSydney College Fri, Oct 26, 2018 Robb T. Koether (HampdenSydney College) The Class Construct Part 1 Fri, Oct 26, 2018 1 /
More informationMagnification and Minification
Magnification and Minification Lecture 30 Robb T. Koether HampdenSydney College Fri, Nov 6, 2015 Robb T. Koether (HampdenSydney College) Magnification and Minification Fri, Nov 6, 2015 1 / 17 Outline
More informationThe Traveling Salesman Problem Brute Force Method
The Traveling Salesman Problem Brute Force Method Lecture 30 Sections 6.1, 6.3 Robb T. Koether HampdenSydney College Fri, Nov 3, 2017 Robb T. Koether (HampdenSydney College)The Traveling Salesman Problem
More informationwhile Loops Lecture 13 Sections Robb T. Koether Wed, Sep 26, 2018 HampdenSydney College
while Loops Lecture 13 Sections 5.85.9 Robb T. Koether HampdenSydney College Wed, Sep 26, 2018 Robb T. Koether (HampdenSydney College) while Loops Wed, Sep 26, 2018 1 / 25 1 while Loops 2 Input Loops
More informationFriends and Unary Operators
Friends and Unary Operators Lecture 11 Sections 11.3, 11.6 Robb T. Koether HampdenSydney College Fri, Feb 13, 2015 Robb T. Koether (HampdenSydney College) Friends and Unary Operators Fri, Feb 13, 2015
More informationTotal Orders. Lecture 41 Section 8.5. Robb T. Koether. HampdenSydney College. Mon, Apr 8, 2013
Total Orders Lecture 41 Section 8.5 Robb T. Koether HampdenSydney College Mon, Apr 8, 2013 Robb T. Koether (HampdenSydney College) Total Orders Mon, Apr 8, 2013 1 / 30 1 Total Orders 2 Topological Sorting
More informationLecture 4: Stack Applications CS2504/CS4092 Algorithms and Linear Data Structures. Parentheses and Mathematical Expressions
Lecture 4: Applications CS2504/CS4092 Algorithms and Linear Data Structures Dr Kieran T. Herley Department of Computer Science University College Cork Summary. Postfix notation for arithmetic expressions.
More informationScope and Parameter Passing
Scope and Parameter Passing Lecture 17 Sections 6.5, 6.10, 6.13 Robb T. Koether HampdenSydney College Fri, Oct 5, 2018 Robb T. Koether (HampdenSydney College) Scope and Parameter Passing Fri, Oct 5,
More informationStack and Its Implementation
Stack and Its Implementation Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale tessema.mengistu@siu.edu Room  3131 1 Definition of Stack Usage of Stack Outline
More informationPA3 Design Specification
PA3 Teaching Data Structure 1. System Description The Data Structure Web application is written in JavaScript and HTML5. It has been divided into 9 pages: Singly linked page, Stack page, Postfix expression
More informationSimpleCalc. which can be entered into a TI calculator, like the one on the right, like this:
!! SimpleCalc Objective: To use stacks to emulate a simple arithmetic calculator. Background: Most people learn to write arithmetic expressions like this: which can be entered into a TI calculator, like
More informationProgramming Languages
Programming Languages Lecture 3 Section 1.3 Robb T. Koether HampdenSydney College Mon, Sep 2, 2013 Robb T. Koether (HampdenSydney College) Programming Languages Mon, Sep 2, 2013 1 / 25 1 Programming
More informationSolving Recursive Sequences by Iteration
Solving Recursive Sequences by Iteration Lecture 25 Section 5.7 Robb T. Koether HampdenSydney College Thu, Feb 28, 2013 Robb T. Koether (HampdenSydney College) Solving Recursive Sequences by Iteration
More informationThe x87 FloatingPoint Unit
The x87 FloatingPoint Unit Lecture 27 Intel Manual, Vol. 1, Chapter 8 Intel Manual, Vol. 2 Robb T. Koether HampdenSydney College Fri, Mar 27, 2015 Robb T. Koether (HampdenSydney College) The x87 FloatingPoint
More informationRotations and Translations
Rotations and Translations Lecture 33 Sections 11.311.4 Robb T. Koether HampdenSydney College Wed, Nov 20, 2013 Robb T. Koether (HampdenSydney College) Rotations and Translations Wed, Nov 20, 2013 1
More informationRecognition of Tokens
Recognition of Tokens Lecture 3 Section 3.4 Robb T. Koether HampdenSydney College Mon, Jan 19, 2015 Robb T. Koether (HampdenSydney College) Recognition of Tokens Mon, Jan 19, 2015 1 / 21 1 A Class of
More informationFunction Definition Syntax Tree
Function Definition Syntax Tree Lecture 34 Section 6.9 Robb T. Koether HampdenSydney College Wed, Apr 15, 2015 Robb T. Koether (HampdenSydney College) Function Definition Syntax Tree Wed, Apr 15, 2015
More informationBuilding the Abstract Syntax Trees
Building the Abstract Syntax Trees Lecture 23 Section 5.3 Robb T. Koether HampdenSydney College Wed, Mar 18, 2015 Robb T. Koether (HampdenSydney College) Building the Abstract Syntax Trees Wed, Mar 18,
More informationThe Stack and Queue Types
The Stack and Queue Types Hartmut Kaiser hkaiser@cct.lsu.edu http://www.cct.lsu.edu/ hkaiser/fall_2012/csc1254.html 2 Programming Principle of the Day Do the simplest thing that could possibly work A good
More informationThe Hacker's Dictionary. Friedrich L. Bauer German computer scientist who proposed "stack method of expression evaluation" in 1955.
Topic 15 Implementing and Using "stack n. The set of things a person has to do in the future. "I haven't done it yet because every time I pop my stack something new gets pushed." If you are interrupted
More informationXPath Lecture 34. Robb T. Koether. HampdenSydney College. Wed, Apr 11, 2012
XPath Lecture 34 Robb T. Koether HampdenSydney College Wed, Apr 11, 2012 Robb T. Koether (HampdenSydney College) XPathLecture 34 Wed, Apr 11, 2012 1 / 20 1 XPath Functions 2 Predicates 3 Axes Robb T.
More informationBoolean Expressions. Lecture 31 Sections 6.6, 6.7. Robb T. Koether. HampdenSydney College. Wed, Apr 8, 2015
Boolean Expressions Lecture 31 Sections 6.6, 6.7 Robb T. Koether HampdenSydney College Wed, Apr 8, 2015 Robb T. Koether (HampdenSydney College) Boolean Expressions Wed, Apr 8, 2015 1 / 22 1 Relational
More informationThe PluralitywithElimination Method
The PluralitywithElimination Method Lecture 9 Section 1.4 Robb T. Koether HampdenSydney College Fri, Sep 8, 2017 Robb T. Koether (HampdenSydney College) The PluralitywithElimination Method Fri, Sep
More informationThe Model Stack. Lecture 8. Robb T. Koether. HampdenSydney College. Wed, Sep 6, 2017
The Model Stack Lecture 8 Robb T. Koether HampdenSydney College Wed, Sep 6, 2017 Robb T. Koether (HampdenSydney College) The Model Stack Wed, Sep 6, 2017 1 / 19 Outline 1 Drawing Rectangle Man 2 The
More informationLR Parsing  The Items
LR Parsing  The Items Lecture 10 Sections 4.5, 4.7 Robb T. Koether HampdenSydney College Fri, Feb 13, 2015 Robb T. Koether (HampdenSydney College) LR Parsing  The Items Fri, Feb 13, 2015 1 / 31 1 LR
More informationAn Introduction to Trees
An Introduction to Trees Alice E. Fischer Spring 2017 Alice E. Fischer An Introduction to Trees... 1/34 Spring 2017 1 / 34 Outline 1 Trees the Abstraction Definitions 2 Expression Trees 3 Binary Search
More informationPointers. Lecture 2 Sections Robb T. Koether. HampdenSydney College. Mon, Jan 20, 2014
Pointers Lecture 2 Sections 10.310.8 Robb T. Koether HampdenSydney College Mon, Jan 20, 2014 Robb T. Koether (HampdenSydney College) Pointers Mon, Jan 20, 2014 1 / 35 1 Endianness 2 Pointer Arithmetic
More informationPointers. Lecture 1 Sections Robb T. Koether. HampdenSydney College. Wed, Jan 14, 2015
Pointers Lecture 1 Sections 10.110.2 Robb T. Koether HampdenSydney College Wed, Jan 14, 2015 Robb T. Koether (HampdenSydney College) Pointers Wed, Jan 14, 2015 1 / 23 1 Pointers 2 Pointer Initialization
More informationFunction Usage. Lecture 15 Sections 6.3, 6.4. Robb T. Koether. HampdenSydney College. Mon, Oct 1, 2018
Function Usage Lecture 15 Sections 6.3, 6.4 Robb T. Koether HampdenSydney College Mon, Oct 1, 2018 Robb T. Koether (HampdenSydney College) Function Usage Mon, Oct 1, 2018 1 / 12 1 Function and Parameters
More informationShading Triangles. Lecture 37. Robb T. Koether. HampdenSydney College. Mon, Nov 30, 2015
Shading Triangles Lecture 37 Robb T. Koether HampdenSydney College Mon, Nov 30, 2015 Robb T. Koether (HampdenSydney College) Shading Triangles Mon, Nov 30, 2015 1 / 35 Outline 1 Shading Triangles Barycentric
More informationWebpage Navigation. Lecture 27. Robb T. Koether. HampdenSydney College. Mon, Apr 2, 2018
Webpage Navigation Lecture 27 Robb T. Koether HampdenSydney College Mon, Apr 2, 2018 Robb T. Koether (HampdenSydney College) Webpage Navigation Mon, Apr 2, 2018 1 / 16 1 Popup Boxes 2 The Document Object
More informationData Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1
Data Structure using C++ Lecture 04 Reading Material Data Structures and algorithm analysis in C++ Chapter. 3 3.1, 3.2, 3.2.1 Summary Stack Operations on a stack Representing stacks Converting an expression
More informationUNIT 3
UNIT 3 Presentation Outline Sequence control with expressions Conditional Statements, Loops Exception Handling Subprogram definition and activation Simple and Recursive Subprogram Subprogram Environment
More informationThe Graphics Pipeline
The Graphics Pipeline Lecture 2 Robb T. Koether HampdenSydney College Fri, Aug 28, 2015 Robb T. Koether (HampdenSydney College) The Graphics Pipeline Fri, Aug 28, 2015 1 / 19 Outline 1 Vertices 2 The
More informationArray Lists. Lecture 15. Robb T. Koether. HampdenSydney College. Mon, Feb 22, 2016
Array Lists Lecture 15 Robb T. Koether HampdenSydney College Mon, Feb 22, 2016 Robb T. Koether (HampdenSydney College) Array Lists Mon, Feb 22, 2016 1 / 23 1 Inlining Functions 2 List Implementations
More informationAbstract Syntax Trees Synthetic and Inherited Attributes
Abstract Syntax Trees Synthetic and Inherited Attributes Lecture 22 Sections 5.15.2 Robb T. Koether HampdenSydney College Mon, Mar 16, 2015 Robb T. Koether (HampdenSydney College)Abstract Syntax TreesSynthetic
More informationDynamic Allocation of Memory
Dynamic Allocation of Memory Lecture 4 Sections 10.910.10 Robb T. Koether HampdenSydney College Fri, Jan 25, 2013 Robb T. Koether (HampdenSydney College) Dynamic Allocation of Memory Fri, Jan 25, 2013
More informationLecture 12 ADTs and Stacks
Lecture 12 ADTs and Stacks Modularity Divide the program into smaller parts Advantages Keeps the complexity managable Isolates errors (parts can be tested independently) Can replace parts easily Eliminates
More informationLecture Chapter 6 Recursion as a Problem Solving Technique
Lecture Chapter 6 Recursion as a Problem Solving Technique Backtracking 1. Select, i.e., guess, a path of steps that could possibly lead to a solution 2. If the path leads to a dead end then retrace steps
More informationThe Graphics Pipeline
The Graphics Pipeline Lecture 2 Robb T. Koether HampdenSydney College Wed, Aug 23, 2017 Robb T. Koether (HampdenSydney College) The Graphics Pipeline Wed, Aug 23, 2017 1 / 19 Outline 1 Vertices 2 The
More informationDTDs and XML Attributes
DTDs and XML Attributes Lecture 33 Robb T. Koether HampdenSydney College Mon, Apr 8, 2013 Robb T. Koether (HampdenSydney College) DTDs and XML Attributes Mon, Apr 8, 2013 1 / 21 1 Attribute Definitions
More informationCS 206 Introduction to Computer Science II
CS 206 Introduction to Computer Science II 03 / 31 / 2017 Instructor: Michael Eckmann Today s Topics Questions? Comments? finish RadixSort implementation some applications of stack Priority Queues Michael
More informationData Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1
Data Structure using C++ Lecture 04 Reading Material Data Structures and algorithm analysis in C++ Chapter. 3 3.1, 3.2, 3.2.1 Summary Infix to Postfix Example 1: Infix to Postfix Example 2: Postfix Evaluation
More informationDynamic Allocation of Memory
Dynamic Allocation of Memory Lecture 5 Section 9.8 Robb T. Koether HampdenSydney College Wed, Jan 24, 2018 Robb T. Koether (HampdenSydney College) Dynamic Allocation of Memory Wed, Jan 24, 2018 1 / 34
More informationInfix to Postfix Conversion
Infix to Postfix Conversion Infix to Postfix Conversion Stacks are widely used in the design and implementation of compilers. For example, they are used to convert arithmetic expressions from infix notation
More informationLab 7 1 Due Thu., 6 Apr. 2017
Lab 7 1 Due Thu., 6 Apr. 2017 CMPSC 112 Introduction to Computer Science II (Spring 2017) Prof. John Wenskovitch http://cs.allegheny.edu/~jwenskovitch/teaching/cmpsc112 Lab 7  Using Stacks to Create a
More informationRecursion. Lecture 2 Sections Robb T. Koether. HampdenSydney College. Wed, Jan 17, 2018
Recursion Lecture 2 Sections 20.120.4 Robb T. Koether HampdenSydney College Wed, Jan 17, 2018 Robb T. Koether (HampdenSydney College) Recursion Wed, Jan 17, 2018 1 / 18 1 Recursion 2 Advantages and
More informationThe string Class. Lecture 21 Sections 2.9, 3.9, Robb T. Koether. Wed, Oct 17, HampdenSydney College
The string Class Lecture 21 Sections 2.9, 3.9, 3.10 Robb T. Koether HampdenSydney College Wed, Oct 17, 2018 Robb T. Koether (HampdenSydney College) The string Class Wed, Oct 17, 2018 1 / 18 1 The String
More informationDensity Curves Sections
Density Curves Sections 3.13.2 Lecture 8 Robb T. Koether HampdenSydney College Wed, Jan 27, 2016 Robb T. Koether (HampdenSydney College) Density CurvesSections 3.13.2 Wed, Jan 27, 2016 1 / 18 Outline
More informationBBM 201 DATA STRUCTURES
BBM 201 DATA STRUCTURES Lecture 6: EVALUATION of EXPRESSIONS 20182019 Fall Evaluation of Expressions Compilers use stacks for the arithmetic and logical expressions. Example: x=a/bc+d*ea*c If a=4, b=c=2,
More informationBBM 201 DATA STRUCTURES
BBM 201 DATA STRUCTURES Lecture 6: EVALUATION of EXPRESSIONS 2017 Fall Evaluation of Expressions Compilers use stacks for the arithmetic and logical expressions. Example: x=a/bc+d*ea*c If a=4, b=c=2,
More informationRecursive Linked Lists
Recursive Linked Lists Lecture 28 Sections 14.114.5, 14.7 Robb T. Koether HampdenSydney College Fri, Mar 31, 2017 Robb T. Koether (HampdenSydney College) Recursive Linked Lists Fri, Mar 31, 2017 1 /
More informationLinear Data Structure
Linear Data Structure Definition A data structure is said to be linear if its elements form a sequence or a linear list. Examples: Array Linked List Stacks Queues Operations on linear Data Structures Traversal
More informationLecture 8: Simple Calculator Application
Lecture 8: Simple Calculator Application Postfix Calculator Dr Kieran T. Herley Department of Computer Science University College Cork 2016/17 KH (27/02/17) Lecture 8: Simple Calculator Application 2016/17
More informationArray Lists. Lecture 15. Robb T. Koether. HampdenSydney College. Fri, Feb 16, 2018
Array Lists Lecture 15 Robb T. Koether HampdenSydney College Fri, Feb 16, 2018 Robb T. Koether (HampdenSydney College) Array Lists Fri, Feb 16, 2018 1 / 21 1 Inlining Functions 2 List Implementations
More informationStreetRouting Problems
StreetRouting Problems Lecture 26 Sections 5.15.2 Robb T. Koether HampdenSydney College Wed, Oct 25, 2017 Robb T. Koether (HampdenSydney College) StreetRouting Problems Wed, Oct 25, 2017 1 / 21 1
More informationLinked Lists. Lecture 16 Sections Robb T. Koether. HampdenSydney College. Wed, Feb 22, 2017
Linked Lists Lecture 16 Sections 17.117.3 Robb T. Koether HampdenSydney College Wed, Feb 22, 2017 Robb T. Koether (HampdenSydney College) Linked Lists Wed, Feb 22, 2017 1 / 24 1 Linked Lists 2 The LinkedListNode
More informationImplementing Linked Lists
Implementing Linked Lists Lecture 16 Sections 17.117.3 Robb T. Koether HampdenSydney College Wed, Feb 27, 2013 Robb T. Koether (HampdenSydney College) Implementing Linked Lists Wed, Feb 27, 2013 1 /
More informationProgramming Languages
Programming Languages Lecture 3 Robb T. Koether HampdenSydney College Fri, Aug 31, 2018 Robb T. Koether (HampdenSydney College) Programming Languages Fri, Aug 31, 2018 1 / 23 1 Programming Languages
More informationFirst Semester  Question Bank Department of Computer Science Advanced Data Structures and Algorithms...
First Semester  Question Bank Department of Computer Science Advanced Data Structures and Algorithms.... Q1) What are some of the applications for the tree data structure? Q2) There are 8, 15, 13, and
More informationMonday, November 13, 2017
Monday, November 13, 2017 Topics for today ode generation nalysis lgorithm 1: evaluation of postfix lgorithm 2: infix to postfix lgorithm 3: evaluation of infix lgorithm 4: infix to tree nalysis We are
More information12 Abstract Data Types
12 Abstract Data Types 12.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT). Define
More informationAmbient and Diffuse Light
Ambient and Diffuse Light Lecture 20 Robb T. Koether HampdenSydney College Mon, Oct 12, 2015 Robb T. Koether (HampdenSydney College) Ambient and Diffuse Light Mon, Oct 12, 2015 1 / 29 Outline 1 Lighting
More informationFundamental Data Types
Fundamental Data Types Lecture 4 Sections 2.72.10 Robb T. Koether HampdenSydney College Mon, Sep 3, 2018 Robb T. Koether (HampdenSydney College) Fundamental Data Types Mon, Sep 3, 2018 1 / 25 1 Integers
More informationCOMP421 Compiler Design. Presented by Dr Ioanna Dionysiou
COMP421 Compiler Design Presented by Dr Ioanna Dionysiou Administrative! Any questions about the syllabus?! Course Material available at www.cs.unic.ac.cy/ioanna! Next time reading assignment [ALSU07]
More informationStacks. stacks of dishes or trays in a cafeteria. Last In First Out discipline (LIFO)
Outline stacks stack ADT method signatures array stack implementation linked stack implementation stack applications infix, prefix, and postfix expressions 1 Stacks stacks of dishes or trays in a cafeteria
More informationLecture Data Structure Stack
Lecture Data Structure Stack 1.A stack :is an abstract Data Type (ADT), commonly used in most programming languages. It is named stack as it behaves like a realworld stack, for example a deck of cards
More informationXPath. Lecture 36. Robb T. Koether. Wed, Apr 16, HampdenSydney College. Robb T. Koether (HampdenSydney College) XPath Wed, Apr 16, / 28
XPath Lecture 36 Robb T. Koether HampdenSydney College Wed, Apr 16, 2014 Robb T. Koether (HampdenSydney College) XPath Wed, Apr 16, 2014 1 / 28 1 XPath 2 Executing XPath Expressions 3 XPath Expressions
More informationPointers. Lecture 2 Sections Robb T. Koether. HampdenSydney College. Fri, Jan 18, 2013
Pointers Lecture 2 Sections 10.310.8 Robb T. Koether HampdenSydney College Fri, Jan 18, 2013 Robb T. Koether (HampdenSydney College) Pointers Fri, Jan 18, 2013 1 / 35 1 Introduction 2 Pointer Arithmetic
More information