ITI Introduction to Computing II

Size: px
Start display at page:

Download "ITI Introduction to Computing II"

Transcription

1 ITI Intoduction to Computing II Macel Tucotte School of Electical Engineeing and Compute Science Abstact data type: Stack Stack-based algoithms Vesion of Febuay 2, 2013 Abstact These lectue notes ae meant to be looked at on a compute sceen. Do not pint them unless it is necessay.

2 Evaluating aithmetic expessions Stack-based algoithms ae used fo syntactical analysis (pasing).

3 Evaluating aithmetic expessions Stack-based algoithms ae used fo syntactical analysis (pasing). Fo example to evaluate the following expession:

4 Evaluating aithmetic expessions Stack-based algoithms ae used fo syntactical analysis (pasing). Fo example to evaluate the following expession: Compiles use simila algoithms to check the syntax of you pogams and geneate machine instuctions (executable). To veify that paentheses ae balanced: ([]) is ok, but not ([)] o )((())(.

5 The fist two steps of the analysis of a souce pogam by a compile ae the lexical analysis and the syntactical analysis.

6 The fist two steps of the analysis of a souce pogam by a compile ae the lexical analysis and the syntactical analysis. Duing the lexical analysis (scanning) the souce code is ead fom left to ight and the chaactes ae egouped into tokens, which ae successive chaactes that constitute numbes o identifies. One of the tasks of the lexical analyse is to emove spaces fom the input. E.g.: whee epesent blank spaces, is tansfomed into the following list of tokens: [10,+,2,+,300]

7 The next step is the syntactical analysis (pasing) and consists in egouping the tokens into gammatical units, fo example the sub-expessions of RPN expessions (seen in class this week). In the next slides, we look at simple examples of lexical and syntactical analysis.

8 public class Test { public static void scan( Sting expession ) { Reade eade = new Reade( expession ); } while ( eade.hasmoetokens() ) { System.out.pintln( eade.nexttoken() ); } public static void main( Sting[] ags ) { scan( " * 567 " ); } } // > java Test // INTEGER: 3 // SYMBOL: + // INTEGER: 4 // SYMBOL: * // INTEGER: 567

9 public class Token { pivate static final int INTEGER = 1; pivate static final int SYMBOL = 2; pivate int ivalue; pivate Sting svalue; pivate int type; public Token( int ivalue ) { this.ivalue = ivalue; type = INTEGER; } public Token( Sting svalue ) { this.svalue = svalue; type = SYMBOL; } public int ivalue() {... } public Sting svalue() {... } } public boolean isintege() { etun type == INTEGER; } public boolean issymbol() { etun type == SYMBOL; }

10 LR Scan public static int execute( Sting expession ) { Token op = null; int l = 0, = 0; Reade eade = new Reade( expession ); l = eade.nexttoken().ivalue(); } while ( eade.hasmoetokens() ) { op = eade.nexttoken(); = eade.nexttoken().ivalue(); l = eval( op, l, ); } etun l;

11 eval( Token op, int l, int ) public static int eval( Token op, int l, int ) { int esult = 0; if ( op.svalue().equals( "+" ) ) esult = l + ; else if ( op.svalue().equals( "-" ) ) esult = l - ; else if ( op.svalue().equals( "*" ) ) esult = l * ; else if ( op.svalue().equals( "/" ) ) esult = l / ; else System.e.pintln( "not a valid symbol" ); } etun esult;

12 Evaluating an aithmetic expession: LR Scan Left-to-ight algoithm: Declae L, R and OP Read L While not end-of-expession do: Read OP Read R Evaluate L OP R Stoe esult in L At the end of the loop the esult can be found in L.

13 3 * 8-10

14 ^ L = 3 OP = R = > Read L While not end-of-expession do: Read OP Read R Evaluate L OP R Stoe esult in L

15 ^ L = 3 OP = + R = Read L While not end-of-expession do: > Read OP Read R Evaluate L OP R Stoe esult in L

16 ^ L = 3 OP = + R = 4 Read L While not end-of-expession do: Read OP > Read R Evaluate L OP R Stoe esult in L

17 ^ L = 3 OP = + R = 4 Read L While not end-of-expession do: Read OP Read R > Evaluate L OP R (7) Stoe esult in L

18 ^ L = 7 OP = + R = 4 Read L While not end-of-expession do: Read OP Read R Evaluate L OP R > Stoe esult in L

19 ^ L = 7 OP = - R = 4 Read L While not end-of-expession do: > Read OP Read R Evaluate L OP R Stoe esult in L

20 ^ L = 7 OP = - R = 5 Read L While not end-of-expession do: Read OP > Read R Evaluate L OP R Stoe esult in L

21 ^ L = 7 OP = - R = 5 Read L While not end-of-expession do: Read OP Read R > Evaluate L OP R (2) Stoe esult in L

22 ^ L = 2 OP = - R = 5 Read L While not end-of-expession do: Read OP Read R Evaluate L OP R > Stoe esult in L

23 ^ L = 2 OP = - R = 5 > Read L While not end-of-expession do: Read OP Read R Evaluate L OP R Stoe esult in L end of expession, exit the loop, L contains the esult.

24 What do you think?

25 What do you think? Without paentheses the following expession cannot be evaluated coectly: 7 - (3-2)

26 What do you think? Without paentheses the following expession cannot be evaluated coectly: 7 - (3-2) Because the esult of the left-to-ight analysis coesponds to: (7-3) - 2

27 What do you think? Without paentheses the following expession cannot be evaluated coectly: 7 - (3-2) Because the esult of the left-to-ight analysis coesponds to: (7-3) - 2 Similaly the following expession cannot be evaluated by ou simple algoithm: 7-3 * 2

28 What do you think? Without paentheses the following expession cannot be evaluated coectly: 7 - (3-2) Because the esult of the left-to-ight analysis coesponds to: (7-3) - 2 Similaly the following expession cannot be evaluated by ou simple algoithm: 7-3 * 2 Since the left-to-ight analysis coesponds to: (7-3) * 2

29 What do you think? Without paentheses the following expession cannot be evaluated coectly: 7 - (3-2) Because the esult of the left-to-ight analysis coesponds to: (7-3) - 2 Similaly the following expession cannot be evaluated by ou simple algoithm: 7-3 * 2 Since the left-to-ight analysis coesponds to: (7-3) * 2 But accoding to the opeato pecedences, the evaluation should have poceeded as follows: 7 - (3 * 2)

30 Remaks The left-to-ight algoithm: Does not handle paentheses; No pecedence.

31 Remaks The left-to-ight algoithm: Does not handle paentheses; No pecedence. Solutions:

32 Remaks The left-to-ight algoithm: Does not handle paentheses; No pecedence. Solutions: 1. Use a diffeent notation; 2. Develop moe complex algoithms.

33 Remaks The left-to-ight algoithm: Does not handle paentheses; No pecedence. Solutions: 1. Use a diffeent notation; 2. Develop moe complex algoithms. Both solutions involve stacks!

34 Notations Thee ae 3 ways to epesent the following expession: L OP R.

35 Notations Thee ae 3 ways to epesent the following expession: L OP R. infix: this is the usual notation, the opeato is sandwiched in between its opeands: L OP R;

36 Notations Thee ae 3 ways to epesent the following expession: L OP R. infix: this is the usual notation, the opeato is sandwiched in between its opeands: L OP R; postfix: in postfix notation, the opeands ae placed befoe the opeato, L R OP. This notation is also called Revese Polish Notation o RPN, it s the notation used by cetain scientific calculatos (such as the HP-35 fom Hewlett-Packad o the Texas Instuments TI-89 using the RPN Inteface by Las Fedeiksen 1 ) o PostScipt pogamming language. 7 - (3-2) = (7-3) - 2 =

37 Notations Thee ae 3 ways to epesent the following expession: L OP R. infix: this is the usual notation, the opeato is sandwiched in between its opeands: L OP R; postfix: in postfix notation, the opeands ae placed befoe the opeato, L R OP. This notation is also called Revese Polish Notation o RPN, it s the notation used by cetain scientific calculatos (such as the HP-35 fom Hewlett-Packad o the Texas Instuments TI-89 using the RPN Inteface by Las Fedeiksen 1 ) o PostScipt pogamming language. 7 - (3-2) = (7-3) - 2 = pefix: the thid notation consists in placing the opeato befoe the opeands, OP L R. The pogamming language Lisp uses a combination of paentheses and pefix notation: (- 7 (* 3 2)).

38 Notations Thee ae 3 ways to epesent the following expession: L OP R. infix: this is the usual notation, the opeato is sandwiched in between its opeands: L OP R; postfix: in postfix notation, the opeands ae placed befoe the opeato, L R OP. This notation is also called Revese Polish Notation o RPN, it s the notation used by cetain scientific calculatos (such as the HP-35 fom Hewlett-Packad o the Texas Instuments TI-89 using the RPN Inteface by Las Fedeiksen 1 ) o PostScipt pogamming language. 7 - (3-2) = (7-3) - 2 = pefix: the thid notation consists in placing the opeato befoe the opeands, OP L R. The pogamming language Lisp uses a combination of paentheses and pefix notation: (- 7 (* 3 2)). 1

39 Infix postfix (mentally) Successively tansfom, one by one, all the sub-expessions following the same ode of evaluation that you would nomally follow to evaluate an infix expession.

40 Infix postfix (mentally) Successively tansfom, one by one, all the sub-expessions following the same ode of evaluation that you would nomally follow to evaluate an infix expession. An infix expession l becomes l, whee l and ae sub-expessions and is an opeato.

41 9 / ( )

42 9 / ( ) 9 / ( 2 }{{} l }{{} 4 }{{} 5 )

43 9 / ( ) 9 / ( 2 }{{} l 9 / ( l {}}{ 2 }{{} {}}{ 4 4 }{{} 5 ) {}}{ 5 )

44 9 / ( ) 9 / ( 2 }{{} l 9 / ( l {}}{ 2 }{{} {}}{ 4 4 }{{} 5 ) {}}{ 5 ) 9 / ( [ 2 4 ] 5 )

45 9 / ( ) 9 / ( 2 }{{} l 9 / ( l {}}{ 2 }{{} {}}{ 4 4 }{{} 5 ) {}}{ 5 ) 9 / ( [ 2 4 ] 5 ) 9 / ( [ 2 4 ] }{{} l }{{} 5 }{{} )

46 9 / ( ) 9 / ( 2 }{{} l 9 / ( l {}}{ 2 }{{} {}}{ 4 4 }{{} 5 ) {}}{ 5 ) 9 / ( [ 2 4 ] 5 ) 9 / ( [ 2 4 ] }{{} l l {}}{ 9 / [ [ 2 4 ] }{{} {}}{ 5 5 }{{} ) {}}{ ]

47 9 / ( ) 9 / ( 2 }{{} l 9 / ( l {}}{ 2 }{{} {}}{ 4 4 }{{} 5 ) {}}{ 5 ) 9 / ( [ 2 4 ] 5 ) 9 / ( [ 2 4 ] }{{} l l {}}{ 9 / [ [ 2 4 ] }{{} {}}{ 5 9 / [ ] 5 }{{} ) {}}{ ]

48 9 / ( ) 9 / ( 2 }{{} l 9 / ( l {}}{ 2 }{{} {}}{ 4 4 }{{} 5 ) {}}{ 5 ) 9 / ( [ 2 4 ] 5 ) 9 / ( [ 2 4 ] }{{} l l {}}{ 9 / [ [ 2 4 ] 9 }{{} l }{{} {}}{ 5 9 / [ ] / }{{} 5 }{{} ) {}}{ ] [ ] }{{}

49 9 / ( ) 9 / ( 2 }{{} l 9 / ( l {}}{ 2 }{{} {}}{ 4 4 }{{} 5 ) {}}{ 5 ) 9 / ( [ 2 4 ] 5 ) 9 / ( [ 2 4 ] }{{} l l {}}{ 9 / [ [ 2 4 ] 9 }{{} l l {}}{ 9 }{{} {}}{ 5 9 / [ ] / }{{} 5 }{{} ) {}}{ ] [ ] }{{} {}}{ [ ] {}}{ /

50 9 / ( ) 9 / ( 2 }{{} l 9 / ( l {}}{ 2 }{{} {}}{ 4 4 }{{} 5 ) {}}{ 5 ) 9 / ( [ 2 4 ] 5 ) 9 / ( [ 2 4 ] }{{} l l {}}{ 9 / [ [ 2 4 ] 9 }{{} l l {}}{ 9 }{{} {}}{ 5 9 / [ ] / }{{} 5 }{{} ) {}}{ ] [ ] }{{} {}}{ [ ] / {}}{ /

51 Evaluating a postfix expession (mentally) Scan the expession fom left to ight. When the cuent element is an opeato, apply the opeato to its opeands, i.e. eplace l by the esult of the evaluation of l /

52 Evaluating a postfix expession (mentally) Scan the expession fom left to ight. When the cuent element is an opeato, apply the opeato to its opeands, i.e. eplace l by the esult of the evaluation of l / 9 2 }{{} l 4 }{{} }{{} 5 /

53 Evaluating a postfix expession (mentally) Scan the expession fom left to ight. When the cuent element is an opeato, apply the opeato to its opeands, i.e. eplace l by the esult of the evaluation of l / 9 2 }{{} l 9 4 }{{} }{{} l {}}{ 8 5 / 5 /

54 Evaluating a postfix expession (mentally) Scan the expession fom left to ight. When the cuent element is an opeato, apply the opeato to its opeands, i.e. eplace l by the esult of the evaluation of l. 9 2 }{{} l / 9 9 }{{} 8 l }{{} 4 l {}}{ }{{} 8 5 / }{{} 5 }{{} 5 / /

55 Evaluating a postfix expession (mentally) Scan the expession fom left to ight. When the cuent element is an opeato, apply the opeato to its opeands, i.e. eplace l by the esult of the evaluation of l. 9 2 }{{} l / 9 9 }{{} 8 l }{{} 4 l {}}{ 9 }{{} 8 5 / }{{} 5 }{{} l {}}{ 3 / 5 / /

56 Evaluating a postfix expession (mentally) Scan the expession fom left to ight. When the cuent element is an opeato, apply the opeato to its opeands, i.e. eplace l by the esult of the evaluation of l. 9 2 }{{} l / 9 9 }{{} 8 l 9 }{{} 9 l }{{} 4 l {}}{ }{{} 8 5 / }{{} 5 }{{} l {}}{ 3 / 3 }{{} / }{{} 5 / /

57 Evaluating a postfix expession (mentally) Scan the expession fom left to ight. When the cuent element is an opeato, apply the opeato to its opeands, i.e. eplace l by the esult of the evaluation of l. 9 2 }{{} l / 9 9 }{{} 8 l 9 }{{} 9 l }{{} 4 l {}}{ }{{} 8 5 / }{{} 5 }{{} l {}}{ 3 / 3 }{{} l {}}{ 3 / }{{} 5 / /

58 Evaluating a postfix expession Until the end of the expession has been eached: 1. Fom left to ight until the fist opeato; 2. Apply the opeato to the two peceding opeands; 3. Replace the opeato and its opeands by the esult. At the end we have esult.

59 9 3 / * - +

60 9 2 4 * 5 - /

61 Remaks: infix vs postfix The ode of the opeands is the same fo both notations, howeve opeatos ae inseted at diffeent places: 2 + (3 * 4) = * + (2 + 3) * 4 = *

62 Remaks: infix vs postfix The ode of the opeands is the same fo both notations, howeve opeatos ae inseted at diffeent places: 2 + (3 * 4) = * + (2 + 3) * 4 = * Evaluating an infix expession involves handling opeatos pecedence and paenthesis in the case of the postfix notation, those two concepts ae embedded in the expession, i.e. the ode of the opeands and opeatos.

63 What ole will the stack be playing? Algoithm: Eval Infix

64 What ole will the stack be playing? opeands = new stack; Algoithm: Eval Infix while ( "has moe tokens" ) { t = next token; if ( "t is an opeand" ) { opeands.push( "the intege value of t" ); } else { // this is an opeato op = "opeato value of t"; = opeands.pop(); l = opeands.pop(); opeands.push( "eval( l, op, )" ); } } etun opeands.pop();

65 Evaluating a postfix expession The algoithm equies a stack (Numbes), a vaiable that contains the last element that was ead (X) and two moe vaiables, L and R, whose pupose is the same as befoe. Numbes = [ While not end-of-expession do: Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes (ight befoe left?!) L = POP Numbes Evaluate L X R; PUSH esult onto Numbes To obtain the final esult: POP Numbes.

66 9 3-2 /

67 9 3 / * - +

68 9 / ((2 * 4) - 5) = * 5 - / ^ > Numbes = [ X = L = R = While not end-of-expession do: Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Ceate a new stack

69 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [ X = 9 L = R = While not end-of-expession do: > Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Read X

70 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 X = 9 L = R = While not end-of-expession do: Read X > If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Push X

71 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 X = 2 L = R = While not end-of-expession do: > Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Read X

72 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 2 X = 2 L = R = While not end-of-expession do: Read X > If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Push X

73 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 2 X = 4 L = R = While not end-of-expession do: > Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Read X

74 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 2 4 X = 4 L = R = While not end-of-expession do: Read X > If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Push X

75 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 2 4 X = * L = R = While not end-of-expession do: > Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Read X

76 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 2 X = * L = R = 4 While not end-of-expession do: Read X If X isnumbe, PUSH X onto Numbes If X isopeato, > R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Ah! X is an opeato, pop the top element save into R

77 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 X = * L = 2 R = 4 While not end-of-expession do: Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes > L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Top element is emoved and saved into L

78 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 8 X = * L = 2 R = 4 While not end-of-expession do: Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes > Evaluate L X R; PUSH esult onto Numbes Push the esult of L X R, 2 4 = 8, onto the stack

79 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 8 X = 5 L = 2 R = 4 While not end-of-expession do: > Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Read X

80 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 8 5 X = 5 L = 2 R = 4 While not end-of-expession do: Read X > If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Push X

81 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 8 5 X = - L = 2 R = 4 While not end-of-expession do: > Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Read X

82 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 8 X = - L = 2 R = 5 While not end-of-expession do: Read X If X isnumbe, PUSH X onto Numbes If X isopeato, > R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Remove the top element and save it into R

83 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 X = - L = 8 R = 5 While not end-of-expession do: Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes > L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Remove the top element and save it into L

84 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 3 X = - L = 8 R = 5 While not end-of-expession do: Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes > Evaluate L X R; PUSH esult onto Numbes Push the esult of L X R, 8 5 = 3, onto the stack

85 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 3 X = / L = 8 R = 5 While not end-of-expession do: > Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes Read X

86 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [9 X = / L = 8 R = 3 While not end-of-expession do: Read X If X isnumbe, PUSH X onto Numbes If X isopeato, > R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes R = POP Numbes.

87 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [ X = / L = 9 R = 3 While not end-of-expession do: Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes > L = POP Numbes Evaluate L X R; PUSH esult onto Numbes L = POP Numbes.

88 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [3 X = / L = 9 R = 3 While not end-of-expession do: Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes > Evaluate L X R; PUSH esult onto Numbes Push L X R, 9 3 = 3, onto the stack su la pile.

89 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [3 X = / L = 9 R = 3 While not end-of-expession do: Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes > Evaluate L X R; PUSH esult onto Numbes End-of-expession

90 9 / ((2 * 4) - 5) = * 5 - / ^ Numbes = [ X = / L = 9 R = 3 > While not end-of-expession do: Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes Evaluate L X R; PUSH esult onto Numbes The esult is POP Numbes = 3 ; the stack is now empty

91 Poblem Rathe than evaluating an RPN expession, we would like to convet an RPN expession to infix (usual notation).

92 Poblem Rathe than evaluating an RPN expession, we would like to convet an RPN expession to infix (usual notation). Hum?

93 Poblem Rathe than evaluating an RPN expession, we would like to convet an RPN expession to infix (usual notation). Hum? Do we need a new algoithm?

94 Poblem Rathe than evaluating an RPN expession, we would like to convet an RPN expession to infix (usual notation). Hum? Do we need a new algoithm? No, a simple modification will do, eplace Evaluate L OP R by Concatenate (L OP R). Note: paentheses ae essential (not all of them but some ae). This time the stack does not contain numbes but chaacte stings that epesent sub-expessions.

95 / - /

96 Postfix infix Sting pntoinfix(sting[] tokens) Numbes = [ X = L = R = While not end-of-expession do: Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes Concatenate ( L X R ); PUSH esult onto Numbes

97 Postfix? While not end-of-expession do: Read X If X isnumbe, PUSH X onto Numbes If X isopeato, R = POP Numbes L = POP Numbes Pocess L X R; PUSH esult onto Numbes We ve seen an example whee Pocess == Evaluate, then one whee Pocess == Concatenate, but Pocess could also poduce assembly code (i.e. machine instuctions). This shows how pogams ae compiled o tanslated.

98 Memoy management heap (instances) fee basept Stack fo method calls Vaiables static pogam (byte code) Java Vitual Machine Method n activation ecod... Method 2 activation ecod Method 1 (main) activation ecod Pogam counte Local vaiables Paametes Retun addess Pevious basept Retun value Schematic and simplified epesentation of the memoy duing the execution of a Java pogam.

99 The Java Vitual Machine (JVM) must: Method call

100 The Java Vitual Machine (JVM) must: Method call 1. Ceate a new activation ecod/block (which contains space fo the local vaiables and the paametes among othe things);

101 The Java Vitual Machine (JVM) must: Method call 1. Ceate a new activation ecod/block (which contains space fo the local vaiables and the paametes among othe things); 2. Save the cuent value of basept in the activation ecod and set the basept to the addess of the cuent ecod;

102 The Java Vitual Machine (JVM) must: Method call 1. Ceate a new activation ecod/block (which contains space fo the local vaiables and the paametes among othe things); 2. Save the cuent value of basept in the activation ecod and set the basept to the addess of the cuent ecod; 3. Save the value of the pogam counte in the designated space of the activation ecod, set the pogam counte to the fist instuction of the cuent method;

103 The Java Vitual Machine (JVM) must: Method call 1. Ceate a new activation ecod/block (which contains space fo the local vaiables and the paametes among othe things); 2. Save the cuent value of basept in the activation ecod and set the basept to the addess of the cuent ecod; 3. Save the value of the pogam counte in the designated space of the activation ecod, set the pogam counte to the fist instuction of the cuent method; 4. Copy the values of the effective paametes into the designated aea of the cuent activation ecod;

104 The Java Vitual Machine (JVM) must: Method call 1. Ceate a new activation ecod/block (which contains space fo the local vaiables and the paametes among othe things); 2. Save the cuent value of basept in the activation ecod and set the basept to the addess of the cuent ecod; 3. Save the value of the pogam counte in the designated space of the activation ecod, set the pogam counte to the fist instuction of the cuent method; 4. Copy the values of the effective paametes into the designated aea of the cuent activation ecod; 5. Initial the local vaiables;

105 The Java Vitual Machine (JVM) must: Method call 1. Ceate a new activation ecod/block (which contains space fo the local vaiables and the paametes among othe things); 2. Save the cuent value of basept in the activation ecod and set the basept to the addess of the cuent ecod; 3. Save the value of the pogam counte in the designated space of the activation ecod, set the pogam counte to the fist instuction of the cuent method; 4. Copy the values of the effective paametes into the designated aea of the cuent activation ecod; 5. Initial the local vaiables; 6. Stat executing the instuction designated by the pogam counte.

106 The Java Vitual Machine (JVM) must: Method call 1. Ceate a new activation ecod/block (which contains space fo the local vaiables and the paametes among othe things); 2. Save the cuent value of basept in the activation ecod and set the basept to the addess of the cuent ecod; 3. Save the value of the pogam counte in the designated space of the activation ecod, set the pogam counte to the fist instuction of the cuent method; 4. Copy the values of the effective paametes into the designated aea of the cuent activation ecod; 5. Initial the local vaiables; 6. Stat executing the instuction designated by the pogam counte. activation block = stack fame, call fame o activation ecod.

107 The JVM must: When the method ends

108 When the method ends The JVM must: 1. Save the etun value (at the designated space)

109 When the method ends The JVM must: 1. Save the etun value (at the designated space) 2. Retun the contol to the calling method, i.e. set the pogam counte and basept back to thei pevious value;

110 When the method ends The JVM must: 1. Save the etun value (at the designated space) 2. Retun the contol to the calling method, i.e. set the pogam counte and basept back to thei pevious value; 3. Remove the cuent block;

111 When the method ends The JVM must: 1. Save the etun value (at the designated space) 2. Retun the contol to the calling method, i.e. set the pogam counte and basept back to thei pevious value; 3. Remove the cuent block; 4. Execute instuction designated by the cuent value of the pogam counte.

112 Example 1 (simplified) public class Calls { public static int c( int v ) { int n; n = v + 1; etun n; } public static int b( int v ) { int m,n; m = v + 1; n = c( m ); etun n; } public static int a( int v ) { int m,n; m = v + 1; n = b( m ); etun n; }

113 } public static void main( Sting[] ags ) { int m,n; m = 1; n = a( m ); System.out.pintln( n ); }

114 Example 1 (simplified) a: main: v m n ags m n 1 1 a(1)

115 Example 1 (simplified) b: a: main: v m n v m n ags m n b(2) a(1)

116 Example 1 (simplified) c: v n 3 c(3) b: v m 2 3 n b(2) a: v 1 m n 2 a(1) main: ags m 1 n

117 Example 1 (simplified) 4 c(3) b: a: main: v m n v m n ags m n b(2) a(1)

118 Example 1 (simplified) 4 b(2) a: v m n a(1) main: ags m n 1

119 Example 1 (simplified) 4 a(1) main: ags m n 1 4

120 Example 1: summay c: 4 v n 3 4 c(3) b: 4 v m n b(2) a: 4 v m n a(1) main: ags m n 1 4

121 Example 2 (with a pogam counte) 01 public class Fact { 02 public static int fact( int n ) { 03 // pe-condition: n >= 0 04 int a, ; 05 if ( n == 0 n == 1 ) { 06 a = 1; 07 } else { 08 = fact( n-1 ); 09 a = n * ; 10 } 11 etun a; 12 } 13 public static void main( Sting[] ags ) { 14 int a, n; 15 n = 3; 16 a = fact( n ); 17 } 18}

122 main ags n a pogam counte 15

123 main ags n 3 a pogam counte 16

124 fact n a etun addess main ags n 3 a fact( 3 ) pogam counte 16

125 fact n 3 a etun addess main ags n 3 a fact( 3 ) pogam counte 16

126 fact n 3 a etun addess 16 main ags n 3 a fact( 3 ) pogam counte 16

127 fact n 3 a etun addess 16 main ags n 3 a fact( 3 ) pogam counte 5

128 fact n 3 a etun addess 16 main ags n 3 a fact( 3 ) pogam counte 8

129 fact n a etun addess fact n 3 a etun addess 16 main ags n 3 a fact( 2 ) fact( 3 ) pogam counte 8

130 fact n 2 a etun addess fact n 3 a etun addess 16 main ags n 3 a fact( 2 ) fact( 3 ) pogam counte 8

131 fact n 2 a etun addess 8 fact n 3 a etun addess 16 main ags n 3 a fact( 2 ) fact( 3 ) pogam counte 8

132 fact n 2 a etun addess 8 fact n 3 a etun addess 16 main ags n 3 a fact( 2 ) fact( 3 ) pogam counte 5

133 fact n 2 a etun addess 8 fact n 3 a etun addess 16 main ags n 3 a fact( 2 ) fact( 3 ) pogam counte 8

134 fact n a etun addess fact n 2 a etun addess 8 fact n 3 a etun addess 16 main ags n 3 a fact( 1 ) fact( 2 ) fact( 3 ) pogam counte 8

135 fact n 1 a etun addess fact n 2 a etun addess 8 fact n 3 a etun addess 16 main ags n 3 a fact( 1 ) fact( 2 ) fact( 3 ) pogam counte 8

136 fact n 1 a etun addess 8 fact n 2 a etun addess 8 fact n 3 a etun addess 16 main ags n 3 a fact( 1 ) fact( 2 ) fact( 3 ) pogam counte 8

137 fact n 1 a etun addess 8 fact n 2 a etun addess 8 fact n 3 a etun addess 16 main ags n 3 a fact( 1 ) fact( 2 ) fact( 3 ) pogam counte 5

138 fact n 1 a etun addess 8 fact n 2 a etun addess 8 fact n 3 a etun addess 16 main ags n 3 a fact( 1 ) fact( 2 ) fact( 3 ) pogam counte 6

139 fact n 1 a 1 etun addess 8 fact n 2 a etun addess 8 fact n 3 a etun addess 16 main ags n 3 a fact( 1 ) fact( 2 ) fact( 3 ) pogam counte 11

140 fact n 1 a 1 etun addess 8 1 fact n 2 a etun addess 8 fact n 3 a etun addess 16 main ags n 3 a fact( 1 ) fact( 2 ) fact( 3 ) pogam counte 11

141 fact n 1 a 1 etun addess 8 1 fact n 2 a etun addess 8 fact n 3 a etun addess 16 main ags n 3 a fact( 1 ) fact( 2 ) fact( 3 ) pogam counte 8

142 1 fact n 2 a etun addess 8 fact n 3 a etun addess 16 main ags n 3 a fact( 2 ) fact( 3 ) pogam counte 8

143 1 fact n 2 a 1 etun addess 8 fact n 3 a etun addess 16 main ags n 3 a fact( 2 ) fact( 3 ) pogam counte 9

144 1 fact n 2 a 2 1 etun addess 8 fact n 3 a etun addess 16 main ags n 3 a fact( 2 ) fact( 3 ) pogam counte 11

145 1 fact n 2 a 2 1 etun addess 8 2 fact n 3 a etun addess 16 main ags n 3 a fact( 2 ) fact( 3 ) pogam counte 11

146 1 fact n 2 a 2 1 etun addess 8 2 fact n 3 a etun addess 16 main ags n 3 a fact( 2 ) fact( 3 ) pogam counte 8

147 2 fact n 3 a etun addess 16 main ags n 3 a fact( 3 ) pogam counte 8

148 2 fact n a 3 2 etun addess 16 main ags n 3 a fact( 3 ) pogam counte 9

149 2 fact n 3 a 6 2 etun addess 16 main ags n 3 a fact( 3 ) pogam counte 11

150 2 fact n 3 a 6 2 etun addess 16 6 main ags n 3 a fact( 3 ) pogam counte 11

151 2 fact n 3 a 6 2 etun addess 16 6 main ags n 3 a fact( 3 ) pogam counte 16

152 main 6 ags n 3 a pogam counte 16

153 main 6 ags n 3 a 6 pogam counte 17

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Intoduction to Computing II Mcel Tucotte School of Electicl Engineeing nd Compute Science Abstct dt type: Stck Stck-bsed lgoithms Vesion of Febuy 2, 2013 Abstct These lectue notes e ment to be

More information

Pushdown Automata (PDAs)

Pushdown Automata (PDAs) CHAPTER 2 Context-Fee Languages Contents Context-Fee Gammas definitions, examples, designing, ambiguity, Chomsky nomal fom Pushdown Automata definitions, examples, euivalence with context-fee gammas Non-Context-Fee

More information

A Bijective Approach to the Permutational Power of a Priority Queue

A Bijective Approach to the Permutational Power of a Priority Queue A Bijective Appoach to the Pemutational Powe of a Pioity Queue Ia M. Gessel Kuang-Yeh Wang Depatment of Mathematics Bandeis Univesity Waltham, MA 02254-9110 Abstact A pioity queue tansfoms an input pemutation

More information

HOW TO TEACH THE FUNDAMENTALS OF INFORMATION SCIENCE, CODING, DECODING AND NUMBER SYSTEMS?

HOW TO TEACH THE FUNDAMENTALS OF INFORMATION SCIENCE, CODING, DECODING AND NUMBER SYSTEMS? 6th INTERNATIONAL MULTIDISCIPLINARY CONFERENCE HOW TO TEACH THE FUNDAMENTALS OF INFORMATION SCIENCE, CODING, DECODING AND NUMBER SYSTEMS? Cecília Sitkuné Göömbei College of Nyíegyháza Hungay Abstact: The

More information

Rigid Body Dynamics 2. CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2018

Rigid Body Dynamics 2. CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2018 Rigid Body Dynamics 2 CSE169: Compute Animation nstucto: Steve Rotenbeg UCSD, Winte 2018 Coss Poduct & Hat Opeato Deivative of a Rotating Vecto Let s say that vecto is otating aound the oigin, maintaining

More information

VECTOR MECHANICS FOR ENGINEERS: STATICS

VECTOR MECHANICS FOR ENGINEERS: STATICS 4 Equilibium CHAPTER VECTOR MECHANICS FOR ENGINEERS: STATICS Fedinand P. Bee E. Russell Johnston, J. of Rigid Bodies Lectue Notes: J. Walt Ole Texas Tech Univesity Contents Intoduction Fee-Body Diagam

More information

ASTR415: Problem Set #6

ASTR415: Problem Set #6 ASTR45: Poblem Set #6 Cuan D. Muhlbege Univesity of Mayland (Dated: May 7, 27) Using existing implementations of the leapfog and Runge-Kutta methods fo solving coupled odinay diffeential equations, seveal

More information

Physics 2A Chapter 10 - Moment of Inertia Fall 2018

Physics 2A Chapter 10 - Moment of Inertia Fall 2018 Physics Chapte 0 - oment of netia Fall 08 The moment of inetia of a otating object is a measue of its otational inetia in the same way that the mass of an object is a measue of its inetia fo linea motion.

More information

Physics 211: Newton s Second Law

Physics 211: Newton s Second Law Physics 211: Newton s Second Law Reading Assignment: Chapte 5, Sections 5-9 Chapte 6, Section 2-3 Si Isaac Newton Bon: Januay 4, 1643 Died: Mach 31, 1727 Intoduction: Kinematics is the study of how objects

More information

ON THE TWO-BODY PROBLEM IN QUANTUM MECHANICS

ON THE TWO-BODY PROBLEM IN QUANTUM MECHANICS ON THE TWO-BODY PROBLEM IN QUANTUM MECHANICS L. MICU Hoia Hulubei National Institute fo Physics and Nuclea Engineeing, P.O. Box MG-6, RO-0775 Buchaest-Maguele, Romania, E-mail: lmicu@theoy.nipne.o (Received

More information

New problems in universal algebraic geometry illustrated by boolean equations

New problems in universal algebraic geometry illustrated by boolean equations New poblems in univesal algebaic geomety illustated by boolean equations axiv:1611.00152v2 [math.ra] 25 Nov 2016 Atem N. Shevlyakov Novembe 28, 2016 Abstact We discuss new poblems in univesal algebaic

More information

Probablistically Checkable Proofs

Probablistically Checkable Proofs Lectue 12 Pobablistically Checkable Poofs May 13, 2004 Lectue: Paul Beame Notes: Chis Re 12.1 Pobablisitically Checkable Poofs Oveview We know that IP = PSPACE. This means thee is an inteactive potocol

More information

Markscheme May 2017 Calculus Higher level Paper 3

Markscheme May 2017 Calculus Higher level Paper 3 M7/5/MATHL/HP3/ENG/TZ0/SE/M Makscheme May 07 Calculus Highe level Pape 3 pages M7/5/MATHL/HP3/ENG/TZ0/SE/M This makscheme is the popety of the Intenational Baccalaueate and must not be epoduced o distibuted

More information

COMP303 Computer Architecture Lecture 11. An Overview of Pipelining

COMP303 Computer Architecture Lecture 11. An Overview of Pipelining COMP303 Compute Achitectue Lectue 11 An Oveview of Pipelining Pipelining Pipelining povides a method fo executing multiple instuctions at the same time. Laundy Example: Ann, Bian, Cathy, Dave each have

More information

On the integration of the equations of hydrodynamics

On the integration of the equations of hydrodynamics Uebe die Integation de hydodynamischen Gleichungen J f eine u angew Math 56 (859) -0 On the integation of the equations of hydodynamics (By A Clebsch at Calsuhe) Tanslated by D H Delphenich In a pevious

More information

Current Balance Warm Up

Current Balance Warm Up PHYSICS EXPERIMENTS 133 Cuent Balance-1 Cuent Balance Wam Up 1. Foce between cuent-caying wies Wie 1 has a length L (whee L is "long") and caies a cuent I 0. What is the magnitude of the magnetic field

More information

15.081J/6.251J Introduction to Mathematical Programming. Lecture 6: The Simplex Method II

15.081J/6.251J Introduction to Mathematical Programming. Lecture 6: The Simplex Method II 15081J/6251J Intoduction to Mathematical Pogamming ectue 6: The Simplex Method II 1 Outline Revised Simplex method Slide 1 The full tableau implementation Anticycling 2 Revised Simplex Initial data: A,

More information

Conservative Averaging Method and its Application for One Heat Conduction Problem

Conservative Averaging Method and its Application for One Heat Conduction Problem Poceedings of the 4th WSEAS Int. Conf. on HEAT TRANSFER THERMAL ENGINEERING and ENVIRONMENT Elounda Geece August - 6 (pp6-) Consevative Aveaging Method and its Application fo One Heat Conduction Poblem

More information

Particle Systems. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Particle Systems. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Paticle Systems Univesity of Texas at Austin CS384G - Compute Gaphics Fall 2010 Don Fussell Reading Requied: Witkin, Paticle System Dynamics, SIGGRAPH 97 couse notes on Physically Based Modeling. Witkin

More information

9.1 POLAR COORDINATES

9.1 POLAR COORDINATES 9. Pola Coodinates Contempoay Calculus 9. POLAR COORDINATES The ectangula coodinate system is immensely useful, but it is not the only way to assign an addess to a point in the plane and sometimes it is

More information

Chapter 3: Theory of Modular Arithmetic 38

Chapter 3: Theory of Modular Arithmetic 38 Chapte 3: Theoy of Modula Aithmetic 38 Section D Chinese Remainde Theoem By the end of this section you will be able to pove the Chinese Remainde Theoem apply this theoem to solve simultaneous linea conguences

More information

Force between two parallel current wires and Newton s. third law

Force between two parallel current wires and Newton s. third law Foce between two paallel cuent wies and Newton s thid law Yannan Yang (Shanghai Jinjuan Infomation Science and Technology Co., Ltd.) Abstact: In this pape, the essence of the inteaction between two paallel

More information

Auchmuty High School Mathematics Department Advanced Higher Notes Teacher Version

Auchmuty High School Mathematics Department Advanced Higher Notes Teacher Version The Binomial Theoem Factoials Auchmuty High School Mathematics Depatment The calculations,, 6 etc. often appea in mathematics. They ae called factoials and have been given the notation n!. e.g. 6! 6!!!!!

More information

Lab #4: Newton s Second Law

Lab #4: Newton s Second Law Lab #4: Newton s Second Law Si Isaac Newton Reading Assignment: bon: Januay 4, 1643 Chapte 5 died: Mach 31, 1727 Chapte 9, Section 9-7 Intoduction: Potait of Isaac Newton by Si Godfey Knelle http://www.newton.cam.ac.uk/at/potait.html

More information

Macro Theory B. The Permanent Income Hypothesis

Macro Theory B. The Permanent Income Hypothesis Maco Theoy B The Pemanent Income Hypothesis Ofe Setty The Eitan Beglas School of Economics - Tel Aviv Univesity May 15, 2015 1 1 Motivation 1.1 An econometic check We want to build an empiical model with

More information

I. CONSTRUCTION OF THE GREEN S FUNCTION

I. CONSTRUCTION OF THE GREEN S FUNCTION I. CONSTRUCTION OF THE GREEN S FUNCTION The Helmohltz equation in 4 dimensions is 4 + k G 4 x, x = δ 4 x x. In this equation, G is the Geen s function and 4 efes to the dimensionality. In the vey end,

More information

FUSE Fusion Utility Sequence Estimator

FUSE Fusion Utility Sequence Estimator FUSE Fusion Utility Sequence Estimato Belu V. Dasaathy Dynetics, Inc. P. O. Box 5500 Huntsville, AL 3584-5500 belu.d@dynetics.com Sean D. Townsend Dynetics, Inc. P. O. Box 5500 Huntsville, AL 3584-5500

More information

The Substring Search Problem

The Substring Search Problem The Substing Seach Poblem One algoithm which is used in a vaiety of applications is the family of substing seach algoithms. These algoithms allow a use to detemine if, given two chaacte stings, one is

More information

Pulse Neutron Neutron (PNN) tool logging for porosity Some theoretical aspects

Pulse Neutron Neutron (PNN) tool logging for porosity Some theoretical aspects Pulse Neuton Neuton (PNN) tool logging fo poosity Some theoetical aspects Intoduction Pehaps the most citicism of Pulse Neuton Neuon (PNN) logging methods has been chage that PNN is to sensitive to the

More information

F-IF Logistic Growth Model, Abstract Version

F-IF Logistic Growth Model, Abstract Version F-IF Logistic Gowth Model, Abstact Vesion Alignments to Content Standads: F-IFB4 Task An impotant example of a model often used in biology o ecology to model population gowth is called the logistic gowth

More information

Quantum Fourier Transform

Quantum Fourier Transform Chapte 5 Quantum Fouie Tansfom Many poblems in physics and mathematics ae solved by tansfoming a poblem into some othe poblem with a known solution. Some notable examples ae Laplace tansfom, Legende tansfom,

More information

COMP Parallel Computing SMM (3) OpenMP Case Study: The Barnes-Hut N-body Algorithm

COMP Parallel Computing SMM (3) OpenMP Case Study: The Barnes-Hut N-body Algorithm COMP 633 - Paallel Computing Lectue 8 Septembe 14, 2017 SMM (3) OpenMP Case Study: The Banes-Hut N-body Algoithm Topics Case study: the Banes-Hut algoithm Study an impotant algoithm in scientific computing»

More information

Green s Identities and Green s Functions

Green s Identities and Green s Functions LECTURE 7 Geen s Identities and Geen s Functions Let us ecall The ivegence Theoem in n-dimensions Theoem 7 Let F : R n R n be a vecto field ove R n that is of class C on some closed, connected, simply

More information

To Feel a Force Chapter 7 Static equilibrium - torque and friction

To Feel a Force Chapter 7 Static equilibrium - torque and friction To eel a oce Chapte 7 Chapte 7: Static fiction, toque and static equilibium A. Review of foce vectos Between the eath and a small mass, gavitational foces of equal magnitude and opposite diection act on

More information

A DETAILED STUDY OF THE HIGH ORDER SERIAL RESONANT INVERTER FOR INDUCTION HEATING

A DETAILED STUDY OF THE HIGH ORDER SERIAL RESONANT INVERTER FOR INDUCTION HEATING ELECTRONICS 005 1 3 Septembe, Sozopol, BULGARIA A DETAILED STUDY OF THE HIGH ORDER SERIAL RESONANT INVERTER FOR INDUCTION HEATING Evgeniy Ivanov Popov, Liliya Ivanova Pindeva, Elisaveta Histova Mileva,

More information

As is natural, our Aerospace Structures will be described in a Euclidean three-dimensional space R 3.

As is natural, our Aerospace Structures will be described in a Euclidean three-dimensional space R 3. Appendix A Vecto Algeba As is natual, ou Aeospace Stuctues will be descibed in a Euclidean thee-dimensional space R 3. A.1 Vectos A vecto is used to epesent quantities that have both magnitude and diection.

More information

Section 8.2 Polar Coordinates

Section 8.2 Polar Coordinates Section 8. Pola Coodinates 467 Section 8. Pola Coodinates The coodinate system we ae most familia with is called the Catesian coodinate system, a ectangula plane divided into fou quadants by the hoizontal

More information

DonnishJournals

DonnishJournals DonnishJounals 041-1189 Donnish Jounal of Educational Reseach and Reviews. Vol 1(1) pp. 01-017 Novembe, 014. http:///dje Copyight 014 Donnish Jounals Oiginal Reseach Pape Vecto Analysis Using MAXIMA Savaş

More information

Using Laplace Transform to Evaluate Improper Integrals Chii-Huei Yu

Using Laplace Transform to Evaluate Improper Integrals Chii-Huei Yu Available at https://edupediapublicationsog/jounals Volume 3 Issue 4 Febuay 216 Using Laplace Tansfom to Evaluate Impope Integals Chii-Huei Yu Depatment of Infomation Technology, Nan Jeon Univesity of

More information

The Implementation of the Conditions for the Existence of the Most Specific Generalizations w.r.t. General EL-TBoxes

The Implementation of the Conditions for the Existence of the Most Specific Generalizations w.r.t. General EL-TBoxes The Implementation of the Conditions fo the Existence of the Most Specific Genealizations w..t. Geneal EL-TBoxes Adian Nuadiansyah Technische Univesität Desden Supevised by: Anni-Yasmin Tuhan Febuay 12,

More information

Why Professor Richard Feynman was upset solving the Laplace equation for spherical waves? Anzor A. Khelashvili a)

Why Professor Richard Feynman was upset solving the Laplace equation for spherical waves? Anzor A. Khelashvili a) Why Pofesso Richad Feynman was upset solving the Laplace equation fo spheical waves? Anzo A. Khelashvili a) Institute of High Enegy Physics, Iv. Javakhishvili Tbilisi State Univesity, Univesity St. 9,

More information

Application of homotopy perturbation method to the Navier-Stokes equations in cylindrical coordinates

Application of homotopy perturbation method to the Navier-Stokes equations in cylindrical coordinates Computational Ecology and Softwae 5 5(): 9-5 Aticle Application of homotopy petubation method to the Navie-Stokes equations in cylindical coodinates H. A. Wahab Anwa Jamal Saia Bhatti Muhammad Naeem Muhammad

More information

Graphs of Sine and Cosine Functions

Graphs of Sine and Cosine Functions Gaphs of Sine and Cosine Functions In pevious sections, we defined the tigonometic o cicula functions in tems of the movement of a point aound the cicumfeence of a unit cicle, o the angle fomed by the

More information

Analytical Solutions for Confined Aquifers with non constant Pumping using Computer Algebra

Analytical Solutions for Confined Aquifers with non constant Pumping using Computer Algebra Poceedings of the 006 IASME/SEAS Int. Conf. on ate Resouces, Hydaulics & Hydology, Chalkida, Geece, May -3, 006 (pp7-) Analytical Solutions fo Confined Aquifes with non constant Pumping using Compute Algeba

More information

AQI: Advanced Quantum Information Lecture 2 (Module 4): Order finding and factoring algorithms February 20, 2013

AQI: Advanced Quantum Information Lecture 2 (Module 4): Order finding and factoring algorithms February 20, 2013 AQI: Advanced Quantum Infomation Lectue 2 (Module 4): Ode finding and factoing algoithms Febuay 20, 203 Lectue: D. Mak Tame (email: m.tame@impeial.ac.uk) Intoduction In the last lectue we looked at the

More information

THE LAPLACE EQUATION. The Laplace (or potential) equation is the equation. u = 0. = 2 x 2. x y 2 in R 2

THE LAPLACE EQUATION. The Laplace (or potential) equation is the equation. u = 0. = 2 x 2. x y 2 in R 2 THE LAPLACE EQUATION The Laplace (o potential) equation is the equation whee is the Laplace opeato = 2 x 2 u = 0. in R = 2 x 2 + 2 y 2 in R 2 = 2 x 2 + 2 y 2 + 2 z 2 in R 3 The solutions u of the Laplace

More information

Part V: Closed-form solutions to Loop Closure Equations

Part V: Closed-form solutions to Loop Closure Equations Pat V: Closed-fom solutions to Loop Closue Equations This section will eview the closed-fom solutions techniques fo loop closue equations. The following thee cases will be consideed. ) Two unknown angles

More information

Flux. Area Vector. Flux of Electric Field. Gauss s Law

Flux. Area Vector. Flux of Electric Field. Gauss s Law Gauss s Law Flux Flux in Physics is used to two distinct ways. The fist meaning is the ate of flow, such as the amount of wate flowing in a ive, i.e. volume pe unit aea pe unit time. O, fo light, it is

More information

Math 124B February 02, 2012

Math 124B February 02, 2012 Math 24B Febuay 02, 202 Vikto Gigoyan 8 Laplace s equation: popeties We have aleady encounteed Laplace s equation in the context of stationay heat conduction and wave phenomena. Recall that in two spatial

More information

10/04/18. P [P(x)] 1 negl(n).

10/04/18. P [P(x)] 1 negl(n). Mastemath, Sping 208 Into to Lattice lgs & Cypto Lectue 0 0/04/8 Lectues: D. Dadush, L. Ducas Scibe: K. de Boe Intoduction In this lectue, we will teat two main pats. Duing the fist pat we continue the

More information

MSE 561, Atomic Modeling in Material Science Assignment 1

MSE 561, Atomic Modeling in Material Science Assignment 1 Depatment of Mateial Science and Engineeing, Univesity of Pennsylvania MSE 561, Atomic Modeling in Mateial Science Assignment 1 Yang Lu 1. Analytical Solution The close-packed two-dimensional stuctue is

More information

Reading Assignment. Problem Description for Homework #9. Read Chapters 29 and 30.

Reading Assignment. Problem Description for Homework #9. Read Chapters 29 and 30. Reading Assignment Read Chaptes 29 and 30. Poblem Desciption fo Homewok #9 In this homewok, you will solve the inhomogeneous Laplace s equation to calculate the electic scala potential that exists between

More information

B da = 0. Q E da = ε. E da = E dv

B da = 0. Q E da = ε. E da = E dv lectomagnetic Theo Pof Ruiz, UNC Asheville, doctophs on YouTube Chapte Notes The Maxwell quations in Diffeential Fom 1 The Maxwell quations in Diffeential Fom We will now tansfom the integal fom of the

More information

Algebra. Substitution in algebra. 3 Find the value of the following expressions if u = 4, k = 7 and t = 9.

Algebra. Substitution in algebra. 3 Find the value of the following expressions if u = 4, k = 7 and t = 9. lgeba Substitution in algeba Remembe... In an algebaic expession, lettes ae used as substitutes fo numbes. Example Find the value of the following expessions if s =. a) s + + = = s + + = = Example Find

More information

School of Electrical and Computer Engineering, Cornell University. ECE 303: Electromagnetic Fields and Waves. Fall 2007

School of Electrical and Computer Engineering, Cornell University. ECE 303: Electromagnetic Fields and Waves. Fall 2007 School of Electical and Compute Engineeing, Conell Univesity ECE 303: Electomagnetic Fields and Waves Fall 007 Homewok 8 Due on Oct. 19, 007 by 5:00 PM Reading Assignments: i) Review the lectue notes.

More information

Information Retrieval Advanced IR models. Luca Bondi

Information Retrieval Advanced IR models. Luca Bondi Advanced IR models Luca Bondi Advanced IR models 2 (LSI) Pobabilistic Latent Semantic Analysis (plsa) Vecto Space Model 3 Stating point: Vecto Space Model Documents and queies epesented as vectos in the

More information

Exploration of the three-person duel

Exploration of the three-person duel Exploation of the thee-peson duel Andy Paish 15 August 2006 1 The duel Pictue a duel: two shootes facing one anothe, taking tuns fiing at one anothe, each with a fixed pobability of hitting his opponent.

More information

Chapter Eight Notes N P U1C8S4-6

Chapter Eight Notes N P U1C8S4-6 Chapte Eight Notes N P UC8S-6 Name Peiod Section 8.: Tigonometic Identities An identit is, b definition, an equation that is alwas tue thoughout its domain. B tue thoughout its domain, that is to sa that

More information

1 Explicit Explore or Exploit (E 3 ) Algorithm

1 Explicit Explore or Exploit (E 3 ) Algorithm 2.997 Decision-Making in Lage-Scale Systems Mach 3 MIT, Sping 2004 Handout #2 Lectue Note 9 Explicit Exploe o Exploit (E 3 ) Algoithm Last lectue, we studied the Q-leaning algoithm: [ ] Q t+ (x t, a t

More information

Unit 7: Sources of magnetic field

Unit 7: Sources of magnetic field Unit 7: Souces of magnetic field Oested s expeiment. iot and Savat s law. Magnetic field ceated by a cicula loop Ampèe s law (A.L.). Applications of A.L. Magnetic field ceated by a: Staight cuent-caying

More information

1) (A B) = A B ( ) 2) A B = A. i) A A = φ i j. ii) Additional Important Properties of Sets. De Morgan s Theorems :

1) (A B) = A B ( ) 2) A B = A. i) A A = φ i j. ii) Additional Important Properties of Sets. De Morgan s Theorems : Additional Impotant Popeties of Sets De Mogan s Theoems : A A S S Φ, Φ S _ ( A ) A ) (A B) A B ( ) 2) A B A B Cadinality of A, A, is defined as the numbe of elements in the set A. {a,b,c} 3, { }, while

