1. (p. 2-3.) Which of the following is NOT a reason for studying concepts of programming languages according to Sebesta?
a. Increased capacity to express ideas.
b. Improved background for choosing appropriate languages.
c. Increased ability to design new languages.
d. Increased ability to learn new languages.
2. (p. 5-6.) What programming language has dominated scientific computing over the past 50 years?
a. FORTRAN
b. ALGOL
c. SNOBOL
d. PL/I
3. (p. 6.) What programming language has dominated artificial intelligence over the past 50 years?
a. Prolog
b. Scheme
c. C
d. LISP
4. (p. 7) What meaning does Sebesta give to the language evaluation criterion readability?
a. The programming language presents no challenges to be read by a machine.
b. A program that is easily read is one in which programs are easily maintained.
c. The programming language has constructs that supported all areas of application.
d. The programming language has unique operators for each type and subtype.
5. (p 36)The first programmer was a. Ada Lovelace b. Konrad Zuse c. Grace Hopper d. John von Neumann
6. (p. 10 – 12) Select the best definition of orthogonality in the context of programming language criteria.
a. Orthogonality means that each operator is precisely defined for a set of valid operand types.
b. Orthogonality means that each operator is defined for all operand types.
c. Orthogonality means that each operator coerces the types of invalid operands to valid types.
d. Othogonality means that each operator is valid only for a single type.
7. (p. 11) What language used orthogonality as a primary design criterion?
a. ALGOL 68.
b. VAX assembly language
c. LISP
d. Modula-2
8. (p. 8) Which of the following is not a programming language evaluation criteria according to Sebesta?
a. syntax design
b. expressivity
c. restricted aliasing
d. type design
9. (p. 7) In what language is UNIX written?
a. B
b. C
c. C++
d. Java
10. (p. 19) What has been the strongest influence on programming language design over the past 50 years?
a. imperative programming methodology
b. the von Neumann architecture
c. BNF specification of programming language
d. the exponential growth of memory
11. (p. 22) Which language was first to support the three fundamental features of objectoriented programming?
a. Smalltalk
b. CLOS
c. SIMULA-67
d. C++
12. (p. 22) Which of the following is not a fundamental feature of an object-oriented programming language?
a. data abstraction b. inheritance
c. dynamic method binding
d. interface encapsulation
13. (p. 121-122) Given the grammar in the figure below, select the leftmost derivation of the string a+b*c. e → t e → e+t e → e-t t → f t → t*f t → t/f t → t%f f → (e) f → id Figure13.
a. Step Sentential Form 1 e 2 e+t 3 e+t*f 4 t+f*id(c) 5 f+id(b)*id(c) 6 id(a)*id(b)+Id(c)
b. Step Sentential Form 1 e 2 e+t 3 e+t*f 4 t+f*id(c) 5 t+id(b)*id(c) 6 f+id(b)*id(c) 7 id(a)+id(b)*id(c)
c. Step Sentential Form 1 e 2 e+t 3 e+t*f 4 t+t*f 5 f+t*f 6 id(a)+t*f 7 id(a)+f*f 8 id(a)+id(b)*f 9 id(a)+id(b)*id(c)
d. Step Sentential Form 1 e 2 e+t 3 t+t 4 f+t 5 id(a)+t 6 id(a)+t*f 7 id(a)+f*f 8 id(a)+id(b)*f 9 id(a)+id(b)*id(c)
14. (p 120) The first language to employ BNF was
a. Pascal
b. LISP
c. FORTRAN
d. Algol60
15. (Ch. 3. Lecture Notes) Given the grammar in the figure below, select the rightmost derivation of the string a+b*c. e → t e → e+t e → e-t t → f t → t*f t → t/f t → t%f f → (e) f → id Figure 15.
a. Step Sentential Form 1 e 2 e+t 3 e+t*f 4 t+f*id(c) 5 f+id(b)*id(c) 6 id(a)*id(b)+id(c) 5
b. Step Sentential Form 1 e 2 e+t 3 t+t 4 f+t 5 id(a)+t 6 id(a)+t*f 7 id(a)+f*f 8 id(a)+id(b)*f 9 id(a)+id(b)*id(c)
c. Step Sentential Form 1 e 2 e+t 3 e+t*f 4 t+t*f 5 f+t*f 6 id(a)+t*f 7 id(a)+f*f 8 id(a)+id(b)*f 9 id(a)+id(b)*id(c)
d. Step Sentential Form 1 e 2 e+t 3 e+t*f 4 e+t*id(c) 5 e+f*id(c) 6 e+id(b)*id(c) 7 t+id(b)*id(c) 8 f+id(b)*id(c) 9 id(a)+id(b)*id(c) 6
16. (Project p01 notes) What sequence of tokens is recognized by the regular expressions shown in the figure below given the input string +123.1?
[+|-]?[0-9]+\.[0-9]*([E|e][+|-]?[0- 9]+)? [+|-]?[0-9]+ \.[0-9]+ “.” [+|-] [0-9]+ Figure 16.
a. 3 tokens as follows + 123 .1
b. 1 token as follows +123.1
c. 4 tokens as follows + 123 . 1
d. 2 tokens as follows +123 .1
17. (p. 27) Which of the following is NOT a phase of compilation? a. lexical analysis b. semantic analysis c. syntax analysis d. static analysis 18. (p. 125 - 128) Which selection correctly orders the precedence of operators in the grammar in the figure below? Operators are ordered from left to right, highest to lowest. e → t e → e+t e → e-t t → f t → t*f t → t/f t → t%f f → (e) f → id Figure18.
a. () * / % + -
b. + * - / % ()
c. () * + / - %
d. + - * / % () 7
19. (p. 124 - 125) Which of the following grammars is NOT ambiguous?
a. E->E+E E->E*E E->(E) E->id
b. E->E+T | T T->T*F | F F->(E) | id
c. E->E A E | (E) | id A -> + | *
d. E->E+E | E*E | (E) | id
20. (p. 123 - 124) Select the parse tree for the sentence B * ( A + C ) in the grammar shown below.
a. e → t e → e*t t → f t → t+f f → (e) f → ID e t t f e e t f t t f * + ( ) ID(B) ID(A) ID(C) Figure 20a
b. e e * t t f f ( e ) ID(B) t t + f f ID(C) ID(A) Figure 20b
c. e e + t t f f ( e ) ID(B) t t * f f ID(C) ID(A) Figure 20c
d. e t t f e e t f t t f + * ( ) ID(B) ID(A) ID(C) Figure 20d
21. (p. 129 - 130) Select the table that correctly specifies the precedence and associativity of the operators given in the grammar shown below. Please note that the highest precedence is one (1). e → t e → e+t e → e-t t → f t → t*f t → t/f f → p f → p ^ f p → (e) p → u u → -u u → id Figure 21.
a.op name precedence associativity - unary minus 1 right () parenthesis 2 n/a ^ exponentiation 3 right * multiplication 4 left / division 4 left + addition 5 left - subtraction 5 left Table 21.
b. op name precedence associativity + addition 1 left - subtraction 1 left * multiplication 2 left / division 2 left ^ exponentiation 3 right () parenthesis 4 n/a - unary minus 5 right Table 21.
c. op name precedence associativity - unary minus 1 left () parenthesis 2 n/a ^ exponentiation 3 left * multiplication 4 right / division 4 right + addition 5 right - subtraction 5 right Table 21.
d. op name precedence associativity + addition 1 right - subtraction 1 right * multiplication 2 right / division 2 right ^ exponentiation 3 left () parenthesis 4 n/a - unary minus 5 left Table 21.
25. (p. 191 - 194) Which of the following is a limitation of the LL grammar class?
a. must be implemented by employing a recursive descent parser
b. left recursion must be eliminated
c. lexical analysis must be implemented using finite automata
d. must be implemented using a pushdown automaton
Please comment below, If you find any difficulty in understanding
Please Upvote, If you are impressed with the answer
Q #1
Answer : c (Increased ability to design new languages)
Q #2
Answer : a (FORTRAN - is a programming language which dominated scientific computing over 50 years)
Q #3
Answer : d (LISP - is a functional language which dominated Artificial Intelligence over 50 years)
Q #4
Answer : b ( A program that is easily read is one in which programs are easily maintained.)
Q #5
Answer : a ( Ada Lovelace - the first computer programmer)
Q #6
Answer : b (Orthogonality means that each operator is defined for all operand types.)
Q #7
Answer : c ( LISP - is a functional language)
Q #8
Answer : d (type design)
Q #9
Answer : b (C language)
Q #10
Answer : b (the von Neumann architecture )
Q #11
Answer : a (Smalltalk )
Q #12
Answer : a (data abstraction )
Q #13
Answer : d (Step Sentential Form 1 e 2 e+t 3 t+t 4 f+t 5 id(a)+t 6 id(a)+t*f 7 id(a)+f*f 8 id(a)+id(b)*f 9 id(a)+id(b)*id(c) )
Q #14
Answer : d (Algol60)
Q #15
Answer : c.
Q #16
Answer : a (3 tokens as follows + 123 .1)
Q #17
Answer : d (static analysis )
Q #18
Answer : a ( () * / % + - )
Q #25
Answer : b (left recursion must be eliminated )
1. (p. 2-3.) Which of the following is NOT a reason for studying concepts of programming...
4. Assume the following rules of associativity and precedence for expressions: Precedence Highest *, /, not +,-,&, mod - (unary) =,/=,<,<=,>=,> and or, xor Lowest Associativity Left to right Show the order of evaluation of the following expressions by parenthesizing all sub expressions and placing a superscript on the right parenthesis to indicate order. For example, for the expression a+b*c+d the order of evaluation would be represented as ((a+(b*c)1)2 +d)3 a * b - 1 + c a * (b...
The questions in this section are based on the grammar given as the following: prog -> assign | expr assign -> id = expr expr -> expr + term | expr - term | term term -> factor | factor * term factor -> ( expr ) | id | num id -> A | B | C num -> 0 | 1 | 2 | 3 (2a) What is the associativity of the * operator? (5 points) (2b) What...
The questions in this section are based on the grammar given as the following: prog -> assign | expr assign -> id = expr expr -> expr + term | expr - term | term term -> factor | factor * term factor -> ( expr ) | id | num id -> A | B | C num -> 0 | 1 | 2 | 3 (2a) What is the associativity of the * operator? (5 points) (2b) What...
Assume the following rules of associativity and precedence for expressions: Precedence Highest *, /, not +, -, &, mod - (unary) =, /=, <, <=, >=, > and Lowest or, xor Associativity Left to right Show the order of evaluation of the following expressions by parenthesizing all subexpressions and placing a superscript on the right parenthesis to indicate order. For example, for the expression a + b * c + d the order of evaluation would be represented as ((a...
Q#2 (6 points) Assume following precedence levels 1. parentheses 2. unary operators 3. **(exponentiation: if the language supports it) 6. Relational operators 7. Conditional operators 8. Boolean operators Determine the value of the following expressions, assuming a 5, b 2, c 4 and d-5. a. a5 Answer: Answer: Answer: c. b* a-b*c)
Question Set 2 1. Given the following grammar dactor>-> ( <expr> ) a) What is the associativity of each of the operators? What is precedence of the operators? Show a leftmost derivation and parse tree for the following sentence: b) c) A-A(B(C A)) d) Rewrite the BNF grammar above to give precedence over and force to be right associative.
Question Set 2 1. Given the following grammar dactor>-> ( <expr> ) a) What is the associativity of each of the operators? What is precedence of the operators? Show a leftmost derivation and parse tree for the following sentence: b) c) A-A(B(C A)) d) Rewrite the BNF grammar above to give precedence over and force to be right associative.
1. a. What language is generated by the CFG above? b. Derive the string ???????? using the grammar in part a. c. Draw the derivation tree for the derivation in part b. Derivation tree, operator precedence, operator associativity, left recursion, right recursion, prefix notation, postfix notation S→ Sbx X+ cxdcYd YaYb ab
1. Construct a DFSM to accept the language: L w E ab): w contains at least 3 as and no more than 3 bs) 2. Let E (acgt and let L be the language of strings consisting of repeated copies of the pairs at, ta, cg. ge. Construct both a DFSM to accept the language and a regular expression that represents the language. 3. Let ab. For a string w E , let w denote the string w with the...
(20 pts) To understand the value of recursion in a programming language: implement the binary search algorithm first as a recursive function and again using a conditional loop. Your program should create an array of characters holding the letters ‘A’ – ‘Z’ and find the index in the array where the letter ‘K’ is stored. You may use any programming language that supports recursion. (5pts) Define syntax and semantics and give an example. (5pts) Why is it important for a...