L YNBROOK C OMPUTER S CIENCE Member Meeting, November 10, 2008.

Slides:



Advertisements
Similar presentations
L YNBROOK C OMPUTER S CIENCE Member Meeting, November 3, 2008.
Advertisements

Data Structures Through C
INFIX, PREFIX, & POSTFIX EXPRESSIONS. Infix Notation We usually write algebraic expressions like this: a + b This is called infix notation, because the.
Where Syntax Meets Semantics
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Chapter 2 – Combinational.
Digital Electronics Lecture 2 Logic Gates. Lecture 2 outline Announcement:
(CSC 102) Discrete Structures Lecture 5.
Stacks & Their Applications COP Stacks  A stack is a data structure that stores information arranged like a stack.  We have seen stacks before.
Stacks - 3 Nour El-Kadri CSI Evaluating arithmetic expressions Stack-based algorithms are used for syntactical analysis (parsing). For example.
Prefix, Postfix, Infix Notation
COSC 2006 Chapter 7 Stacks III
D ATA S TRUCTURE MSc.IT Ali Abdul Karem Habib. S TACK A PPLICATIONS Web browser: stores the addresses of recently visited sites on a stack. Each time.
Joseph Lindo Abstract Data Types Sir Joseph Lindo University of the Cordilleras.
Infix, Postfix, Prefix.
Assembly Language and Computer Architecture Using C++ and Java
Postfix notation. About postfix notation Postfix, or Reverse Polish Notation (RPN) is an alternative to the way we usually write arithmetic expressions.
Section 5.2 Defining Languages. © 2005 Pearson Addison-Wesley. All rights reserved5-2 Defining Languages A language –A set of strings of symbols –Examples:
Bit Operations C is well suited to system programming because it contains operators that can manipulate data at the bit level –Example: The Internet requires.
A bit can have one of two values: 0 or 1. The C language provides four operators that can be used to perform bitwise operations on the individual bits.
1 MATERI PENDUKUNG OPERATOR Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
CS 206 Introduction to Computer Science II 10 / 28 / 2009 Instructor: Michael Eckmann.
More About Stacks: Stack Applications Dan Nguyen CS 146, Spring 2004 Professor Sin-Min Lee.
Binary Trees. Node structure Data A data field and two pointers, left and right.
Stack Applications.
Week7 Stack Data Structures & Algorithms. Introduction to Stacks and Queues Widely used data structures Ordered List of element Easy to implement Easy.
CSC 205 Programming II Postfix Expressions. Recap: Stack Stack features Orderly linear structure Access from one side only – top item Stack operations.
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Logic Circuits I.
(c) University of Washington20d-1 CSC 143 Java Applications of Trees.
INTRODUCTION TO THE THEORY OF COMPUTATION INTRODUCTION MICHAEL SIPSER, SECOND EDITION 1.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Logic Circuits I.
Copyright © Curt Hill BitWise Operators Packing Logicals with Other Bases as a Bonus.
February 23, Announcements ACSL – March 9 Digital Electronics – 2 Graph Theory – 2 Boolean Algebra – 1 USACO – March
Linear Data Structures LIFO – Polish notation Context Saving.
Prefix, Postfix and Infix. Infix notation  A-B/(C+D)  evaluate C+D (call the result X),  then B/X (call the result Y),  and finally A-Y.  The order.
Aim: How to write in Scientific Notation DO NOW: 1. WHAT DOES 10 5 MEAN? 2. WHAT IS THE VALUE OF USING YOUR CALCULATOR, CALCULATE 4.5 X 10 6.
Wednesday, March 2 Homework #2 is posted Homework #2 is posted Due Friday, March 4 (BOC) Due Friday, March 4 (BOC) Program #5 is posted Program #5 is posted.
Prefix, Postfix, Infix Notation. Infix Notation  To add A, B, we write A+B  To multiply A, B, we write A*B  The operators ('+' and '*') go in between.
Stacks A stack is a linear data structure that can be accessed only at one of its ends for storing and retrieving data LIFO (Last In First Out) structure.
CC 215 DATA STRUCTURES MORE ABOUT STACK APPLICATIONS Dr. Manal Helal - Fall 2014 Lecture 6 AASTMT Engineering and Technology College 1.
Multiplication
Infix to postfix conversion
Objectives In this lesson, you will learn to: Define stacks
ASTs, Grammars, Parsing, Tree traversals
Multiplication
COMPUTER 2430 Object Oriented Programming and Data Structures I
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Stack application: postponing data usage
Stacks – Calculator Application
Stacks – Calculator Application
Stacks – Calculator Application
PART II STACK APPLICATIONS
University of Gujrat Department of Computer Science
Stacks Chapter 5 Adapted from Pearson Education, Inc.
Stacks, Queues, and Deques
More About Stacks: Stack Applications
Number Systems and Circuits for Addition
Stacks – Calculator Application
Queue Applications Lecture 31 Mon, Apr 9, 2007.
Infix to Postfix Conversion
Computer Science 2 5/17/2016 Finish the Queue Program
Logic Circuits I Lecture 3.
CSC 143 Java Applications of Trees.
XOR Function Logic Symbol  Description  Truth Table 
Queue Applications Lecture 31 Tue, Apr 11, 2006.
CO4301 – Advanced Games Development Week 3 Parsing Continued
Basic Logic Operations
More About Stacks: Stack Applications
Stacks A stack is an ordered set of elements, for which only the last element placed into the stack is accessible. The stack data type is also known as.
Presentation transcript:

L YNBROOK C OMPUTER S CIENCE Member Meeting, November 10, 2008

U PCOMING C OMPETITIONS Today: USACO November Round 11/12 (Wed): TopCoder SRM Round 12/5-12/8 (Fri-Mon): USACO December Round 12/15 (Mon): ACSL Contest #1 Check for full ACSL and USACO schedules!

T ESTED M ATERIAL ON THE ACSL What does this program do? Number Systems (different base operations) Recursive Functions (f(x) = f(x-1) + 1) Boolean Algebra (not A + B = …) Bit String Flicking (right shift, left shift) LISP Evaluation (ADD, SUB, DIV, MULT) Digital Electronics (AND, OR, XOR, NAND, NOR, XNOR) Prefix/Infix/Postfix Notation (+ 3 4) Data Structures (heaps, binary trees, stacks, etc.)

W HAT DOES THIS PROGRAM DO ? Usually written in an easy-to-understand language such as BASIC or Pascal Trick is to read the code as if it were in english, and then evaluate the operations as they come. program S(input, output); var a,b:integer; begin a:=0; b:=0; for a:=0 to 5 do begin b:=b+1; end; Simple evaluation leads us to b = 6

I NFIX N OTATION Operators are written in-between operands Exactly like normal mathematical evaluation A * ( B + C ) / D First add B to C Then multiply the result by A Then divide by D

P REFIX N OTATION Operators are written before their operands Trick is to group them with parenthesis, then convert into infix notation, and evaluate / * A + B C D (/ (* A (+ B C) ) D ) Infix notation: A * (B + C) / D

P OSTFIX N OTATION Operators are written after their operands Trick is to group them with parenthesis, then convert into infix notation, and evaluate A B C + * D / ( (A (B C +) *) D / ) Infix notation: A * (B + C) / D

W HAT DOES THIS PROGRAM DO ? program SR(input,output); var a,b,c,x:integer; begin b:=0; for a:=1 to 5 do begin x:=0; while x <= 5 do begin c:=5; repeat b:=b+c; c:=c-1; until c=0; x:=x+1; end; end end; What is the final value of b after SR is executed?

S OLUTION 1. Read code as if it were in english 2. Translate code into math ( ( ) * 6 ) * 5 3. Evaluate mathematical operation = (15) * 6 * 5 =15 * 30 = 450

P REFIX /I NFIX /P OSTFIX N OTATION Translate the following from prefix to postfix: - + * 2 x * 3 y z

S OLUTION 1. Group problem with parenthesis (- (+ (* 2 x) (* 3 y)) z) 2. Translate problem into infix notation (((2 * x) + (3 * y)) - z) 3. Work backwards to translate from infix notation to postfix notation (((2 x *) (3 y *) +) z -) 2 x * 3 y * + z -

M ISCELLANEOUS Remember to sign in! Dont forget to turn in your check ($15, payable to Lynbrook ASB) if you havent done so already! Remember to take the USACO (ends today)! Check for updateshttp://LynbrookCS.com Dont forget to review the material we covered today – it comes up on the ACSL!