More information

Solution to Problem First, the firm minimizes the cost of the inputs: min wl + rk + sf

Solution to Problem First, the firm minimizes the cost of the inputs: min wl + rk + sf Econ 0A Poblem Set 4 Solutions ue in class on Tu 4 Novembe. No late Poblem Sets accepted, so! This Poblem set tests the knoledge that ou accumulated mainl in lectues 5 to 9. Some of the mateial ill onl

More information

Steady State and Transient Performance Analysis of Three Phase Induction Machine using MATLAB Simulations

Steady State and Transient Performance Analysis of Three Phase Induction Machine using MATLAB Simulations Intenational Jounal of Recent Tends in Engineeing, Vol, No., May 9 Steady State and Tansient Pefomance Analysis of Thee Phase Induction Machine using MATAB Simulations Pof. Himanshu K. Patel Assistant

More information

Introduction to Arrays

Introduction to Arrays Intoduction to Aays Page 1 Intoduction to Aays The antennas we have studied so fa have vey low diectivity / gain. While this is good fo boadcast applications (whee we want unifom coveage), thee ae cases

More information

Suggested Solutions to Homework #4 Econ 511b (Part I), Spring 2004

Suggested Solutions to Homework #4 Econ 511b (Part I), Spring 2004 Suggested Solutions to Homewok #4 Econ 5b (Pat I), Sping 2004. Conside a neoclassical gowth model with valued leisue. The (epesentative) consume values steams of consumption and leisue accoding to P t=0

