38 Pages

ControlFlow

Course: COP 4020, Spring 2011
School: FSU
Rating:
 
 
 
 
 

Word Count: 3382

Document Preview

Flow Prof. COP4020 Programming Languages Control Robert van Engelen Overview ! Structured and unstructured flow " " " " " " ! Goto's Sequencing Selection Iteration and iterators Recursion Applicative- and normal-order evaluation Expressions evaluation " " 4/7/11 Evaluation order Assignments COP4020 Spring 2011 2 Control Flow:...

Register Now

Unformatted Document Excerpt

Coursehero >> Florida >> FSU >> COP 4020

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Flow Prof. COP4020 Programming Languages Control Robert van Engelen Overview ! Structured and unstructured flow " " " " " " ! Goto's Sequencing Selection Iteration and iterators Recursion Applicative- and normal-order evaluation Expressions evaluation " " 4/7/11 Evaluation order Assignments COP4020 Spring 2011 2 Control Flow: Ordering the Execution of a Program ! Constructs for specifying the execution order: 1. 2. 3. 4. 5. 6. 7. 4/7/11 Sequencing: the execution of statements and evaluation of expressions is usually in the order in which they appear in a program text Selection (or alternation): a run-time condition determines the choice among two or more statements or expressions Iteration: a statement is repeated a number of times or until a run-time condition is met Procedural abstraction: subroutines encapsulate collections of statements and subroutine calls can be treated as single statements Recursion: subroutines which call themselves directly or indirectly to solve a problem, where the problem is typically defined in terms of simpler versions of itself Concurrency: two or more program fragments executed in parallel, either on separate processors or interleaved on a single processor Nondeterminacy: the execution order among alternative constructs is deliberately left unspecified, indicating that any alternative will lead to a correct result COP4020 Spring 2011 3 Structured and Unstructuted Flow ! Unstructured flow: the use of goto statements and statement labels to implement control flow " " " ! Merit or evil? Generally considered bad, but sometimes useful for jumping out of nested loops and for coding the flow of exceptions (when a language does not support exception handling) Java has no goto statement (supports labeled loops and breaks) Structured flow: " " " " " 4/7/11 Statement sequencing Selection with if-then-else statements and switch statements Iteration with for and while loop statements Subroutine calls (including recursion) All of which promotes structured programming COP4020 Spring 2011 4 Sequencing ! ! A list of statements in a program text is executed in topdown order A compound statement is a delimited list of statements " " " " ! ! A compund statement is called a block when it includes variable declarations C, C++, and Java use { and } to delimit a block Pascal and Modula use begin ... end Ada uses declare ... begin ... end Special cases: in C, C++, and Java expressions can be inserted as statements In pure functional languages sequencing is impossible (and not desired!) 4/7/11 COP4020 Spring 2011 5 Selection ! If-then-else selection statements in C and C++: " " " " ! ! ! if (<expr>) <stmt> [else <stmt>] Condition is a bool, integer, or pointer Grouping with { and } is required for statement sequences in the then clause and else clause Syntax ambiguity is resolved with an else matches the closest if rule Conditional expressions, e.g. if and cond in Lisp and a?b:c in C Java syntax is like C/C++, but condition must be Boolean Ada syntax supports multiple elsif's to define nested conditions: " 4/7/11 if <cond> then <statements> elsif <cond> then ... else <statements> end if COP4020 Spring 2011 6 Selection (contd) ! Case/switch statements are different from if-then-else statements in that an expression can be tested against multiple constants to select statement(s) in one of the arms of the case statement: " " " ! C, C++, and Java: switch (<expr>) { case <const>: <statements> break; case <const>: <statements> break; ... default: <statements> } A break is necessary to transfer control at the end of an arm to the end of the switch statement Most programming languages support a switch-like statement, but do not require the use of a break in each arm A switch statement is much more efficient compared to nested ifthen-else statements 4/7/11 COP4020 Spring 2011 7 Iteration ! ! Enumeration-controlled loops repeat a collection of statements a number of times, where in each iteration a loop index variable takes the next value of a set of values specified at the beginning of the loop Logically-controlled loops repeat a collection of statements until some Boolean condition changes value in the loop " " " 4/7/11 Pretest loops test condition at the begin of each iteration Posttest loops test condition at the end of each iteration Midtest loops allow structured exits from within loop with exit conditions COP4020 Spring 2011 8 Enumeration-Controlled Loops ! ! History of failures on design of enumeration-controlled loops Fortran-IV: 20 DO 20 i = 1, 10, 2 ... CONTINUE which is defined to be equivalent to 20 i=1 ... i=i+2 IF i.LE.10 GOTO 20 Problems: " " " " " 4/7/11 Requires positive constant loop bounds (1 and 10) and step size (2) If loop index variable i is modified in the loop body, the number of iterations is changed compared to the iterations set by the loop bounds GOTOs can jump out of the loop and also from outside into the loop The value of counter i after the loop is implementation dependent The body of the loop will be executed at least once (no empty bounds) COP4020 Spring 2011 9 Enumeration-Controlled Loops (contd) ! Fortran-77: " " " " " " " " 4/7/11 Same syntax as in Fortran-IV, but many dialects support ENDDO instead of CONTINUE statements Can jump out of the loop, but cannot jump from outside into the loop Assignments to counter i in loop body are not allowed Number of iterations is determined by max(!(H-L+S)/S", 0) for lower bound L, upper bound H, step size S Body is not executed when (H-L+S)/S < 0 Either integer-valued or real-valued expressions for loop bounds and step sizes Changes to the variables used in the bounds do not affect the number of iterations executed Terminal value of loop index variable is the most recent value assigned, which is L + S*max(!(H-L+S)/S", 0) COP4020 Spring 2011 10 Enumeration-Controlled Loops (contd) ! ! Algol-60 combines logical conditions in combination loops: for <id> := <forlist> do <stmt> where the syntax of <forlist> is <forlist> ::= <enumerator> [, enumerator]* <enumerator> ::= <expr> | <expr> step <expr> until <expr> | <expr> while <cond> Not orthogonal: many forms that behave the same: for i := 1, 3, 5, 7, 9 do ... for i := 1 step 2 until 10 do ... for i := 1, i+2 while i < 10 do ... 4/7/11 COP4020 Spring 2011 11 Enumeration-Controlled Loops (contd) ! ! ! ! ! Pascals enumeration-controlled loops have simple and elegant design with two forms for up and down: for <id> := <expr> to <expr> do <stmt> and for <id> := <expr> downto <expr> do <stmt> Can iterate over any discrete type, e.g. integers, chars, elements of a set Lower and upper bound expressions are evaluated once to determine the iteration range Counter variable cannot be assigned in the loop body Final value of loop counter after the loop is undefined 4/7/11 COP4020 Spring 2011 12 Enumeration-Controlled Loops (contd) ! ! ! Adas for loop is much like Pascal's: for <id> in <expr> .. <expr> loop <statements> end loop and for <id> in reverse <expr> .. <expr> loop <statements> end loop Lower and upper bound expressions are evaluated once to determine the iteration range Counter variable has a local scope in the loop body " ! Not accessible outside of the loop Counter variable cannot be assigned in the loop body 4/7/11 COP4020 Spring 2011 13 Enumeration-Controlled Loops (contd) ! ! ! C, C++, and Java do not have true enumeration-controlled loops A for loop is essentially a logically-controlled loop for (i = 1; i <= n; i++) ... which iterates i from 1 to n by testing i <= n before the start of each iteration and updating i by 1 in each iteration Why is this not enumeration controlled? " ! ! ! Assignments to counter i and variables in the bounds are allowed, thus it is the programmer's responsibility to structure the loop to mimic enumeration loops Use continue to jump to next iteration Use break to exit loop C++ and Java also support local scoping for counter variable for (int i = 1; i <= n; i++) ... 4/7/11 COP4020 Spring 2011 14 Enumeration-Controlled Loops (contd) ! Other problems with C/C++ for loops to emulate enumerationcontrolled loops are related to the mishandling of bounds and limits of value representations " This C program never terminates (do you see why?) #include <limits.h> // INT_MAX is max int value main() { int i; for (i = 0; i <= INT_MAX; i++) printf(Iteration %d\n, i); } " This C program does not count from 0.0 to 10.0, why? main() { float n; for (n = 0.0; n <= 10; n += 0.01) printf(Iteration %g\n, n); } 4/7/11 COP4020 Spring 2011 15 Enumeration-Controlled Loops (contd) ! ! ! How is loop iteration counter overflow handled? C, C++, and Java: nope Fortran-77 " " ! Calculate the number of iterations in advance For REAL typed index variables an exception is raised when overflow occurs Pascal and Ada " " 4/7/11 Only specify step size 1 and -1 and detection of the end of the iterations is safe Pascals final counter value is undefined (may have wrapped) COP4020 Spring 2011 16 Iterators ! ! ! Iterators are used to iterate over elements of containers such as sets and data structures such as lists and trees Iterator objects are also called enumerators or generators C++ iterators are associated with a container object and used in loops similar to pointers and pointer arithmetic: vector<int> V; for (vector<int>::iterator it = V.begin(); it != V.end(); ++it) cout << *n << endl; An in-order tree traversal: tree_node<int> T; for (tree_node<int>::iterator it = T.begin(); it != T.end(); ++it) cout << *n << endl; 4/7/11 COP4020 Spring 2011 17 Iterators (contd) ! ! Java supports generics similar to C++ templates Iterators are similar to C++, but do not have the usual C++ overloaded iterator operators: TreeNode<Integer> T; for (Integer i : T) System.out.println(i); Note that Java has the above special for-loop for iterators that is essentially syntactic sugar for: for (Iterator<Integer> it = T.iterator(); it.hasNext(); ) { Integer i = it.next(); System.out.println(i); } 4/7/11 COP4020 Spring 2011 18 Iterators (contd) ! Iterators typically need special loops to produce elements one by one, e.g. in Clu: for i in int$from_to_by(first, last, step) do end ! While Java and C++ use iterator objects that hold the state of the iterator, Clu, Python, Ruby, and C# use generators (=true iterators) which are functions that run in parallel to the loop code to produce elements " " " 4/7/11 The yield operation in Clu returns control to the loop body The loop returns control to the generators last yield operation to allow it to compute the value for the next iteration The loop terminates when the generator function returns COP4020 Spring 2011 19 Logically-Controlled Pretest loops ! ! ! ! ! Logically-controlled pretest loops check the exit condition before the next loop iteration Not available Fortran-77 Ada has only one kind of logically-controlled loops: midtest loops Pascal: while <cond> do <stmt> where the condition is a Boolean-typed expression C, C++: while (<expr>) <stmt> where loop the terminates when the condition evaluates to 0, NULL, or false " ! Use continue and break to jump to next iteration or exit the loop Java is similar C++, but condition is restricted to Boolean 4/7/11 COP4020 Spring 2011 20 Logically-Controlled Posttest Loops ! ! ! ! ! ! Logically-controlled posttest loops check the exit condition after each loop iteration Not available in Fortran-77 Ada has only one kind of logically-controlled loops: midtest loops Pascal: repeat <stmt> [; <stmt>]* until <cond> where the condition is a Boolean-typed expression and the loop terminates when the condition is true C, C++: do <stmt> while (<expr>) where the loop terminates when the expression evaluates to 0, NULL, or false Java is similar to C++, but condition is restricted to Boolean 4/7/11 COP4020 Spring 2011 21 Logically-Controlled Midtest Loops ! Ada supports logically-controlled midtest loops check exit conditions anywhere within the loop: loop <statements> exit when <cond>; <statements> exit when <cond>; ... end loop ! Ada also supports labels, allowing exit of outer loops without gotos: outer: loop ... for i in 1..n loop ... exit outer when a[i]>0; ... end loop; end outer loop; 4/7/11 COP4020 Spring 2011 22 Recursion ! ! Recursion: subroutines that call themselves directly or indirectly (mutual recursion) Typically used to solve a problem that is defined in terms of simpler versions, for example: " " ! Iteration and recursion are equally powerful in theoretical sense " ! ! To compute the length of a list, remove the first element, calculate the length of the remaining list in n, and return n+1 Termination condition: if the list is empty, return 0 Iteration can be expressed by recursion and vice versa Recursion is more elegant to use to solve a problem that is naturally recursively defined, such as a tree traversal algorithm Recursion can be less efficient, but most compilers for functional languages are often able to replace it with iterations 4/7/11 COP4020 Spring 2011 23 Tail-Recursive Functions ! Tail-recursive functions are functions in which no operations follow the recursive call(s) in the function, thus the function returns immediately after the recursive call: tail-recursive not tail-recursive int trfun() { return trfun(); } ! A tail-recursive call could reuse the subroutine's frame on the runtime stack, since the current subroutine state is no longer needed " ! int rfun() { return rfun()+1; } Simply eliminating the push (and pop) of the next frame will do In addition, we can do more for tail-recursion optimization: the compiler replaces tail-recursive calls by jumps to the beginning of the function 4/7/11 COP4020 Spring 2011 24 Tail-Recursion Optimization ! Consider the GCD function: int gcd(int a, int b) { if (a==b) return a; else if (a>b) return gcd(a-b, b); else return gcd(a, b-a); } a good compiler will optimize the function into: int gcd(int a, int b) { start: if (a==b) return a; else if (a>b) { a = a-b; goto start; } else { b = b-a; goto start; } } which is just as efficient as the iterative version: 4/7/11 int gcd(int a, int b) { while (a!=b) if (a>b) a = a-b; else b = b-a; return a; } COP4020 Spring 2011 25 Converting Recursive Functions to Tail-Recursive Functions ! ! Remove the work after the recursive call and include it in some other form as a computation that is passed to the recursive call For example, the non-tail-recursive function (define summation (lambda (f low high) (if (= low high) (f low) (+ (f low) (summation f (+ low 1) high))))) can be rewritten into a tail-recursive function: (define summation (lambda (f low high subtotal) (if (=low high) (+ subtotal (f low)) (summation f (+ low 1) high (+ subtotal (f low)))))) 4/7/11 COP4020 Spring 2011 26 Example ! Here is the same example in C: typedef int (*int_func)(int); int summation(int_func f, int low, int high) { if (low == high) return f(low) else return f(low) + summation(f, low+1, high); } rewritten into the tail-recursive form: int summation(int_func f, int low, int high, int subtotal) { if (low == high) return subtotal+f(low) else return summation(f, low+1, high, subtotal+f(low)); } 4/7/11 COP4020 Spring 2011 27 When Recursion is Bad ! The Fibonacci function implemented as a recursive function is very inefficient as it takes exponential time to compute: (define fib (lambda (n) (cond ((= n 0) 1) ((= n 1) 1) (else (+ (fib (- n 1)) (fib (- n 2))))))) with a tail-recursive helper function, we can run it in O(n) time: (define fib (lambda (n) (letrec ((fib-helper (lambda (f1 f2 i) (if (= i n) f2 (fib-helper f2 (+ f1 f2) (+ i 1)))))) (fib-helper 0 1 0)))) 4/7/11 COP4020 Spring 2011 28 Applicative- and Normal-Order Evaluation ! Lazy evaluation Topic skipped 4/7/11 COP4020 Spring 2011 29 Expression Syntax and Effect on Evaluation Order ! An expression consists of " " ! Common syntactic forms for operators: " " " " " " 4/7/11 An atomic object, e.g. number or variable An operator applied to a collection of operands (or arguments) that are expressions Function call notation, e.g. somefunc(A, B, C) Infix notation for binary operators, e.g. A + B Prefix notation for unary operators, e.g. -A Postfix notation for unary operators, e.g. i++ Cambridge Polish notation, e.g. (* (+ 1 3) 2) in Lisp "Multi-word" infix, e.g. a>b?a:b in C and myBox displayOn: myScreen at: 100@50 in Smalltalk, where displayOn: and at: are written infix with arguments mybox, myScreen, and 100@50 COP4020 Spring 2011 30 Operator Precedence and Associativity ! The use of infix, prefix, and postfix notation sometimes lead to ambiguity as to what is an operand of what " ! ! Fortran example: a+b*c**d**e/f Operator precedence: higher operator precedence means that a (collection of) operator(s) group more tightly in an expression than operators of lower precedence Operator associativity: determines grouping of operators of the same precedence " " " 4/7/11 Left associative: operators are grouped left-to-right (most common) Right associative: operators are grouped right-to-left (Fortran power operator **, C assignment operator = and unary minus) Non-associative: requires parenthesis when composed (Ada power operator **) COP4020 Spring 2011 31 Operator Precedence and Associativity ! Pascal's flat precedence levels is a design mistake if A<B and C<D then is grouped as follows if A<(B and C)<D then ! Note: levels of operator precedence and associativity are easily captured in a grammar as we saw earlier 4/7/11 COP4020 Spring 2011 32 Evaluation Order of Expressions ! Precedence and associativity state the rules for grouping operators in expressions, but do not determine the operand evaluation order! " ! ! Expression a-f(b)-b*c is structured as (a-f(b))-(b*c) but either (a-f(b)) or (b*c) can be evaluated first The evaluation order of arguments in function and subroutine calls may differ, e.g. arguments evaluated from left to right or right to left Knowing the operand evaluation order is important " " 4/7/11 Side effects: suppose f(b) above modifies the value of b (f(b) has a side effect) then the value will depend on the operand evaluation order Code improvement: compilers rearrange expressions to maximize efficiency, e.g. a compiler can improve memory load efficiency by moving loads up in the instruction stream COP4020 Spring 2011 33 Expression Operand Reordering Issues ! Rearranging expressions may lead to arithmetic overflow or different floating point results " " " ! Assume b, d, and c are very large positive integers, then if b-c+d is rearranged into (b+d)-c arithmetic overflow occurs Floating point value of b-c+d may differ from b+d-c Most programming languages will not rearrange expressions when parenthesis are used, e.g. write (b-c)+d to avoid problems Design choices: " " " " 4/7/11 Java: expressions evaluation is always left to right in the order operands are provided in the source text and overflow is always detected Pascal: expression evaluation is unspecified and overflows are always detected C anc C++: expression evaluation is unspecified and overflow detection is implementation dependent Lisp: no limit on number representation COP4020 Spring 2011 34 Short-Circuit Evaluation ! ! Short-circuit evaluation of Boolean expressions: the result of an operator can be determined from the evaluation of just one operand Pascal does not use short-circuit evaluation " ! The program fragment below has the problem that element a[11] is read resulting in a dynamic semantic error: var a:array [1..10] of integer; ... i := 1; while i<=10 and a[i]<>0 do i := i+1 C, C++, and Java use short-circuit conditional and/or operators " " " " " 4/7/11 If a in a&&b evaluates to false, b is not evaluated If a in a||b evaluates to true, b is not evaluated Avoids the Pascal problem, e.g. while (i <= 10 && a[i] != 0) ... Ada uses and then and or else, e.g. cond1 and then cond2 Ada, C, and C++ also have regular bit-wise Boolean operators COP4020 Spring 2011 35 Assignments and Expressions ! ! Fundamental difference between imperative and functional languages Imperative: "computing by means of side effects " ! Computation is an ordered series of changes to values of variables in memory (state) and statement ordering is influenced by run-time testing values of variables Expressions in functional language are referentially transparent: " " 4/7/11 All values used and produced depend on the local referencing environment of the expression A function is idempotent in a functional language: it always returns the same value given the same arguments because of the absence of side-effects COP4020 Spring 2011 36 L-Values vs. R-Values and Value Model vs. Reference Model ! Consider the assignment of the form: a := b " " ! ! The left-hand side a of the assignment is an l-value which is an expression that should denote a location, e.g. array element a[2] or a variable foo or a dereferenced pointer *p The right-hand side b of the assignment is an r-value which can be any syntactically valid expression with a type that is compatible to the lefthand side Languages that adopt the value model of variables copy the value of b into the location of a (e.g. Ada, Pascal, C) Languages that adopt the reference model of variables copy references, resulting in shared data values via multiple references " " 4/7/11 Clu copies the reference of b into a so that a and b refer to the same object Java is a mix: it uses the value model for built-in types and the reference model for class instances COP4020 Spring 2011 37 Special Cases of Assignments ! Assignment by variable initialization " " ! Combinations of assignment operators " " ! Use of uninitialized variable is source of many problems, sometimes compilers are able to detect this but with programmer involvement e.g. definite assignment requirement in Java Implicit initialization, e.g. 0 or NaN (not a number) is assigned by default when variable is declared In C/C++ a+=b is equivalent to a=a+b (but a[i++]+=b is different from a[i++]=a[i++]+b, ouch!) Compiler produces better code, because the address of a variable is only calculated once Multiway assignments in Clu, ML, and Perl " " 4/7/11 a,b := c,d assigns c to a and d to b simultaneously, e.g. a,b := b,a swaps a with b a,b := 1 assigns 1 to both a and b COP4020 Spring 2011 38
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

