Test 1 CS 4337.002 - Programming Language Paradigms - S22

Ace your homework & exams now with Quizwiz!

[Sebesta04P] Consider the following parse tree.

"ab" is a handle

[Lisp] What is the parenthesis notation for this cons cell structur

((BOWS ARROWS) (FLOWERS CHOCOLATES))

[Lisp] What is the parenthesis notation for this cons cell structure?

((BRAIN SURGEONS) NEVER (SAY OOPS))

[Lisp] Given the following statement. (setf line '(roses are red)) What is the result of the following expression? (cons (last line) line)

((red) roses are red)

[Lisp] What is the result of:(mapcar #'try '(1 3 5)) with the Lisp function try provided:(defun try (n) (+ 2 n))

(3 5 7)

[Lisp] What is the parenthesis notation for this cons cell structure?

(RED GREEN BLUE)

[Lisp] What is CADR of the following expression? ((BLUE CUBE) (RED PYRAMID))

(RED PYRAMID)

[Lisp] What is the result of:(list 'cons t nil)

(cons t nil)

[Lisp] What is Lisp lambda function to subtract 7 from a number (a parameter n)?

(lambda (n) (- n 7))

[Lisp] What is the result of: (mapcar #'zerop '(2 0 -5))

(nil t nil)

[Lisp] Given(setf line '(roses are red)) What is the result of: (reverse line)

(red are roses)

[Lisp] Given the following Lisp statement run (setf line '(roses are red)) What is the result of the following statement? (list (first line) (last line))

(roses (red))

[Lisp] Given the following statement (setf line '(roses are red)) What is the result of: (append line (list (first line)))

(roses are red roses)

[Lisp] What is the result of the following expression?(apply #'cons '(t nil))

(t)

[Sebesta03] Compute the weakest precondition for each of the following assignment statement and postcondition: x = 2 * y + x - 1 {x > 11}

2 * y + x > 12

[Lisp] What is the result of the following Lisp function? (length '((OPEN) (THE POD BAY DOORS) HAL)

3

[Lisp] What is the result of: (+ 1 2)

3

[Sebesta04] Consider the following parse tree, as discussed in the class. There is/are ___ simple phrases.

3

[Lisp] What is the result of the following Lisp function? (length '((1 2 3) (4 5 6) (7 8 9) (10 11 12)))

4

[Lisp] What is the result of the following Lisp function? (length '((ONE) FOR ALL (AND (TWO (FOR ME)))))

4

[Lisp] What is the result of the following Lisp function? (length '(1 2 3 4))

4

[Lisp] What is the result of the following Lisp function?(length '(1 2 3 4))

4

[Lisp] What is the result of the following expression? (+ (- 5 2) 3)

6

[Sebesta04] Consider the following parse tree, as discussed in the class. There is/are ___ phrases.

6

[Sebesta03] The following grammar is ambiguous. <expr> → <expr> <op> <expr> | const <op> → * | + Which one of the following grammar is equivalent to this grammar but not ambiguous

<expr> → <expr> + <term> | <term> <term> → <term> * const | cons

[Sebesta01-02] _____ is invented to describe the syntax of Algol 58

BNF

[Sebesta01] According to the author. Consider the list of potential benefits of studying concepts of programming languages. One of the benefits would be argued as follows: Certain kinds of program bugs can be found and fixed only by a programmer who knows some related implementation details. Another benefit of understanding implementation issues is that it allows us to visualize how a computer executes various language constructs. In some cases, some knowledge of implementation issues provides hints about the relative efficiency of alternative constructs that may be chosen for a program. For example, programmers who know little about the complexity of the implementation of subprogram calls often do not realize that a small subprogram that is frequently called can be a highly inefficient design choice. This is an example of ____

Better understanding of the significance of implementation.

[Sebesta01] According to the author. Consider the list of potential benefits of studying concepts of programming languages. One of the benefits would be argued as follows: Many contemporary programming languages are large and complex. Accordingly, it is uncommon for a programmer to be familiar with and use all of the features of a language he or she uses. By studying the concepts of programming languages, programmers can learn about previously unknown and unused parts of the languages they already use and begin to use those features. This is an example of ____

Better use of languages that are already known.

[Sebesta01-02] ___ was developed as a systems programming language for the development of UNIX.

C

[Sebesta01-02] The major commercial language for the period 1960 through the 1990s was ____.

Cobol

[Sebesta01] According to the author. Select the best answer. Consider a binary tree that stores integer data in its nodes. Such a binary tree would usually be implemented in a language that does not support pointers and dynamic storage management with a heap, such as Fortran 77, as three parallel integer arrays, where two of the integers are used as subscripts to specify offspring nodes. In C++ and Java, these trees can be implemented by using an abstraction of a tree node in the form of a simple class with two pointers (or references) and an integer. The naturalness of the latter representation makes it much easier to write a program that uses binary trees in these languages than to write one in Fortran 77. This is about _____.

Data Abstraction

[Sebesta01] According to the author. Select the best answer. One of the complicating characteristics of a programming language is ____- that is, having more than one way to accomplish a particular operation.

Feature multiplicity

[Sebesta01] According to the author. Consider the list of potential benefits of studying concepts of programming languages. One of the benefits would be argued as follows: It might be argued that learning the capabilities of other languages does not help a programmer who is forced to use a language that lacks those capabilities. That argument does not hold up, however, because often, language constructs can be simulated in other languages that do not support those constructs directly. For example, a C programmer who had learned the structure and uses of associative arrays in Perl (Wall et al., 2000) might design structures that simulate associative arrays in that language. In other words, the study of programming language concepts builds an appreciation for valuable language features and constructs and encourages programmers to use them, even when the language they are using does not directly support such features and constructs. This is an example of ____

Increased capacity to express ideas.

[Sebesta01-02] ____ is a set of technologies by Sun/Oracle that allows programmers to develop and deploy Web services for a company.

Java EE

[Sebesta04P] The original LR algorithm was designed by ____ in 1960's.

Knuth

[Sebesta03] Leftmost derivation is used in ____ parsing.

LL

[Sebesta03] A(n) _____ is the lowest level syntactic unit of a language (e.g., +, *, 123, ...).

Lexeme

[Sebesta01-02] One of the Functional programming languages is _______

Lisp

[Sebesta01-02] The major AI language for the period 1960 through the 1990s was ______.

Lisp

[Sebesta03] Context-Free Grammars is developed by ____ in the mid-1950s.

Noam Chomsky

[Sebesta04P] Most compilers use efficient parsers for implementing syntax analyzers for programming languages, working on subclasses of unambiguous grammars, and having complexity ___.

O(n)

[Sebesta04P] For CFG, parsers that work for all unambiguous grammars have complexity ____ in gerenal.

O(n3)

[Sebesta01-02] This ______ feature or criteria is about a relatively small set of primitive constructs which can be combined in a relatively small number of ways, and every possible combination is legal.

Orthogonality

[Sebesta01] According to the author. Select the best answer. Some believe that functional languages offer a good combination of simplicity and _____. A functional language, such as LISP, is one in which computations are made primarily by applying functions to given parameters

Orthogonality

[Sebesta01] According to the author. Select the best answer. _____ in a programming language means that a relatively small set of primitive constructs can be combined in a relatively small number of ways to build the control and data structures of the language. Furthermore, every possible combination of primitives is legal and meaningful.

Orthogonality

[Sebesta01] According to the author. Select the best answer. Consider data types. Suppose a language has four primitive data types (integer, float, double, and character) and two type operators (array and pointer). If the two type operators can be applied to themselves and the four primitive data types, a large number of data structures can be defined. This is about ____.

Orthogonality

[Sebesta01] According to the author. Select the best answer. ____ is closely related to simplicity: The more it is for the design of a language, the fewer exceptions the language rules require. Fewer exceptions mean a higher degree of regularity in the design, which makes the language easier to learn, read, and understand. Anyone who has learned a significant part of the English language can testify to the difficulty of learning its many rule exceptions. This is about ____.

Orthogonality

[Sebesta01-02] ______ is the most popular server-side programming language

PHP

[Sebesta01-02] One of the logic programming languages is ______

Prolog

[Sebesta01-02] ___ is the evaluation criteria for the ease with which programs can be understood

Readability

[Sebesta01] According to the author. Consider the list of some important criteria of a programming language. Select the best answer. Simplicity is primarily concerned for this criterion (or criteria).

Readability, Writability, Reliability

[Sebesta01] According to the author. Consider the list of some important criteria of a programming language. Select the best answer. Syntax Design is primarily concerned for this criterion (or criteria)

Readability, Writability, Reliability

[Sebesta01-02] _____ is for the evaluation criteria for the conformance to specifications (i.e., performs to its specifications).

Reliability

[Sebesta01] According to the author. Consider the list of some important criteria of a programming language. Select the best answer. Exception Handling is primarily concerned for this criterion (or criteria).

Reliability

[Sebesta01] According to the author. Consider the list of some important criteria of a programming language. Select the best answer. Type Checking is primarily concerned for this criterion (or criteria).

Reliability

[Sebesta01] According to the author. Consider the list of some important criteria of a programming language. Select the best answer. Restricted Aliasing is primarily concerned for this criterion (or criteria).

Reliability

[Sebesta01] According to the author. Select the best answer. The design of Java requires checks of the types of nearly all variables and expressions at compile time. This virtually eliminates type errors at run time in Java programs. This is about _____.

Reliability

[Lisp] Using the list: ( ( A B) (C D) (E F) )Match the result for each Lisp expression.For example, "car" is for the result of: (car ( ( A B) (C D) (E F) ) )Note. Some of these are implementation-dependent (e.g., CADADDR may not work in your Lisp interpreter).

See picture

[Sebesta03] A(n) ____ is a sentential form that has only terminal symbols

Sentence

[Sebesta03] A(n) _____ is a string of characters over some alphabet.

Sentence

[Sebesta01] According to the author. Consider diverse and various domains of programming languages and applications. The UNIX operating system is written almost entirely in C, which has made it relatively easy to port, or move, to different machines. Some of the characteristics of C make it a good choice for this programming domain. It is low level, execution efficient, and does not burden the user with many safety restrictions. This is an example of ____.

Systems Programming or Programming Language(s)

[Sebesta03] A(n) _____ is a category of lexemes (e.g., identifier)

Token

[Sebesta01-02] _____ is for the evaluation criteria for the ease with which a language can be used to create programs

Writability

[Sebesta01] According to the author. Select the best answer. _____ is a measure of how easily a language can be used to create programs for a chosen problem domain.

Writability

[Sebesta01] According to the author. Consider the list of some important criteria of a programming language. Select the best answer. Support for Abstraction is primarily concerned for this criterion (or criteria).

Writability, Reliability

[Sebesta01] According to the author. Consider the list of some important criteria of a programming language. Select the best answer. Expressivity is primarily concerned for this criterion (or criteria)

Writability, Reliability

[Sebesta09] Consider the following program (as we discussed in the class). Matching Problem. assuming static scoping is used.Assuming Static Scoping is used, for each variable name in sub2, find the program unit where it is declared. (For a,x,y,w)

a | sub2 x | main y | sub1 w | none (not-visible)

[Lisp] Given the following statement: (setf line '(roses are red)) What is the result of: (nth 1 line)

are

[Sebesta03] Compute the weakest precondition for each of the following assignment statement and postcondition: a = 2 * (b - 1) - 1 {a > 0}

b > 3 / 2

[Sebesta03] Compute the weakest precondition for each of the following assignment statement and postcondition: b = (c + 10) / 3 {b > 6}

c > 8

[Sebesta09] Matching Problem. Consider the following program (as we discussed in the class). Given the following calling sequences and assuming that dynamic scoping is used, what variables are visible during execution of the last function called? Select a correct choice of each visible variable and the name of the function in which it was defined. Calling Sequence: main calls fun1; fun1 calls fun2; fun2 calls fun3.

e, f in fun3

[Sebesta05] Variables can be characterized by six-tuple attributes. Which is not one of these attributes?

generation

[Sebesta04P] LR parsers use two parsing tables: action and ____.

goto

[Sebesta04] Which one of the following choices is CORRECT? β is the ___ of the right sentential form γ=αβw if and only if S =>*rm α A w =>rm α β w.

handle

[Sebesta04P] Some grammars that fail the pairwise disjointness test often can be modified to pass it, using ____.

left-factoring

[Lisp] What is the result of the following expression: (eql 3 3.0)

nil

[Lisp] What is the result of the following expression? (eval nil)

nil

[Lisp] What is the result of the following expression? (eval (list 'eval nil))

nil

[Sebesta03] In BNF, a rule has a left-hand side (LHS), which is/are _____

nonterminal

[Sebesta04] Which one of the following choices is CORRECT? β is a(n) ___ of the right sentential form γ if and only if S =>* γ = α1 A α2 =>+ α1 β α2

phrase

[Sebesta04P] Every parser for a context-free programming language is a ____, because this is a recognizer for a context-free language.

push-down automaton

[Sebesta04P] _____ parser is an LL parser that is implemented by writing code directly from the grammar of the source language. EBNF is ideal as the basis for this type of parsers and much easier and simpler to implement.

recursive-descent

[Sebesta05] ___ of a variable is the range of statements over which it is visible.

scope

[Sebesta05] ____ is when storage bindings are created for variables when their declaration statements are elaborated (for example, all local not-static variables in C subprograms and all Java methods). Note: A declaration is elaborated when the executable code associated with it is executed.

stack-dynamic

[Sebesta04P] The top symbol on the LR parse stack is always a ____ symbol that represents all of the information in the parse stack that is relevant to the parsing process.

state

[Sebesta05] Declarations, either explicit or implicit, provide a means of specifying the ____ binding of variables to types.

static

[Lisp] What is the result of the following expression: (equal '(a b) '(a b))

t

[Sebesta05] ____ are locations that can store different type values at different times.

unions

[Sebesta03] Consider the following analysis of a program, as discussed in the class.{...} a = b + 1 {a > 1} Looking at post-condition of { a > 1} after execution of (a=b+1). Its weakest precondition is ___

{b > 0}


Related study sets

Final HMS 381- Hospitality Operations

View Set

Ch. 10- Accounting for Long-Term Liabilities

View Set

managerial accounting ch 5, 5A, 6

View Set

Mahatma Gandhi: Pilgrim of Peace

View Set