Stack. A list whose end points are pointed by top and bottom
|
|
- Jasmine Benson
- 6 years ago
- Views:
Transcription
1 4. Stck
2 Stck A list whose end points re pointed by top nd bottom Insertion nd deletion tke plce t the top (cf: Wht is the difference between Stck nd Arry?) Bottom is constnt, but top grows nd shrinks! Not possible to ccess the items within stck, except top! Which item is removed first? : LIFO (Lst-In First-Out)
3 Implementtion : Use of Arry Use one-dimensionl rry Use one vrible : top Alwys initilize the top by - Ex : #define MAX_STACK_SIZE typedef struct { top=- chr key; } element; element stck [MAX_STACK_SIZE]; int top = -; /initilize top/ stck
4 Opertors: Push nd Pop PUSH : Insert n item into stck ; Time =?? void push (int top, element item) if (top >= MAX_STACK_SIZE - ) top=k+ return stck_full( ); top=k top = top + ; /increse top by / stck [top] = item; POP : Delete n item from stck; Time =?? push pop d 3 stck element pop (int top) if (top == ) return stck_empty(); item = stck [top] top = top ; /decrese top by / return item; top=k+ top=k d 3 stck
5 Push nd Pop... Ex: Push(E), Push(F), Pop, Pop top D Push(E) top E D Push(F) top F E D bottom C B A Pop bottom C B A Pop bottom C B A Reference from Dt Structures by Gilberg nd Forouzn
6 Applictions of Stck Evlution of Arithmetic Expressions Mze Problem Prsing (Pttern Mtching) Function Clls/Returns (Ex: Recursions) Queens Problem Bcktrcking
7 Evlution of Arithmetic Expression Arithmetic expression consists of two elements s follows: Opernd:, b, c,... x, y, z Opertor: +, -,,, (, ),... How to clculte the rithmetic expression? Ex: b + c Ex2: + b c Ex 3: (b + c) Ex4: / b c + d e c Point: Which opertor is computed first?
8 Evlution Method of Arithmetic Expression Generl Method (i.e., Humn Method) () Assign priority to ech opertor (2) Prenthesize opertors (if necessry) (3) Compute from the inside to the outside of prentheses This pproch is not efficient! c + b / c 3 (c + b)/ c 2 Compiler Method () Trnsltion: Convert Infix into Postfix (2) Evlution: Compute by Postfix This is efficient, nd does not need the prenthesizing.
9 Priority of Opertors in C Postfix form Prefix form opertor priority order () [] ->. 7 left-to-right left-to-right -- ++! ~ - + & sizeof 5 right-to-left (type) 4 right-to-left / % 3 left-to-right left-to-right << >> left-to-right > >= < <= left-to-right ==!= 9 left-to-right & 8 left-to-right ^ 7 left-to-right 6 left-to-right && 5 left-to-right 4 left-to-right?: 3 right-to-left = += -= /= = %= <<= >>= &= 2 right-to-left ^= =, left-to-right
10 Three Arithmetic Expressions () Infix Opertor loctes in the middle of opernds i.e., (opnd ) (optr) (opnd 2 ) Infix + b + b c ( + b) c (2) Postfix Opertor loctes t the end of opernds i.e., (opnd ) (opnd 2 ) (optr) (3) Prefix Opertor loctes t the first of opernds i.e., (optr) (opnd ) (opnd 2 ) Postfix b + b c + b + c Pretfix + b + b c + b c Note: Postfix nd Prefix do not use Prenthesis opertor!
11 stck stck Bsic Principle (According to Postfix property) opernds lwys loctes in front of their opertor. push To store the vlues of opernds, stck is needed. d + b c d Algorithm Evlution of Postfix () Scn Postfix from left to right. (just once run!) (2) If symbol X is opernd, push it to the stck (3) Otherwise (i.e., X is opertor) ) pop opernds (for X) from the stck 2) perform the specified opertion = 3) push the result bck on the stck 3 pop pop + d d +d +d 3
12 Evlution of Postfix : Procedures Ex: 6 2 / eos (eos is chrcter tht indictes the end of eqution) token 6 2 / stck [] [] [2] /2 6/2 3 6/2-3 6/ / / / top 2 When reching eos, print out pop. Here, the result lwys exists t the top of stck
13 Trnslte : Infix to Postfix () Generl Approch : Prenthesizing () Prenthesize the opertors of Infix expression ccording to their priorities. (2) Move the opertor in ech prenthesis to the right side of the prenthesis. (3) Delete ll the prentheses. Ex: / b c + d e c () Prenthesize : ( / b) c + (d e) ( c) ((( / b) c) + (d e)) ( c) (((( / b) c) + (d e)) ( c)) (2) Move : (((( b) / c) (d e) ) + ( c) ) (3) Delete : b / c d e + c This pproch requires t lest two psses; thus, not efficient!
14 Trnslte : Infix to Postfix (2) Another Approch : Use of Stck The order of opernds is not chnged. The order of opertors is chnged by their priorities To store the priorities, stck is used b c + Algorithm () Scn left to right; (Just once!) (2) If symbol X is opernd, print(x) Otherwise, (i.e., X is opertor) ) Compre the priority of X with the priority of opertor (t the top) in stck How to decide 2) Decide if we push or pop on opertors? - push X into stck, or - pop opertors from the stck + b c + stck
15 Trnslte : Infix to Postfix (3) How to decide?: Pop or Push top stck infix expression c + b d compre current symbol X In-Stck Priority (ISP) In-Coming-Priority (ICP) Two Cses; Cse : If ISP[stck [top]] < ICP[X], then Push (X) Cse 2 : If ISP[stck [top]] ICP[X], then ) Pop(top) nd Print it 2) Push (X)
16 Trnslte : Infix to Postfix (Procedures) Ex : + b c eos symbol + b c eos stck [] [] [2] top - - output b b bc bc+ Since (input) is higher thn + (in stck), we push
17 Trnslte : Infix to Postfix (Procedures) Ex : b + c eos symbol b + c eos stck [] [] [2] + + top - - output b b bc bc+ Since + (input) is lower thn (in stck), we pop
18 Trnslte : Infix to Postfix (Procedures) Ex : b / c eos token b / c eos stck [] [] [2] / / top - - output b b bc bc/ Since / (input) is the sme s (in stck), we pop.
19 Wht if prenthesis exists? Concept of Prenthesis Prenthesis cn be employed. Prenthesis hs the highest priority. y / ( x + y) z b + Left nd right prenthesis mens the strt nd the end opertion, respectively. Computtion procedures become complex if prenthesis exists. All prentheses must be deleted when trnslting infix to postfix Ex: (b + c) d Wht is the result of postfix? Process of Prenthesis If X is left prenthesis : Push If X is right prenthesis: Pop nd Print ll opertors in Stck until mtched left prenthesis is reched! (but, the left prenthesis is not printed) ( + b ) c pop ) + ( pop stck
20 Trnslte : Infix to Postfix (Procedures) Ex: (b + c) d eos token ( b + c ) d eos stck [] [] [2] ( ( ( ( + + top output b b bc bc+ bc+ bc+d bc+d Exercise: (((( / b) c) + (d e)) ( c))
21 stck stck Performnce Anlysis Infix Trnsltion Time : O(n) (n : no. of symbols in infix) Spce : it needs n extr stck Wht is the stck size required t this time? t lest one, t most (mx) no. of opertors Exmples + b / c d... (constntly incresing priority) b / c + d... (constntly decresing priority) / b c + d e c + b / c d e + c Postfix Trnsltion O(n) Evlution O(n) Evlution Time : O(n) (n : no. of symbols in postfix) Spce: it lso needs n extr stck Wht is the required stck size? The required size is (mx) no. of opernds 3 Result
22 A Nice Appliction of Stck! Mze Problem
23 Representtion of Mze Mze Problem Use two-dimensionl rry: mze[row][col] : open pths : closed pths entrnce exit
24 Possible Moving Direction Mze Problem Let X be the current position. There re 8 possible moving directions NW N NE [row-][col-] [row-][col] [row-][col+] [row][col-] W X [row][col] [row][col+] E [row+][col-] SW [row+][col] S [row+][col+] SE
25 Mze Problem Moving Directions Every position (except border) hs 8 directions If [row, col] is on border, then it hs 3 or 5 directions. To void checking for borders, we surround the mze by s. Size of Mze m p mze needs (m + 2) (p + 2) rry Entrnce : mze[][] Exit : mze[m][p] [] [2] [3] [m] [] [2] [3] [p]
26 Mze Problem We predefine possible directions; use move rry. typedef struct { short int short int vert; horiz; } offsets; offsets move [8] ; / rry of moves for ech direction / Tble of moves NW(7) N() nme dir move[dir].vert move[dir].hori N NE E SE S SW W NW W [2][4] [3][4] X (6) [3][5] [4][4] SW(5) S(4) NE() [2][5] [2][6] [4][5] [3][6] E (2) [4][6] SE(3)
27 Mze Problem If we re t position mze [row][col], then the position for the next move mze [next_row][next_col] we set; next_row = row + move[dir].vert; next_col = col + move[dir].horiz; We exmine the possible moves, strting from the north nd moving clockwise. #define MAX_STACK_SIZE typedef struct { short int row; short int col; short int dir; } element; element stck [MAX_STACK_SIZE]; Before moving, we must sve our current position; - Why? To sfely return bck to it!! - Use stck; To sve the position in stck, we define element s the bove. We need to void returning to previously tried pth - Use rry mrk[row][col] ; initilly, ll entries re - Mrk to when the position is visited
28 Exmple Cul-de-sc Mze Problem (row, col, dir) Next direction! mze = mrk = row=; col=; dir=; dir=; nextrow=; nextcol=; No! dir=; nextrow=; nextcol=2; No! dir=2; nextrow=; nextcol=2; No! dir=3; nextrow=2; nextcol=2; Yes! row=2; col=2; dir=; dir=; nextrow=; nextcol=2; No! dir=; nextrow=; nextcol=3; Yes! row=; col=3; dir=; push (3,3,3) push (2,2,2) (2,2,4) push (,,) (,,4) stck row=2; col=2; dir=2; pop pop dir=2; nextrow=2; nextcol=3; No! dir=3; nextrow=3; nextcol=3; Yes! row=3; col=3; dir=; dir=2; nextrow=3; nextcol=4; Yes!
29 Mze Problem Algorithm pth ( ) { mrk[][]=; top=; stck[].row=; stck[].col=; stck[].dir=; while (top > - &&!found) { position = pop(); row=position.row; col=position.col; dir=position.dir; while (dir < 8 &&!found) { / move in direction dir / nextrow = row + move[dir].vert; nextcol = col + move[dir].horiz; } } if (nextrow == EXIT_ROW && nextcol == EXIT_COL) found = TRUE; else if (!mze[nextrow][nextcol] &&!mrk[nextrow][nextcol] ) { mrk[nextrow][nextcol] = ; position.row = row; position.col = col; position.dir = ++dir; push (position); row = nextrow; col = nextcol; dir = ; } else {mrk[nextrow][nextcol] = ; ++dir;}
30 Mrk Mze Problem Wht is the mximum stck size? Ech position within the mze is visited no more thn once; The stck needs only the number of s in the mze. p push Performnce Time : O(m p) Spce : rrys(mze, move, mrk) + extr spce(stck) m pop (2,2,3) (,,2) stck Mze
CHAPTER 3 STACKS AND QUEUES
CHAPTER 3 STACKS AND QUEUES All the programs in this file are selected from Ellis Horowitz, Sartaj Sahni, and Susan Anderson-Freed Fundamentals of Data Structures in C /2nd Edition, Silicon Press, 2008.
More informationCSE 401 Midterm Exam 11/5/10 Sample Solution
Question 1. egulr expressions (20 points) In the Ad Progrmming lnguge n integer constnt contins one or more digits, but it my lso contin embedded underscores. Any underscores must be preceded nd followed
More informationSTACKS AND QUEUES CHAPTER 3
CHAPTER 3 STACKS AND QUEUES All the programs in this file are selected from Ellis Horowitz, Sartaj Sahni, and Susan Anderson-Freed Fundamentals of Data Structures in C, CHAPTER 3 1 Stack: a Last-In-First-Out
More information10/12/17. Motivating Example. Lexical and Syntax Analysis (2) Recursive-Descent Parsing. Recursive-Descent Parsing. Recursive-Descent Parsing
Motivting Exmple Lexicl nd yntx Anlysis (2) In Text: Chpter 4 Consider the grmmr -> cad A -> b Input string: w = cd How to build prse tree top-down? 2 Initilly crete tree contining single node (the strt
More informationUnion-Find Problem. Using Arrays And Chains. A Set As A Tree. Result Of A Find Operation
Union-Find Problem Given set {,,, n} of n elements. Initilly ech element is in different set. ƒ {}, {},, {n} An intermixed sequence of union nd find opertions is performed. A union opertion combines two
More information10/9/2012. Operator is an operation performed over data at runtime. Arithmetic, Logical, Comparison, Assignment, Etc. Operators have precedence
/9/22 P f Performing i Si Simple l Clcultions C l l ti with ith C#. Opertors in C# nd Opertor Precedence 2. Arithmetic Opertors 3. Logicl Opertors 4. Bitwise Opertors 5. Comprison Opertors 6. Assignment
More informationUnit 5 Vocabulary. A function is a special relationship where each input has a single output.
MODULE 3 Terms Definition Picture/Exmple/Nottion 1 Function Nottion Function nottion is n efficient nd effective wy to write functions of ll types. This nottion llows you to identify the input vlue with
More information2014 Haskell January Test Regular Expressions and Finite Automata
0 Hskell Jnury Test Regulr Expressions nd Finite Automt This test comprises four prts nd the mximum mrk is 5. Prts I, II nd III re worth 3 of the 5 mrks vilble. The 0 Hskell Progrmming Prize will be wrded
More informationΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών
ΕΠΛ323 - Θωρία και Πρακτική Μταγλωττιστών Lecture 3 Lexicl Anlysis Elis Athnsopoulos elisthn@cs.ucy.c.cy Recognition of Tokens if expressions nd reltionl opertors if è if then è then else è else relop
More informationDr. D.M. Akbar Hussain
Dr. D.M. Akr Hussin Lexicl Anlysis. Bsic Ide: Red the source code nd generte tokens, it is similr wht humns will do to red in; just tking on the input nd reking it down in pieces. Ech token is sequence
More informationInformation Retrieval and Organisation
Informtion Retrievl nd Orgnistion Suffix Trees dpted from http://www.mth.tu.c.il/~himk/seminr02/suffixtrees.ppt Dell Zhng Birkeck, University of London Trie A tree representing set of strings { } eef d
More informationControl-Flow Analysis and Loop Detection
! Control-Flow Anlysis nd Loop Detection!Lst time! PRE!Tody! Control-flow nlysis! Loops! Identifying loops using domintors! Reducibility! Using loop identifiction to identify induction vribles CS553 Lecture
More informationFunctor (1A) Young Won Lim 8/2/17
Copyright (c) 2016-2017 Young W. Lim. Permission is grnted to copy, distribute nd/or modify this document under the terms of the GNU Free Documenttion License, Version 1.2 or ny lter version published
More informationCS201 Discussion 10 DRAWTREE + TRIES
CS201 Discussion 10 DRAWTREE + TRIES DrwTree First instinct: recursion As very generic structure, we could tckle this problem s follows: drw(): Find the root drw(root) drw(root): Write the line for the
More informationReducing a DFA to a Minimal DFA
Lexicl Anlysis - Prt 4 Reducing DFA to Miniml DFA Input: DFA IN Assume DFA IN never gets stuck (dd ded stte if necessry) Output: DFA MIN An equivlent DFA with the minimum numer of sttes. Hrry H. Porter,
More informationFunctor (1A) Young Won Lim 10/5/17
Copyright (c) 2016-2017 Young W. Lim. Permission is grnted to copy, distribute nd/or modify this document under the terms of the GNU Free Documenttion License, Version 1.2 or ny lter version published
More informationWhat are suffix trees?
Suffix Trees 1 Wht re suffix trees? Allow lgorithm designers to store very lrge mount of informtion out strings while still keeping within liner spce Allow users to serch for new strings in the originl
More informationCPSC 213. Polymorphism. Introduction to Computer Systems. Readings for Next Two Lectures. Back to Procedure Calls
Redings for Next Two Lectures Text CPSC 213 Switch Sttements, Understnding Pointers - 2nd ed: 3.6.7, 3.10-1st ed: 3.6.6, 3.11 Introduction to Computer Systems Unit 1f Dynmic Control Flow Polymorphism nd
More informationFig.25: the Role of LEX
The Lnguge for Specifying Lexicl Anlyzer We shll now study how to uild lexicl nlyzer from specifiction of tokens in the form of list of regulr expressions The discussion centers round the design of n existing
More informationFall 2018 Midterm 1 October 11, ˆ You may not ask questions about the exam except for language clarifications.
15-112 Fll 2018 Midterm 1 October 11, 2018 Nme: Andrew ID: Recittion Section: ˆ You my not use ny books, notes, extr pper, or electronic devices during this exm. There should be nothing on your desk or
More informationUNIT 11. Query Optimization
UNIT Query Optimiztion Contents Introduction to Query Optimiztion 2 The Optimiztion Process: An Overview 3 Optimiztion in System R 4 Optimiztion in INGRES 5 Implementing the Join Opertors Wei-Png Yng,
More informationAlgorithm Design (5) Text Search
Algorithm Design (5) Text Serch Tkshi Chikym School of Engineering The University of Tokyo Text Serch Find sustring tht mtches the given key string in text dt of lrge mount Key string: chr x[m] Text Dt:
More informationChapter3 Stacks and Queues
Chapter Stacks and Queues Stacks Stacks Using Dynamic Arrays Queues Circular Queues Using Dynamic Arrays A Maze Problem Evaluation of Expressions Multiple Stacks and Queues C-C Tsai P. Stacks A stack is
More informationLexical Analysis: Constructing a Scanner from Regular Expressions
Lexicl Anlysis: Constructing Scnner from Regulr Expressions Gol Show how to construct FA to recognize ny RE This Lecture Convert RE to n nondeterministic finite utomton (NFA) Use Thompson s construction
More informationbinary trees, expression trees
COMP 250 Lecture 21 binry trees, expression trees Oct. 27, 2017 1 Binry tree: ech node hs t most two children. 2 Mximum number of nodes in binry tree? Height h (e.g. 3) 3 Mximum number of nodes in binry
More informationWhat do all those bits mean now? Number Systems and Arithmetic. Introduction to Binary Numbers. Questions About Numbers
Wht do ll those bits men now? bits (...) Number Systems nd Arithmetic or Computers go to elementry school instruction R-formt I-formt... integer dt number text chrs... floting point signed unsigned single
More informationMid-term exam. Scores. Fall term 2012 KAIST EE209 Programming Structures for EE. Thursday Oct 25, Student's name: Student ID:
Fll term 2012 KAIST EE209 Progrmming Structures for EE Mid-term exm Thursdy Oct 25, 2012 Student's nme: Student ID: The exm is closed book nd notes. Red the questions crefully nd focus your nswers on wht
More informationEngineer To Engineer Note
Engineer To Engineer Note EE-186 Technicl Notes on using Anlog Devices' DSP components nd development tools Contct our technicl support by phone: (800) ANALOG-D or e-mil: dsp.support@nlog.com Or visit
More informationSuffix trees, suffix arrays, BWT
ALGORITHMES POUR LA BIO-INFORMATIQUE ET LA VISUALISATION COURS 3 Rluc Uricru Suffix trees, suffix rrys, BWT Bsed on: Suffix trees nd suffix rrys presenttion y Him Kpln Suffix trees course y Pco Gomez Liner-Time
More informationCMPSC 470: Compiler Construction
CMPSC 47: Compiler Construction Plese complete the following: Midterm (Type A) Nme Instruction: Mke sure you hve ll pges including this cover nd lnk pge t the end. Answer ech question in the spce provided.
More informationGeometric transformations
Geometric trnsformtions Computer Grphics Some slides re bsed on Shy Shlom slides from TAU mn n n m m T A,,,,,, 2 1 2 22 12 1 21 11 Rows become columns nd columns become rows nm n n m m A,,,,,, 1 1 2 22
More information5 Regular 4-Sided Composition
Xilinx-Lv User Guide 5 Regulr 4-Sided Composition This tutoril shows how regulr circuits with 4-sided elements cn be described in Lv. The type of regulr circuits tht re discussed in this tutoril re those
More informationCSEP 573 Artificial Intelligence Winter 2016
CSEP 573 Artificil Intelligence Winter 2016 Luke Zettlemoyer Problem Spces nd Serch slides from Dn Klein, Sturt Russell, Andrew Moore, Dn Weld, Pieter Abbeel, Ali Frhdi Outline Agents tht Pln Ahed Serch
More informationUnit #9 : Definite Integral Properties, Fundamental Theorem of Calculus
Unit #9 : Definite Integrl Properties, Fundmentl Theorem of Clculus Gols: Identify properties of definite integrls Define odd nd even functions, nd reltionship to integrl vlues Introduce the Fundmentl
More informationCS 430 Spring Mike Lam, Professor. Parsing
CS 430 Spring 2015 Mike Lm, Professor Prsing Syntx Anlysis We cn now formlly descrie lnguge's syntx Using regulr expressions nd BNF grmmrs How does tht help us? Syntx Anlysis We cn now formlly descrie
More informationData Flow on a Queue Machine. Bruno R. Preiss. Copyright (c) 1987 by Bruno R. Preiss, P.Eng. All rights reserved.
Dt Flow on Queue Mchine Bruno R. Preiss 2 Outline Genesis of dt-flow rchitectures Sttic vs. dynmic dt-flow rchitectures Pseudo-sttic dt-flow execution model Some dt-flow mchines Simple queue mchine Prioritized
More informationIn the last lecture, we discussed how valid tokens may be specified by regular expressions.
LECTURE 5 Scnning SYNTAX ANALYSIS We know from our previous lectures tht the process of verifying the syntx of the progrm is performed in two stges: Scnning: Identifying nd verifying tokens in progrm.
More informationΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών. Lecture 3b Lexical Analysis Elias Athanasopoulos
ΕΠΛ323 - Θωρία και Πρακτική Μταγλωττιστών Lecture 3 Lexicl Anlysis Elis Athnsopoulos elisthn@cs.ucy.c.cy RecogniNon of Tokens if expressions nd relnonl opertors if è if then è then else è else relop è
More informationPYTHON PROGRAMMING. The History of Python. Features of Python. This Course
The History of Python PYTHON PROGRAMMING Dr Christin Hill 7 9 November 2016 Invented by Guido vn Rossum* t the Centrum Wiskunde & Informtic in Amsterdm in the erly 1990s Nmed fter Monty Python s Flying
More informationFall 2018 Midterm 2 November 15, 2018
Nme: 15-112 Fll 2018 Midterm 2 November 15, 2018 Andrew ID: Recittion Section: ˆ You my not use ny books, notes, extr pper, or electronic devices during this exm. There should be nothing on your desk or
More informationCSCI 104. Rafael Ferreira da Silva. Slides adapted from: Mark Redekopp and David Kempe
CSCI 0 fel Ferreir d Silv rfsilv@isi.edu Slides dpted from: Mrk edekopp nd Dvid Kempe LOG STUCTUED MEGE TEES Series Summtion eview Let n = + + + + k $ = #%& #. Wht is n? n = k+ - Wht is log () + log ()
More informationComputer Arithmetic Logical, Integer Addition & Subtraction Chapter
Computer Arithmetic Logicl, Integer Addition & Sutrction Chpter 3.-3.3 3.3 EEC7 FQ 25 MIPS Integer Representtion -it signed integers,, e.g., for numeric opertions 2 s s complement: one representtion for
More informationSome Thoughts on Grad School. Undergraduate Compilers Review and Intro to MJC. Structure of a Typical Compiler. Lexing and Parsing
Undergrdute Compilers Review nd Intro to MJC Announcements Miling list is in full swing Tody Some thoughts on grd school Finish prsing Semntic nlysis Visitor pttern for bstrct syntx trees Some Thoughts
More informationCOMPUTER SCIENCE 123. Foundations of Computer Science. 6. Tuples
COMPUTER SCIENCE 123 Foundtions of Computer Science 6. Tuples Summry: This lecture introduces tuples in Hskell. Reference: Thompson Sections 5.1 2 R.L. While, 2000 3 Tuples Most dt comes with structure
More informationCS 241. Fall 2017 Midterm Review Solutions. October 24, Bits and Bytes 1. 3 MIPS Assembler 6. 4 Regular Languages 7.
CS 241 Fll 2017 Midterm Review Solutions Octoer 24, 2017 Contents 1 Bits nd Bytes 1 2 MIPS Assemly Lnguge Progrmming 2 3 MIPS Assemler 6 4 Regulr Lnguges 7 5 Scnning 9 1 Bits nd Bytes 1. Give two s complement
More informationCOMP 423 lecture 11 Jan. 28, 2008
COMP 423 lecture 11 Jn. 28, 2008 Up to now, we hve looked t how some symols in n lphet occur more frequently thn others nd how we cn sve its y using code such tht the codewords for more frequently occuring
More informationTries. Yufei Tao KAIST. April 9, Y. Tao, April 9, 2013 Tries
Tries Yufei To KAIST April 9, 2013 Y. To, April 9, 2013 Tries In this lecture, we will discuss the following exct mtching prolem on strings. Prolem Let S e set of strings, ech of which hs unique integer
More informationFrom Dependencies to Evaluation Strategies
From Dependencies to Evlution Strtegies Possile strtegies: 1 let the user define the evlution order 2 utomtic strtegy sed on the dependencies: use locl dependencies to determine which ttriutes to compute
More informationEXPONENTIAL & POWER GRAPHS
Eponentil & Power Grphs EXPONENTIAL & POWER GRAPHS www.mthletics.com.u Eponentil EXPONENTIAL & Power & Grphs POWER GRAPHS These re grphs which result from equtions tht re not liner or qudrtic. The eponentil
More informationLexical Analysis. Amitabha Sanyal. (www.cse.iitb.ac.in/ as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay
Lexicl Anlysis Amith Snyl (www.cse.iit.c.in/ s) Deprtment of Computer Science nd Engineering, Indin Institute of Technology, Bomy Septemer 27 College of Engineering, Pune Lexicl Anlysis: 2/6 Recp The input
More informationTwo abstract data types. performed on them) Stacks Last In First Out (LIFO) Queues First In First Out (FIFO)
Two abstract data types o Can be implemented using arrays or linked lists o Restricted lists (only a small number of operations are performed on them) Stacks Last In First Out (LIFO) Queues First In First
More informationToday. Search Problems. Uninformed Search Methods. Depth-First Search Breadth-First Search Uniform-Cost Search
Uninformed Serch [These slides were creted by Dn Klein nd Pieter Abbeel for CS188 Intro to AI t UC Berkeley. All CS188 mterils re vilble t http://i.berkeley.edu.] Tody Serch Problems Uninformed Serch Methods
More informationSuffix Tries. Slides adapted from the course by Ben Langmead
Suffix Tries Slides dpted from the course y Ben Lngmed en.lngmed@gmil.com Indexing with suffixes Until now, our indexes hve een sed on extrcting sustrings from T A very different pproch is to extrct suffixes
More informationCS481: Bioinformatics Algorithms
CS481: Bioinformtics Algorithms Cn Alkn EA509 clkn@cs.ilkent.edu.tr http://www.cs.ilkent.edu.tr/~clkn/teching/cs481/ EXACT STRING MATCHING Fingerprint ide Assume: We cn compute fingerprint f(p) of P in
More informationWhat do all those bits mean now? Number Systems and Arithmetic. Introduction to Binary Numbers. Questions About Numbers
Wht do ll those bits men now? bits (...) Number Systems nd Arithmetic or Computers go to elementry school instruction R-formt I-formt... integer dt number text chrs... floting point signed unsigned single
More informationMidterm 2 Sample solution
Nme: Instructions Midterm 2 Smple solution CMSC 430 Introduction to Compilers Fll 2012 November 28, 2012 This exm contins 9 pges, including this one. Mke sure you hve ll the pges. Write your nme on the
More informationCMSC 331 First Midterm Exam
0 00/ 1 20/ 2 05/ 3 15/ 4 15/ 5 15/ 6 20/ 7 30/ 8 30/ 150/ 331 First Midterm Exm 7 October 2003 CMC 331 First Midterm Exm Nme: mple Answers tudent ID#: You will hve seventy-five (75) minutes to complete
More informationProblem Set 2 Fall 16 Due: Wednesday, September 21th, in class, before class begins.
Problem Set 2 Fll 16 Due: Wednesdy, September 21th, in clss, before clss begins. 1. LL Prsing For the following sub-problems, consider the following context-free grmmr: S T$ (1) T A (2) T bbb (3) A T (4)
More informationCS 432 Fall Mike Lam, Professor a (bc)* Regular Expressions and Finite Automata
CS 432 Fll 2017 Mike Lm, Professor (c)* Regulr Expressions nd Finite Automt Compiltion Current focus "Bck end" Source code Tokens Syntx tree Mchine code chr dt[20]; int min() { flot x = 42.0; return 7;
More informationLecture 10 Evolutionary Computation: Evolution strategies and genetic programming
Lecture 10 Evolutionry Computtion: Evolution strtegies nd genetic progrmming Evolution strtegies Genetic progrmming Summry Negnevitsky, Person Eduction, 2011 1 Evolution Strtegies Another pproch to simulting
More informationCSCI 446: Artificial Intelligence
CSCI 446: Artificil Intelligence Serch Instructor: Michele Vn Dyne [These slides were creted by Dn Klein nd Pieter Abbeel for CS188 Intro to AI t UC Berkeley. All CS188 mterils re vilble t http://i.berkeley.edu.]
More information2 Computing all Intersections of a Set of Segments Line Segment Intersection
15-451/651: Design & Anlysis of Algorithms Novemer 14, 2016 Lecture #21 Sweep-Line nd Segment Intersection lst chnged: Novemer 8, 2017 1 Preliminries The sweep-line prdigm is very powerful lgorithmic design
More informationCS311H: Discrete Mathematics. Graph Theory IV. A Non-planar Graph. Regions of a Planar Graph. Euler s Formula. Instructor: Işıl Dillig
CS311H: Discrete Mthemtics Grph Theory IV Instructor: Işıl Dillig Instructor: Işıl Dillig, CS311H: Discrete Mthemtics Grph Theory IV 1/25 A Non-plnr Grph Regions of Plnr Grph The plnr representtion of
More informationITEC2620 Introduction to Data Structures
ITEC0 Introduction to Dt Structures Lecture 7 Queues, Priority Queues Queues I A queue is First-In, First-Out = FIFO uffer e.g. line-ups People enter from the ck of the line People re served (exit) from
More informationPointers and Arrays. More Pointer Examples. Pointers CS 217
Pointers nd Arrs CS 21 1 2 Pointers More Pointer Emples Wht is pointer A vrile whose vlue is the ddress of nother vrile p is pointer to vrile v Opertions &: ddress of (reference) *: indirection (dereference)
More informationAccelerating 3D convolution using streaming architectures on FPGAs
Accelerting 3D convolution using streming rchitectures on FPGAs Hohun Fu, Robert G. Clpp, Oskr Mencer, nd Oliver Pell ABSTRACT We investigte FPGA rchitectures for ccelerting pplictions whose dominnt cost
More informationAssignment 4. Due 09/18/17
Assignment 4. ue 09/18/17 1. ). Write regulr expressions tht define the strings recognized by the following finite utomt: b d b b b c c b) Write FA tht recognizes the tokens defined by the following regulr
More informationVirtual Machine (Part I)
Hrvrd University CS Fll 2, Shimon Schocken Virtul Mchine (Prt I) Elements of Computing Systems Virtul Mchine I (Ch. 7) Motivtion clss clss Min Min sttic sttic x; x; function function void void min() min()
More informationQuiz2 45mins. Personal Number: Problem 1. (20pts) Here is an Table of Perl Regular Ex
Long Quiz2 45mins Nme: Personl Numer: Prolem. (20pts) Here is n Tle of Perl Regulr Ex Chrcter Description. single chrcter \s whitespce chrcter (spce, t, newline) \S non-whitespce chrcter \d digit (0-9)
More informationSample Midterm Solutions COMS W4115 Programming Languages and Translators Monday, October 12, 2009
Deprtment of Computer cience Columbi University mple Midterm olutions COM W4115 Progrmming Lnguges nd Trnsltors Mondy, October 12, 2009 Closed book, no ids. ch question is worth 20 points. Question 5(c)
More informationRegular Expression Matching with Multi-Strings and Intervals. Philip Bille Mikkel Thorup
Regulr Expression Mtching with Multi-Strings nd Intervls Philip Bille Mikkel Thorup Outline Definition Applictions Previous work Two new problems: Multi-strings nd chrcter clss intervls Algorithms Thompson
More informationOutline. Tiling, formally. Expression tile as rule. Statement tiles as rules. Function calls. CS 412 Introduction to Compilers
CS 412 Introduction to Compilers Andrew Myers Cornell University Lectur8 Finishing genertion 9 Mr 01 Outline Tiling s syntx-directed trnsltion Implementing function clls Implementing functions Optimizing
More informationMA1008. Calculus and Linear Algebra for Engineers. Course Notes for Section B. Stephen Wills. Department of Mathematics. University College Cork
MA1008 Clculus nd Liner Algebr for Engineers Course Notes for Section B Stephen Wills Deprtment of Mthemtics University College Cork s.wills@ucc.ie http://euclid.ucc.ie/pges/stff/wills/teching/m1008/ma1008.html
More informationSolving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence Winter 2016
Solving Prolems y Serching CS 486/686: Introduction to Artificil Intelligence Winter 2016 1 Introduction Serch ws one of the first topics studied in AI - Newell nd Simon (1961) Generl Prolem Solver Centrl
More informationThe Greedy Method. The Greedy Method
Lists nd Itertors /8/26 Presenttion for use with the textook, Algorithm Design nd Applictions, y M. T. Goodrich nd R. Tmssi, Wiley, 25 The Greedy Method The Greedy Method The greedy method is generl lgorithm
More informationOutline. Introduction Suffix Trees (ST) Building STs in linear time: Ukkonen s algorithm Applications of ST
Suffi Trees Outline Introduction Suffi Trees (ST) Building STs in liner time: Ukkonen s lgorithm Applictions of ST 2 3 Introduction Sustrings String is ny sequence of chrcters. Sustring of string S is
More informationOutline CS 412/413. Function calls. Stack layout. Tiling a call. Two translations
CS 412/413 Introduction to Compilers nd Trnsltors Cornell University Andrew Myers Outline Implementing function clls Implementing functions Optimizing wy the pointer Dynmiclly-llocted structures strings
More informationPresentation Martin Randers
Presenttion Mrtin Rnders Outline Introduction Algorithms Implementtion nd experiments Memory consumption Summry Introduction Introduction Evolution of species cn e modelled in trees Trees consist of nodes
More informationMIPS I/O and Interrupt
MIPS I/O nd Interrupt Review Floting point instructions re crried out on seprte chip clled coprocessor 1 You hve to move dt to/from coprocessor 1 to do most common opertions such s printing, clling functions,
More informationCS412/413. Introduction to Compilers Tim Teitelbaum. Lecture 4: Lexical Analyzers 28 Jan 08
CS412/413 Introduction to Compilers Tim Teitelum Lecture 4: Lexicl Anlyzers 28 Jn 08 Outline DFA stte minimiztion Lexicl nlyzers Automting lexicl nlysis Jlex lexicl nlyzer genertor CS 412/413 Spring 2008
More informationAgenda & Reading. Class Exercise. COMPSCI 105 SS 2012 Principles of Computer Science. Arrays
COMPSCI 5 SS Principles of Computer Science Arrys & Multidimensionl Arrys Agend & Reding Agend Arrys Creting & Using Primitive & Reference Types Assignments & Equlity Pss y Vlue & Pss y Reference Copying
More information1. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES)
Numbers nd Opertions, Algebr, nd Functions 45. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES) In sequence of terms involving eponentil growth, which the testing service lso clls geometric
More informationAllocator Basics. Dynamic Memory Allocation in the Heap (malloc and free) Allocator Goals: malloc/free. Internal Fragmentation
Alloctor Bsics Dynmic Memory Alloction in the Hep (mlloc nd free) Pges too corse-grined for llocting individul objects. Insted: flexible-sized, word-ligned blocks. Allocted block (4 words) Free block (3
More informationAlignment of Long Sequences. BMI/CS Spring 2012 Colin Dewey
Alignment of Long Sequences BMI/CS 776 www.biostt.wisc.edu/bmi776/ Spring 2012 Colin Dewey cdewey@biostt.wisc.edu Gols for Lecture the key concepts to understnd re the following how lrge-scle lignment
More informationx )Scales are the reciprocal of each other. e
9. Reciprocls A Complete Slide Rule Mnul - eville W Young Chpter 9 Further Applictions of the LL scles The LL (e x ) scles nd the corresponding LL 0 (e -x or Exmple : 0.244 4.. Set the hir line over 4.
More informationQuestions About Numbers. Number Systems and Arithmetic. Introduction to Binary Numbers. Negative Numbers?
Questions About Numbers Number Systems nd Arithmetic or Computers go to elementry school How do you represent negtive numbers? frctions? relly lrge numbers? relly smll numbers? How do you do rithmetic?
More informationParallel Square and Cube Computations
Prllel Squre nd Cube Computtions Albert A. Liddicot nd Michel J. Flynn Computer Systems Lbortory, Deprtment of Electricl Engineering Stnford University Gtes Building 5 Serr Mll, Stnford, CA 945, USA liddicot@stnford.edu
More informationStack Manipulation. Other Issues. How about larger constants? Frame Pointer. PowerPC. Alternative Architectures
Other Issues Stck Mnipultion support for procedures (Refer to section 3.6), stcks, frmes, recursion mnipulting strings nd pointers linkers, loders, memory lyout Interrupts, exceptions, system clls nd conventions
More informationMatrices and Systems of Equations
Mtrices Mtrices nd Sstems of Equtions A mtri is rectngulr rr of rel numbers. CHAT Pre-Clculus Section 8. m m m............ n n n mn We will use the double subscript nottion for ech element of the mtri.
More informationEssential Question What are some of the characteristics of the graph of a rational function?
8. TEXAS ESSENTIAL KNOWLEDGE AND SKILLS A..A A..G A..H A..K Grphing Rtionl Functions Essentil Question Wht re some of the chrcteristics of the grph of rtionl function? The prent function for rtionl functions
More informationComputing offsets of freeform curves using quadratic trigonometric splines
Computing offsets of freeform curves using qudrtic trigonometric splines JIULONG GU, JAE-DEUK YUN, YOONG-HO JUNG*, TAE-GYEONG KIM,JEONG-WOON LEE, BONG-JUN KIM School of Mechnicl Engineering Pusn Ntionl
More informationcisc1110 fall 2010 lecture VI.2 call by value function parameters another call by value example:
cisc1110 fll 2010 lecture VI.2 cll y vlue function prmeters more on functions more on cll y vlue nd cll y reference pssing strings to functions returning strings from functions vrile scope glol vriles
More informationCS321 Languages and Compiler Design I. Winter 2012 Lecture 5
CS321 Lnguges nd Compiler Design I Winter 2012 Lecture 5 1 FINITE AUTOMATA A non-deterministic finite utomton (NFA) consists of: An input lphet Σ, e.g. Σ =,. A set of sttes S, e.g. S = {1, 3, 5, 7, 11,
More informationThe Distributed Data Access Schemes in Lambda Grid Networks
The Distributed Dt Access Schemes in Lmbd Grid Networks Ryot Usui, Hiroyuki Miygi, Yutk Arkw, Storu Okmoto, nd Noki Ymnk Grdute School of Science for Open nd Environmentl Systems, Keio University, Jpn
More informationTheory of Computation CSE 105
$ $ $ Theory of Computtion CSE 105 Regulr Lnguges Study Guide nd Homework I Homework I: Solutions to the following problems should be turned in clss on July 1, 1999. Instructions: Write your nswers clerly
More informationSection 10.4 Hyperbolas
66 Section 10.4 Hyperbols Objective : Definition of hyperbol & hyperbols centered t (0, 0). The third type of conic we will study is the hyperbol. It is defined in the sme mnner tht we defined the prbol
More informationCS 321 Programming Languages and Compilers. Bottom Up Parsing
CS 321 Progrmming nguges nd Compilers Bottom Up Prsing Bottom-up Prsing: Shift-reduce prsing Grmmr H: fi ; fi b Input: ;;b hs prse tree ; ; b 2 Dt for Shift-reduce Prser Input string: sequence of tokens
More informationImproper Integrals. October 4, 2017
Improper Integrls October 4, 7 Introduction We hve seen how to clculte definite integrl when the it is rel number. However, there re times when we re interested to compute the integrl sy for emple 3. Here
More informationReference types and their characteristics Class Definition Constructors and Object Creation Special objects: Strings and Arrays
Objects nd Clsses Reference types nd their chrcteristics Clss Definition Constructors nd Object Cretion Specil objects: Strings nd Arrys OOAD 1999/2000 Cludi Niederée, Jochim W. Schmidt Softwre Systems
More informationTO REGULAR EXPRESSIONS
Suject :- Computer Science Course Nme :- Theory Of Computtion DA TO REGULAR EXPRESSIONS Report Sumitted y:- Ajy Singh Meen 07000505 jysmeen@cse.iit.c.in BASIC DEINITIONS DA:- A finite stte mchine where
More information