City College of San Francisco - MATH - 203
203 Spring 2009 Group Final SolutionsQ1a: unit vectors are:v1 =84, 0, 1&lt;Sqrt@84, 0, 1&lt; . 84, 0, 1&lt;D4:, 0,17v2 =&gt;17- 84, 0, 1&lt;Sqrt@84, 0, 1&lt; . 84, 0, 1&lt;D4:-1, 0, -171&gt;17Q1b: substitute and solve to get the point of intersection as (-8
FSU - COP - 4020
COP4020ProgrammingLanguagesException HandlingProf. Robert van EngelenOverview!What is defensive programming?!Ways to catch and handle run-time errors:&quot;&quot;&quot;4/13/11In programming languages that do not support exceptionhandlingException handlin
FSU - COP - 4020
COP4020ProgrammingLanguagesFunctional ProgrammingProf. Robert van EngelenOverview!!!!!!What is functional programming?Historical origins of functional programmingFunctional programming todayConcepts of functional programmingFunctional prog
City College of San Francisco - MATH - 203
dYphd t p k tg k cfw_ g zj gj jgk t g dXusugB@aysBsg DIwsxDse%wvDu4D|sEUcfw_f f nd pr f uweiyD w'D4h| gkkj kj jg z k lmjgjk jgk t k j jxk k k kjjx g k tg k k k d g dsws'wvDuPD'ss5yiuyDDDxysyDsFDuswyyPD Dui@d XSD4Dssg s Dy$d k z jk j kjx e
FSU - COP - 4020
Class Quiz ResultsCode fragment 1:program fac(input, output)vari, n, f : integer;beginreadln(n);f := 1;for i := 1 to n dof := f * i;writeln(f)end.Pascal: 8Ada: 6Prolog: 5Fortran77/90: 4Lisp: 4Cobol 3Algol: 2Haskell: 2Basic: 1C: 1PL/I
City College of San Francisco - MATH - 203
MATH/PHILO 376Texts:Philosophy of Mathematics3 hours 3 creditsCoursepack prepared especially for this course for this semesterErnest Nagel and James R. Newman, Gdel's Proof Revised Edition,(New York and London: New York University Press, 2001)Bertr
FSU - COP - 4020
COP4020 Spring 2010 Homework Assignment 2The material for this homework assignment covers textbook !&quot;#$%&amp;'()( and lecture notes.1. What was the first programming language you learned? If you chose it yourself,why did you do so? If it was chose for you
FSU - COP - 4020
COP4020 Spring 2011 Homework Assignment 31. Explain the difference between a functional and a special form in Scheme.2. Why is Scheme called homoiconic?3. Which Scheme construct(s) will cause a Scheme program to depart from a purelyfunctional programm
City College of San Francisco - MATH - 203
Math 34600Final ExamFall 2005Instructions: Answer any seven questions. Omit one. 1 1 0 1a) Find the inverse of the matrix A = 1 2 1 . 0 1 2 x y =11b) Using A solve the system of equations: x + 2 y z = 2 . y + 2 z = 2012a) Let B = 02210 1
FSU - COP - 4020
COP4020 Spring 2011 Homework Assignment 41. Consider the following tic-tac-toe board positions:XOOXXOThat is, the program database holds the following facts (in this order):x(1).x(5).x(6).o(2).o(3).o(7).Show a trace of the execution of sub-
City College of San Francisco - MATH - 203
Math 34600 Final Exam, Fall 20061. Invert the following matrices, if possible.(a)(5 points)2 324A=(b)(5 points)4 81 2A=2. Let266A = 2 7 6 .277(a) Compute A1 , if possible.(5 points)(b) Find the rank and nullity of A.1(c) Find all solu
FSU - COP - 4020
COP4020 Spring 2011 Homework Assignment 51. Errors in a computer program can be classified according to when they aredetected and, if they are detected at compile time, what part of the compilerdetects them. Assuming we use C, give an example of each o
City College of San Francisco - MATH - 203
THE CITY COLLEGEMATHEMATICS 34600DEPARTMENT OF MATHEMATICSFINAL EXAMINATION SPRING 2005PART I: ANSWER ALL THREE QUESTIONS (40%) 1 2 21. (15) Let A = 1 2 1 . 1 1 0 a. Find the eigenvalues and bases for the eigenspaces of A.b. Find a diagonal matri
FSU - COP - 4020
COP4020 Spring 2011 Homework Assignment 61. Using axiomatic semantics, prove the correctness of the following algorithm thatcomputes the quotient q and remainder r of n/d (that is, it computes q and r such thatn = q*d + r and 0 ! r &lt; d). The loop invar
City College of San Francisco - MATH - 203
Department of MathematicsMathematics 34600Final ExaminationThe City College of New YorkSpring 2006PART I: Answer any 5 out of 7 questions. Each is worth 16 points.1. Solve the system of equations.x1 2 x 2 + x3 4 x 4 = 1x1 + 3 x 2 + 7 x3 + 2 x 4 =
FSU - COP - 4020
COP4020 Spring 2011 Homework Assignment 71.Consider the following pseudo-code program:sum : integer / a global variableprocedure add(amount : integer)sum := sum + amountprocedure p(x : integer, adder : procedure)integer sumsum := xadder(x) / invo
City College of San Francisco - MATH - 203
PSYCH 170: Psychology of Human SexualityHunter College, CUNY, Fall 2011Section 001: Mondays and Thursdays, 8:109:25am HN 1036Instructor: Jennifer TangPhone: (212) 817-8766Teaching Assistant: Wen LiuE-Mail: jtang@gc.cuny.eduOffice Hours: By Appointm
FSU - COP - 4020
COP4020ProgrammingLanguagesNames, Scopes, and BindingsProf. Robert van EngelenOverview!!!!Abstractions and namesBinding timeObject lifetimeObject storage management&quot;&quot;&quot;!!!!Static allocationStack allocationHeap allocationScope rules
City College of San Francisco - MATH - 203
TENTATIVE SYLLABUSPsychology170PsychologyofHumanSexualityThisisatentativesyllabustogivestudentsinformationonacourse.PleasereferbacktotheRegistrarssiteforupdateswhentheofficialsyllabusandbookinfowillbeposted.Prerequisites:PSYCH100Text:Thetextbookfort
FSU - COP - 4020
COP4020 Programming Assignment 1 - Spring 2011In this programming assignment we design and implement a small imperative programming language Micro-PL. To execute Mirco-PL code we translate the code to Schemeand execute it in Scheme. This translator/comp
City College of San Francisco - MATH - 203
Statistics 213: Introduction to Applied StatisticsLearning Outcomes.This course emphasizes statistical literacy and develops statistical thinking. Statistical literacyis promoted throughout the text in the many examples and exercises, drawn from publis
FSU - COP - 4020
COP4020 Programming Assignment 2 Spring 2011Consider our familiar augmented LL(1) grammar for an expression language (see Syntax lecture notes on the LL(1) expression grammar):GRAMMAR PRODUCTIONSEMANTIC RULES&lt;expr&gt;-&gt; &lt;term&gt; &lt;term_tail&gt;term_tail.subt
City College of San Francisco - MATH - 203
Hunter College of The City University of New YorkSTAT213IntroductiontoAppliedStatistics 3hrs,3crLearning Outcomes: This course emphasizes statistical literacy and develops statisticalthinking. Statistical literacy is promoted throughout the text in the
FSU - COP - 4020
COP4020ProgrammingLanguagesPrologProf. Robert van EngelenOverview!Logic programming principles!Prolog1/27/11COP4020 Spring 20112Logic Programming!Logic programming is a form of declarative programming!A program is a collection of axiomsE
City College of San Francisco - MATH - 203
Hunter College of the City University of New YorkWomen and Gender Studies ProgramWGS 100 Section 051Introduction to Gender and Sexuality StudiesSpring 2012Instructor: Portia SeddonMondays/Wednesdays 5:35 PM 6:50 PMHW 406Office Hours: Wednesdays 4:
FSU - COP - 4020
COP4020ProgrammingLanguagesSemanticsProf. Robert van EngelenOverview!Static semantics!Dynamic semantics!Attribute grammars!Abstract syntax trees2/10/11COP4020 Spring 20112Static Semantics!Syntax concerns the form of a valid program, whi
FSU - COP - 4020
COP4020ProgrammingLanguagesSubroutines and Parameter PassingProf. Robert van EngelenOverview!Parameter passing modes!Subroutine closures as parameters!Special-purpose parameters!Function returns4/7/11COP4020 Spring 20112Parameters!!Fir
FSU - COP - 4020
COP4020ProgrammingLanguagesSyntaxProf. Robert van EngelenOverview!!!!!!Tokens and regular expressionsSyntax and context-free grammarsGrammar derivationsMore about parse treesTop-down and bottom-up parsingRecursive descent parsing2/17/11
University of Ottawa - ECON - 453
HW#1 Finance 463 Shapiro 9Student: _1. Historically, the primary motive for U.S. multinationals to produce abroad has been toA. lower costsB. respond more quickly to the marketplaceC. avoid trade barriersD. gain tax benefits2. The primary objective
University of Bristol - MATH - 11006
SOLUTIONS - ANALYSIS - MIDSESSIONAL EXAM JANUARY 2008This paper has two sections, A an B. Please use a separate answer book for each section.Section A has four short questions, ALL of which you should answer. Each of these questionsis worth 10 marks. S
University of Bristol - MATH - 11006
ANALYSIS - MIDSESSIONAL EXAM JANUARY 2008This paper has two sections, A an B. Please use a separate answer book for each section.Section A has four short questions, ALL of which you should answer. Each of these questionsis worth 10 marks. Section B has
University of Bristol - MATH - 11400
MATH11400Statistics 12008-09Homepage http:/www.maths.bris.ac.uk/maejc/stats1/intro.htmlProblem Sheet 9Remember: when online, you can access the Statistics 1 data sets from an R console by typingload(url(&quot;http:/www.maths.bris.ac.uk/maejc/stats1/stats
University of Bristol - MATH - 11009
Lecture notes for Mechanics 1Misha Rudnev1On principles. IntroductionIf one studies natural phenomena, it is important to try to understand the underlying principles. These wouldideally not only enable one to explain the range of familiar phenomena b
IBS DE - MBA - 2011
BhagavadGitaandManagementWorldManagementLessonsfromIndiaM.P.BhattathiriRetiredChiefTechnicalExaminerGovernmentofKeralaIndiaTableofContentsTableofContents.2Abstract.3Introduction.4ManagementguidelinesfromtheBhagavadGita. 4Oldtruthsinanewcontext.
Portland CC - ECONOMICS - 120
PRINCIPLES OFMACROECONOMICSP ART I Introduction to EconomicsTENTH EDITIONCASE FAIR OSTERPrepared by: Fernando Quijano &amp; Shelly TefftPART I Introduction to Economics 2012 Pearson Education, Inc. Publishing as Prentice Hall 2012 Pearson Education, I
Portland CC - ECONOMICS - 120
PRINCIPLES OFMACROECONOMICSPART I Introduction to EconomicsTENTH EDITIONCASE FAIR OSTERPrepared by: Fernando Quijano &amp; Shelly TefftPART I Introduction to Economics 2012 Pearson Education, Inc. Publishing as Prentice Hall 2012 Pearson Education, In
Portland CC - ECONOMICS - 120
PRINCIPLES OFMACROECONOMICSPART I Introduction to EconomicsTENTH EDITIONCASE FAIR OSTERPrepared by: Fernando Quijano &amp; Shelly TefftPART I Introduction to Economics 2012 Pearson Education, Inc. Publishing as Prentice Hall2 of 50 2012 Pearson Educa
Portland CC - ECONOMICS - 120
PRINCIPLES OFMACROECONOMICSPART I Introduction to EconomicsTENTH EDITIONCASE FAIR OSTERPrepared by: Fernando Quijano &amp; Shelly TefftPART I Introduction to Economics 2012 Pearson Education, Inc. Publishing as Prentice Hall 2012 Pearson Education, In
Portland CC - ECONOMICS - 120
PRINCIPLES OFMACROECONOMICSPART II Concepts and Problems in MacroeconomicsTENTH EDITIONCASE FAIR OSTERPrepared by: Fernando Quijano &amp; Shellyof 261 TefftPART II Concepts and Problems in Macroeconomics 2012 Pearson Education, Inc. Publishing as Pren
Portland CC - ECONOMICS - 120
PRINCIPLES OFMACROECONOMICSPART II Concepts and Problems in MacroeconomicsTENTH EDITIONCASE FAIR OSTERPrepared by: Fernando Quijano &amp; Shellyof 381 TefftPART II Concepts and Problems in Macroeconomics 2012 Pearson Education, Inc. Publishing as Pren
Portland CC - ECONOMICS - 120
PRINCIPLES OFMACROECONOMICSPART III The Core of Macroeconomic TheoryTENTH EDITIONCASE FAIR OSTERPrepared by: Fernando Quijano &amp; Shellyof 291 TefftPART III The Core of Macroeconomic Theory 2012 Pearson Education, Inc. Publishing as Prentice Hall2
Portland CC - ECONOMICS - 120
PRINCIPLES OFMACROECONOMICSPART III The Core of Macroeconomic TheoryTENTH EDITIONCASE FAIR OSTERPrepared by: Fernando Quijano &amp; Shellyof 421 TefftPART III The Core of Macroeconomic Theory 2012 Pearson Education, Inc. Publishing as Prentice Hall2
Portland CC - ECONOMICS - 120
PRINCIPLES OFMACROECONOMICSPART III The Core of Macroeconomic TheoryTENTH EDITIONCASE FAIR OSTERPrepared by: Fernando Quijano &amp; Shellyof 331 TefftPART III The Core of Macroeconomic Theory 2012 Pearson Education, Inc. Publishing as Prentice Hall2
Portland CC - ECONOMICS - 120
PRINCIPLES OFMACROECONOMICSPART III The Core of Macroeconomic TheoryTENTH EDITIONCASE FAIR OSTERPrepared by: Fernando Quijano &amp; Shellyof 251 TefftPART III The Core of Macroeconomic Theory 2012 Pearson Education, Inc. Publishing as Prentice Hall 2
Portland CC - ECONOMICS - 120
PRINCIPLES OFMACROECONOMICSPART III The Core of Macroeconomic TheoryTENTH EDITIONCASE FAIR OSTERPrepared by: Fernando Quijano &amp; Shellyof 391 TefftPART III The Core of Macroeconomic Theory 2012 Pearson Education, Inc. Publishing as Prentice Hall2
Portland CC - ECONOMICS - 120
PRINCIPLES OFMACROECONOMICSPART III The Core of Macroeconomic TheoryTENTH EDITIONCASE FAIR OSTERPrepared by: Fernando Quijano &amp; Shellyof 301 TefftPART III The Core of Macroeconomic Theory 2012 Pearson Education, Inc. Publishing as Prentice Hall 2
Portland CC - ECONOMICS - 120
PRINCIPLES OFMACROECONOMICSPART III The Core of Macroeconomic TheoryTENTH EDITIONCASE FAIR OSTERPrepared by: Fernando Quijano &amp; Shellyof 291 TefftPART III The Core of Macroeconomic Theory 2012 Pearson Education, Inc. Publishing as Prentice Hall2
Portland CC - ECONOMICS - 120
PRINCIPLES OFMACROECONOMICSPART IV Further Macroeconomics IssuesTENTH EDITIONCASE FAIR OSTERPrepared by: Fernando Quijano &amp; Shellyof 241 TefftPART IV Further Macroeconomics Issues 2012 Pearson Education, Inc. Publishing as Prentice Hall 2012 Pear
Pace - MBA - 672
#Amy Ray#A#m#y##R#a#y#n#0#8#T#l#
Pace - MBA - 672
Chapter 1NATURE AND SCOPE OF MANAGERIAL ECONOMICSQUESTIONS &amp; ANSWERSQ1.1Is it appropriate to view firms primarily as economic entities?Q1.1ANSWERYes. Firms represent a combination of people, physical assets, and information(financial, technical, m
Pace - MBA - 672
Chapter 2ECONOMIC OPTIMIZATIONQUESTIONS &amp; ANSWERSQ2.1In 2007, Chrysler Group said it would cut 13,000 jobs, close a major assembly plantand reduce production at other plants as part of a restructuring effort designed torestore profitability at the a
Pace - MBA - 672
Chapter 3DEMAND AND SUPPLYQUESTIONS AND ANSWERSQ3.1What key ingredients are necessary for the creation of economic demand?Q3.1ANSWERTwo basic conditions must be met before economic demand is created. First, theremust be value associated with acqui
Pace - MBA - 672
Chapter 4DEMAND ANALYSISQUESTIONS &amp; ANSWERSQ4.1&quot;The utility derived from consumption is intangible and unobservable. Therefore,the utility concept has no practical value. Discuss this statement.Q4.1ANSWERThe utility derived from consumption is int
Pace - MBA - 672
Chapter 5DEMAND ESTIMATIONQUESTIONS &amp; ANSWERSQ5.1Describe some of the limitations of market experiments.Q5.1ANSWERMarket experiments have several serious shortcomings. They are expensive andusually undertaken on a scale too small to allow high lev
Pace - MBA - 672
Chapter 6FORECASTINGQUESTIONS AND ANSWERSQ6.1Discuss some of the microeconomic and macroeconomic factors a firm must considerin its own sales and profit forecasting.Q6.1ANSWERThe better a company can assess future demand, the better it can plan it
Pace - MBA - 672
Chapter 7PRODUCTION ANALYSIS AND COMPENSATION POLICYQUESTIONS AND ANSWERSQ7.1Is use of least-cost input combinations a necessary condition for profitmaximization? Is it a sufficient condition? Explain.Q7.1ANSWEREmployment of least-cost input combi
Pace - MBA - 672
Chapter 8COST ANALYSIS AND ESTIMATIONQUESTIONS AND ANSWERSQ8.1What advantages or disadvantages do you see in using current costs for tax andstockholder reporting purposes?Q8.1ANSWERTheoretically, it would be preferable to use current costs for inc
Pace - MBA - 672
Chapter 9Linear ProgrammingQUESTIONS AND ANSWERSQ9.1Give some illustrations of managerial decision situations in which you think thelinear programming technique would be useful.Q9.1ANSWERLinear programming can be used for solving any type of const
Pace - MBA - 672
Chapter 10COMPETITIVE MARKETSQUESTIONS AND ANSWERSQ10.1Historically, the Regional Bell Operating Companies (RBOCs) had a monopoly onthe provision of local voice phone service. Regulation has now been eased to permitcompetition from Competitive Local
Pace - MBA - 672
Chapter 11PERFORMANCE AND STRATEGY IN COMPETITIVE MARKETSQUESTIONS AND ANSWERSQ11.1Your best income-earning opportunity appears to be an offer to work for a localdeveloper during the month of June and earn $2,000. However, before taking thejob, you
Pace - MBA - 672
Chapter 12MONOPOLY AND MONOPSONYQUESTIONS AND ANSWERSQ12.1Describe the monopoly market structure and provide some examples.Q12.1ANSWERMonopoly is a market structure characterized by a single seller of a highlydifferentiated product. Because a mono