More information

ac p Answers to questions for The New Introduction to Geographical Economics, 2 nd edition Chapter 3 The core model of geographical economics

ac p Answers to questions for The New Introduction to Geographical Economics, 2 nd edition Chapter 3 The core model of geographical economics Answes to questions fo The New ntoduction to Geogaphical Economics, nd edition Chapte 3 The coe model of geogaphical economics Question 3. Fom intoductoy mico-economics we know that the condition fo pofit

More information

A new approach in classical electrodynamics to protect principle of causality

A new approach in classical electrodynamics to protect principle of causality A new appoach in classical electodynamics to potect pinciple of causality Biswaanjan Dikshit * Lase and Plasma Technology Division Bhabha Atomic Reseach Cente, Mumbai-400085 INDIA * Coesponding autho E-mail:

More information

is the instantaneous position vector of any grid point or fluid

is the instantaneous position vector of any grid point or fluid Absolute inetial, elative inetial and non-inetial coodinates fo a moving but non-defoming contol volume Tao Xing, Pablo Caica, and Fed Sten bjective Deive and coelate the govening equations of motion in

More information

Functions Defined on Fuzzy Real Numbers According to Zadeh s Extension

Functions Defined on Fuzzy Real Numbers According to Zadeh s Extension Intenational Mathematical Foum, 3, 2008, no. 16, 763-776 Functions Defined on Fuzzy Real Numbes Accoding to Zadeh s Extension Oma A. AbuAaqob, Nabil T. Shawagfeh and Oma A. AbuGhneim 1 Mathematics Depatment,

