Data Structures and Algorithms V22.0102. Otávio Braga



Similar documents
DATA STRUCTURES USING C

Introduction to Stacks

7.1 Our Current Model

PSTricks. pst-ode. A PSTricks package for solving initial value problems for sets of Ordinary Differential Equations (ODE), v0.7.

Chapter 3: Restricted Structures Page 1

Stacks. Stacks (and Queues) Stacks. q Stack: what is it? q ADT. q Applications. q Implementation(s) CSCU9A3 1

Algorithms and Data Structures

Chapter 5 Instructor's Manual

10CS35: Data Structures Using C

Data Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010

Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C

Module 2 Stacks and Queues: Abstract Data Types

Data Structures and Algorithms Stacks and Queues

Application of Stacks: Postfix Expressions Calculator (cont d.)

PES Institute of Technology-BSC QUESTION BANK

Outline. Computer Science 331. Stack ADT. Definition of a Stack ADT. Stacks. Parenthesis Matching. Mike Jacobson

Administrative Issues

Data Structures Using C++ 2E. Chapter 5 Linked Lists

Home Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit

Last not not Last Last Next! Next! Line Line Forms Forms Here Here Last In, First Out Last In, First Out not Last Next! Call stack: Worst line ever!

CompuScholar, Inc. Alignment to Utah's Computer Programming II Standards

Stack & Queue. Darshan Institute of Engineering & Technology. Explain Array in detail. Row major matrix No of Columns = m = u2 b2 + 1

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

CHAPTER 4 ESSENTIAL DATA STRUCTRURES

Outline. The Stack ADT Applications of Stacks Array-based implementation Growable array-based stack. Stacks 2

CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues. Linda Shapiro Spring 2016

Introduction to Data Structures

Atmiya Infotech Pvt. Ltd. Data Structure. By Ajay Raiyani. Yogidham, Kalawad Road, Rajkot. Ph : ,

Data Structure with C

Data Structure [Question Bank]

LSN 2 Computer Processors

Linked Lists Linked Lists, Queues, and Stacks

DATA STRUCTURE - STACK

Data Structures/Stacks and Queues

Stacks. Data Structures and Data Types. Collections

MAX = 5 Current = 0 'This will declare an array with 5 elements. Inserting a Value onto the Stack (Push)

Compilers I - Chapter 4: Generating Better Code

Data Structures UNIT III. Model Question Answer

2) Write in detail the issues in the design of code generator.

Cpt S 223. School of EECS, WSU

COMPUTER SCIENCE. Paper 1 (THEORY)

Data Structures and Algorithm Analysis (CSC317) Intro/Review of Data Structures Focus on dynamic sets

Bottom-Up Parsing. An Introductory Example

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)

COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing

Stacks. Linear data structures

1 The Java Virtual Machine

VISION FINANCIALS. Budget Status (GLS8020) Introduction. Purpose of the Report

HW3: Programming with stacks

EE2204 DATA STRUCTURES AND ALGORITHM (Common to EEE, EIE & ICE)

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT. Course Curriculum. DATA STRUCTURES (Code: )

Honors Class (Foundations of) Informatics. Tom Verhoeff. Department of Mathematics & Computer Science Software Engineering & Technology

STACKS,QUEUES, AND LINKED LISTS

Linked Lists, Stacks, Queues, Deques. It s time for a chainge!

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

Chapter Objectives. Chapter 7. Stacks. Various Types of Stacks LIFO. Empty Stack. Stacks

Binary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( B-S-T) are of the form. P parent. Key. Satellite data L R

AFF 808. Sub. Code 4BIT1C1. B.Sc. DEGREE EXAMINATION, NOVEMBER First Semester. Information Technology

Collaboration policy. Where to get help (but no code in ) Office hours Lab TAs in Friend 008/009 Bounce ideas (but not code) off classmates

Overview of Web Request Routing Through Unified ICM

PROGRAMMING CONCEPTS AND EMBEDDED PROGRAMMING IN C, C++ and JAVA: Lesson-4: Data Structures: Stacks

NM i Automasjon 2014 Project 4:

PARALLELIZED SUDOKU SOLVING ALGORITHM USING OpenMP

The following themes form the major topics of this chapter: The terms and concepts related to trees (Section 5.2).

An Overview of Stack Architecture and the PSC 1000 Microprocessor

Cobra Standard Version 1.0

BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security. & BSc. (Hons.) Software Engineering

Common Data Structures

AP Computer Science AB Syllabus 1

Data Structures. Level 6 C Module Descriptor

PERFORMANCE CRITERIA FOR SOFTWARE METRICS MODEL REFINEMENT

Does a Programmer s Activity Indicate Knowledge of Code? Software Engineering Seminar 2010

This lecture. Abstract data types Stacks Queues. ADTs, Stacks, Queues Goodrich, Tamassia

Language Processing Systems

Class XII (Theory) C++

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, School of Informatics University of Edinburgh als@inf.ed.ac.

14 Stacks, Queues, And Linked Lists

Zoho CRM and Google Apps Synchronization

Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile

WORKSPACE WEB DEVELOPMENT & OUTSOURCING TRAINING CENTER

Chapter 6. Decoding. Statistical Machine Translation

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

Instructions for setting up Junk E mail filters

CSC 2405: Computer Systems II

Unit Testing with Monkeys Karl-Mikael Björklid University of Jyväskylä Department of Mathematical Information Technology

Chapter 2: Elements of Java

Stacks and queues. Algorithms and Data Structures, Fall Rasmus Pagh. Based on slides by Kevin Wayne, Princeton

Computer Architecture Lecture 3: ISA Tradeoffs. Prof. Onur Mutlu Carnegie Mellon University Spring 2013, 1/18/2013

İSTANBUL AYDIN UNIVERSITY

MPLS Environment. To allow more complex routing capabilities, MPLS permits attaching a

Catalan Numbers. Thomas A. Dowling, Department of Mathematics, Ohio State Uni- versity.

Virtual Leased Lines - Martini

First Bytes Programming Lab 2

Data Structures and Data Manipulation

PROBLEMS (Cap. 4 - Istruzioni macchina)

64-Bit NASM Notes. Invoking 64-Bit NASM

Statistical Machine Translation

Data Structures and Algorithms

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING LESSON PLAN

Transcription:

Data Structures and Algorithms V22.0102 Otávio Braga

We use a stack When an operand is read, output it When an operator is read Pop until the top of the stack has an element of lower precedence Then push it When ) is found, pop until we find the matching ( ( has the lowest precedence when in the stack but has the highest precedence when in the input When we reach the end of input, pop until the stack is empty

3+4*5/6 Infix to Postfix Conversion Example 1

3+4*5/6 Stack: Output: Infix to Postfix Conversion Example 1

3+4*5/6 Stack: Output: 3 Infix to Postfix Conversion Example 1

3+4*5/6 Stack: + Output: 3 Infix to Postfix Conversion Example 1

3+4*5/6 Stack: + Output: 3 4 Infix to Postfix Conversion Example 1

3+4*5/6 Stack: + * Output: 3 4 Infix to Postfix Conversion Example 1

3+4*5/6 Stack: + * Output: 3 4 5 Infix to Postfix Conversion Example 1

Example 1 3+4*5/6 Stack: + Output: 3 4 5 *

Example 1 3+4*5/6 Stack: + / Output: 3 4 5 *

Example 1 3+4*5/6 Stack: + / Output: 3 4 5 * 6

Example 1 3+4*5/6 Stack: + Output: 3 4 5 * 6 /

Example 1 3+4*5/6 Stack: Output: 3 4 5 * 6 / + Done!

Example 2 (300+23)*(43-21)/(84+7)

Example 2 (300+23)*(43-21)/(84+7) Stack: Output:

Example 2 (300+23)*(43-21)/(84+7) Stack: ( Output:

Example 2 (300+23)*(43-21)/(84+7) Stack: ( Output: 300

Example 2 (300+23)*(43-21)/(84+7) Stack: ( + Output: 300

Example 2 (300+23)*(43-21)/(84+7) Stack: ( + Output: 300 23

Example 2 (300+23)*(43-21)/(84+7) Stack: ( Output: 300 23 +

Example 2 (300+23)*(43-21)/(84+7) Stack: Output: 300 23 +

Example 2 (300+23)*(43-21)/(84+7) Stack: * Output: 300 23 +

Example 2 (300+23)*(43-21)/(84+7) Stack: * ( Output: 300 23 +

Example 2 (300+23)*(43-21)/(84+7) Stack: * ( Output: 300 23 + 43

Example 2 (300+23)*(43-21)/(84+7) Stack: * ( - Output: 300 23 + 43

Example 2 (300+23)*(43-21)/(84+7) Stack: * ( - Output: 300 23 + 43 21

Example 2 (300+23)*(43-21)/(84+7) Stack: * ( Output: 300 23 + 43 21 -

Example 2 (300+23)*(43-21)/(84+7) Stack: * Output: 300 23 + 43 21 -

Example 2 (300+23)*(43-21)/(84+7) Stack: Output: 300 23 + 43 21 - *

Example 2 (300+23)*(43-21)/(84+7) Stack: / Output: 300 23 + 43 21 - *

Example 2 (300+23)*(43-21)/(84+7) Stack: / ( Output: 300 23 + 43 21 - *

Example 2 (300+23)*(43-21)/(84+7) Stack: / ( Output: 300 23 + 43 21 - * 84

Example 2 (300+23)*(43-21)/(84+7) Stack: / ( + Output: 300 23 + 43 21 - * 84

Example 2 (300+23)*(43-21)/(84+7) Stack: / ( + Output: 300 23 + 43 21 - * 84 7

Example 2 (300+23)*(43-21)/(84+7) Stack: / ( Output: 300 23 + 43 21 - * 84 7 +

Example 2 (300+23)*(43-21)/(84+7) Stack: / Output: 300 23 + 43 21 - * 84 7 +

Example 2 (300+23)*(43-21)/(84+7) Stack: Output: 300 23 + 43 21 - * 84 7 + / Done!

Example 3 (4+8)*(6-5)/((3-2)*(2+2))

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: Output:

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: ( Output:

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: ( Output: 4

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: ( + Output: 4

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: ( + Output: 4 8

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: ( Output: 4 8 +

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: Output: 4 8 +

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: * Output: 4 8 +

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: * ( Output: 4 8 +

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: * ( Output: 4 8 + 6

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: * ( - Output: 4 8 + 6

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: * ( - Output: 4 8 + 6 5

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: * ( Output: 4 8 + 6 5 -

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: * Output: 4 8 + 6 5 -

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: Output: 4 8 + 6 5 - *

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / Output: 4 8 + 6 5 - *

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / ( Output: 4 8 + 6 5 - *

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / ( ( Output: 4 8 + 6 5 - *

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / ( ( Output: 4 8 + 6 5 - * 3

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / ( ( - Output: 4 8 + 6 5 - * 3

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / ( ( - Output: 4 8 + 6 5 - * 3 2

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / ( ( Output: 4 8 + 6 5 - * 3 2 -

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / ( Output: 4 8 + 6 5 - * 3 2 -

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / ( * Output: 4 8 + 6 5 - * 3 2 -

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / ( * ( Output: 4 8 + 6 5 - * 3 2 -

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / ( * ( Output: 4 8 + 6 5 - * 3 2-2

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / ( * ( + Output: 4 8 + 6 5 - * 3 2-2

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / ( * ( + Output: 4 8 + 6 5 - * 3 2 2 2

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / ( * ( Output: 4 8 + 6 5 - * 3 2 2 2 +

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / ( * Output: 4 8 + 6 5 - * 3 2 2 2 +

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / ( Output: 4 8 + 6 5 - * 3 2 2 2 + *

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: / Output: 4 8 + 6 5 - * 3 2 2 2 + *

Example 3 (4+8)*(6-5)/((3-2)*(2+2)) Stack: Output: 4 8 + 6 5 - * 3 2 2 2 + * / Done!