More information

[2007] IEEE. Reprinted, with permission, from [Jiaxin Chen, Jianguo Zhu, Youguang Guo, A 2-D nonlinear FEA tool embedded in Matlab/Simulink

[2007] IEEE. Reprinted, with permission, from [Jiaxin Chen, Jianguo Zhu, Youguang Guo, A 2-D nonlinear FEA tool embedded in Matlab/Simulink [2007] IEEE. Repinted, with pemission, fom [Jiaxin Chen, Jianguo Zhu, Youguang Guo, A 2-D nonlinea FEA tool embedded in Matlab/Simulin suounding fo application of electomagnetic field analysis in powe

More information

MATHEMATICS GRADE 12 SESSION 38 (LEARNER NOTES)

MATHEMATICS GRADE 12 SESSION 38 (LEARNER NOTES) EXAM PREPARATION PAPER (A) Leane Note: In this session you will be given the oppotunity to wok on a past examination pape (Feb/Ma 010 DoE Pape ). The pape consists of 1 questions. Question 1, and will

More information

Stanford University CS259Q: Quantum Computing Handout 8 Luca Trevisan October 18, 2012

Stanford University CS259Q: Quantum Computing Handout 8 Luca Trevisan October 18, 2012 Stanfod Univesity CS59Q: Quantum Computing Handout 8 Luca Tevisan Octobe 8, 0 Lectue 8 In which we use the quantum Fouie tansfom to solve the peiod-finding poblem. The Peiod Finding Poblem Let f : {0,...,

More information

1D2G - Numerical solution of the neutron diffusion equation

1D2G - Numerical solution of the neutron diffusion equation DG - Numeical solution of the neuton diffusion equation Y. Danon Daft: /6/09 Oveview A simple numeical solution of the neuton diffusion equation in one dimension and two enegy goups was implemented. Both

More information

A Hartree-Fock Example Using Helium

A Hartree-Fock Example Using Helium Univesity of Connecticut DigitalCommons@UConn Chemisty Education Mateials Depatment of Chemisty June 6 A Hatee-Fock Example Using Helium Cal W. David Univesity of Connecticut, Cal.David@uconn.edu Follow

More information

Ch 30 - Sources of Magnetic Field! The Biot-Savart Law! = k m. r 2. Example 1! Example 2!

Ch 30 - Sources of Magnetic Field! The Biot-Savart Law! = k m. r 2. Example 1! Example 2! Ch 30 - Souces of Magnetic Field 1.) Example 1 Detemine the magnitude and diection of the magnetic field at the point O in the diagam. (Cuent flows fom top to bottom, adius of cuvatue.) Fo staight segments,

More information

PHYS 110B - HW #7 Spring 2004, Solutions by David Pace Any referenced equations are from Griffiths Problem statements are paraphrased

PHYS 110B - HW #7 Spring 2004, Solutions by David Pace Any referenced equations are from Griffiths Problem statements are paraphrased PHYS 0B - HW #7 Sping 2004, Solutions by David Pace Any efeenced euations ae fom Giffiths Poblem statements ae paaphased. Poblem 0.3 fom Giffiths A point chage,, moves in a loop of adius a. At time t 0

More information

Computers and Mathematics with Applications

Computers and Mathematics with Applications Computes and Mathematics with Applications 58 (009) 9 7 Contents lists available at ScienceDiect Computes and Mathematics with Applications jounal homepage: www.elsevie.com/locate/camwa Bi-citeia single

More information

MULTILAYER PERCEPTRONS

MULTILAYER PERCEPTRONS Last updated: Nov 26, 2012 MULTILAYER PERCEPTRONS Outline 2 Combining Linea Classifies Leaning Paametes Outline 3 Combining Linea Classifies Leaning Paametes Implementing Logical Relations 4 AND and OR

More information

THE NUMBER OF TWO CONSECUTIVE SUCCESSES IN A HOPPE-PÓLYA URN

THE NUMBER OF TWO CONSECUTIVE SUCCESSES IN A HOPPE-PÓLYA URN TH NUMBR OF TWO CONSCUTIV SUCCSSS IN A HOPP-PÓLYA URN LARS HOLST Depatment of Mathematics, Royal Institute of Technology S 100 44 Stocholm, Sweden -mail: lholst@math.th.se Novembe 27, 2007 Abstact In a

More information

( ) [ ] [ ] [ ] δf φ = F φ+δφ F. xdx.

( ) [ ] [ ] [ ] δf φ = F φ+δφ F. xdx. 9. LAGRANGIAN OF THE ELECTROMAGNETIC FIELD In the pevious section the Lagangian and Hamiltonian of an ensemble of point paticles was developed. This appoach is based on a qt. This discete fomulation can

More information

Introduction Common Divisors. Discrete Mathematics Andrei Bulatov

Introduction Common Divisors. Discrete Mathematics Andrei Bulatov Intoduction Common Divisos Discete Mathematics Andei Bulatov Discete Mathematics Common Divisos 3- Pevious Lectue Integes Division, popeties of divisibility The division algoithm Repesentation of numbes

More information

Physics 221 Lecture 41 Nonlinear Absorption and Refraction

Physics 221 Lecture 41 Nonlinear Absorption and Refraction Physics 221 Lectue 41 Nonlinea Absoption and Refaction Refeences Meye-Aendt, pp. 97-98. Boyd, Nonlinea Optics, 1.4 Yaiv, Optical Waves in Cystals, p. 22 (Table of cystal symmeties) 1. Intoductoy Remaks.

More information

HASHING METHODS. Hanan Samet

HASHING METHODS. Hanan Samet hs0 HASHING METHODS Hanan Samet Compute Science Depatment and Cente fo Automation Reseach and Institute fo Advanced Compute Studies Univesity of Mayland College Pak, Mayland 20742 e-mail: hjs@umiacs.umd.edu

More information

Classical Worm algorithms (WA)

Classical Worm algorithms (WA) Classical Wom algoithms (WA) WA was oiginally intoduced fo quantum statistical models by Pokof ev, Svistunov and Tupitsyn (997), and late genealized to classical models by Pokof ev and Svistunov (200).

More information

ANA BERRIZBEITIA, LUIS A. MEDINA, ALEXANDER C. MOLL, VICTOR H. MOLL, AND LAINE NOBLE

ANA BERRIZBEITIA, LUIS A. MEDINA, ALEXANDER C. MOLL, VICTOR H. MOLL, AND LAINE NOBLE THE p-adic VALUATION OF STIRLING NUMBERS ANA BERRIZBEITIA, LUIS A. MEDINA, ALEXANDER C. MOLL, VICTOR H. MOLL, AND LAINE NOBLE Abstact. Let p > 2 be a pime. The p-adic valuation of Stiling numbes of the

More information

Electromagnetic scattering. Graduate Course Electrical Engineering (Communications) 1 st Semester, Sharif University of Technology

Electromagnetic scattering. Graduate Course Electrical Engineering (Communications) 1 st Semester, Sharif University of Technology Electomagnetic scatteing Gaduate Couse Electical Engineeing (Communications) 1 st Semeste, 1390-1391 Shaif Univesity of Technology Geneal infomation Infomation about the instucto: Instucto: Behzad Rejaei

More information

Review Exercise Set 16

Review Exercise Set 16 Review Execise Set 16 Execise 1: A ectangula plot of famland will be bounded on one side by a ive and on the othe thee sides by a fence. If the fame only has 600 feet of fence, what is the lagest aea that

More information

Construction and Analysis of Boolean Functions of 2t + 1 Variables with Maximum Algebraic Immunity

Construction and Analysis of Boolean Functions of 2t + 1 Variables with Maximum Algebraic Immunity Constuction and Analysis of Boolean Functions of 2t + 1 Vaiables with Maximum Algebaic Immunity Na Li and Wen-Feng Qi Depatment of Applied Mathematics, Zhengzhou Infomation Engineeing Univesity, Zhengzhou,

More information

2.5 The Quarter-Wave Transformer

2.5 The Quarter-Wave Transformer /3/5 _5 The Quate Wave Tansfome /.5 The Quate-Wave Tansfome Reading Assignment: pp. 73-76 By now you ve noticed that a quate-wave length of tansmission line ( λ 4, β π ) appeas often in micowave engineeing

More information

When two numbers are written as the product of their prime factors, they are in factored form.

When two numbers are written as the product of their prime factors, they are in factored form. 10 1 Study Guide Pages 420 425 Factos Because 3 4 12, we say that 3 and 4 ae factos of 12. In othe wods, factos ae the numbes you multiply to get a poduct. Since 2 6 12, 2 and 6 ae also factos of 12. The

More information

PROBLEM SET #1 SOLUTIONS by Robert A. DiStasio Jr.

PROBLEM SET #1 SOLUTIONS by Robert A. DiStasio Jr. POBLM S # SOLUIONS by obet A. DiStasio J. Q. he Bon-Oppenheime appoximation is the standad way of appoximating the gound state of a molecula system. Wite down the conditions that detemine the tonic and

More information

RECTIFYING THE CIRCUMFERENCE WITH GEOGEBRA

RECTIFYING THE CIRCUMFERENCE WITH GEOGEBRA ECTIFYING THE CICUMFEENCE WITH GEOGEBA A. Matín Dinnbie, G. Matín González and Anthony C.M. O 1 Intoducction The elation between the cicumfeence and the adius of a cicle is one of the most impotant concepts

More information

Multifrontal sparse QR factorization on the GPU

Multifrontal sparse QR factorization on the GPU Multifontal spase QR factoization on the GPU Tim Davis, Sanjay Ranka, Shaanyan Chetlu, Nui Yealan Univesity of Floida Feb 2012 GPU-based Multifontal QR factoization why spase QR? multifontal spase QR in

More information

Simulation of a 2-link Brachiating Robot with Open-Loop Controllers

Simulation of a 2-link Brachiating Robot with Open-Loop Controllers Simulation of a -link Bachiating Robot with Open-oop Contolles David Uffod Nothwesten Univesit June 009 . Poject Oveview The goal of this poject was to wite a complete simulation of a -link swinging obot

More information

A NEW VARIABLE STIFFNESS SPRING USING A PRESTRESSED MECHANISM

A NEW VARIABLE STIFFNESS SPRING USING A PRESTRESSED MECHANISM Poceedings of the ASME 2010 Intenational Design Engineeing Technical Confeences & Computes and Infomation in Engineeing Confeence IDETC/CIE 2010 August 15-18, 2010, Monteal, Quebec, Canada DETC2010-28496

More information

PHYS 301 HOMEWORK #10 (Optional HW)

PHYS 301 HOMEWORK #10 (Optional HW) PHYS 301 HOMEWORK #10 (Optional HW) 1. Conside the Legende diffeential equation : 1 - x 2 y'' - 2xy' + m m + 1 y = 0 Make the substitution x = cos q and show the Legende equation tansfoms into d 2 y 2

More information

Evolutionary approach to Quantum and Reversible Circuits synthesis

Evolutionary approach to Quantum and Reversible Circuits synthesis Evolutionay appoach to Quantum and Revesible Cicuits synthesis Matin Lukac, Maek Pekowski, Hilton Goi, Mikhail Pivtoaiko +, Chung Hyo Yu, Kyusik Chung, Hyunkoo Jee, Byung-guk Kim, Yong-Duk Kim Depatment

More information

CALCULUS II Vectors. Paul Dawkins

CALCULUS II Vectors. Paul Dawkins CALCULUS II Vectos Paul Dawkins Table of Contents Peface... ii Vectos... 3 Intoduction... 3 Vectos The Basics... 4 Vecto Aithmetic... 8 Dot Poduct... 13 Coss Poduct... 21 2007 Paul Dawkins i http://tutoial.math.lama.edu/tems.aspx

More information

Physics 2B Chapter 22 Notes - Magnetic Field Spring 2018

Physics 2B Chapter 22 Notes - Magnetic Field Spring 2018 Physics B Chapte Notes - Magnetic Field Sping 018 Magnetic Field fom a Long Staight Cuent-Caying Wie In Chapte 11 we looked at Isaac Newton s Law of Gavitation, which established that a gavitational field

More information

Lecture 18: Graph Isomorphisms

Lecture 18: Graph Isomorphisms INFR11102: Computational Complexity 22/11/2018 Lectue: Heng Guo Lectue 18: Gaph Isomophisms 1 An Athu-Melin potocol fo GNI Last time we gave a simple inteactive potocol fo GNI with pivate coins. We will

More information