Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. The Scheme statement, (map (lambda (x)(* x x)) \'(9 8 7 6)) evaluates to the

ID: 3675408 • Letter: 1

Question

1. The Scheme statement,

(map (lambda (x)(* x x)) '(9 8 7 6))

evaluates to the list,

'(81 64 49 36)

           

2.The Scheme constructor, cons, is used when you already have a list and you want to add one new element. Cons takes two arguments, an element and a list (in that order), and returns a new list whose car is the first argument and whose cdr is the second.

           

3.Because of the run time typing, Python's run-time must work harder than Java's. For example, when evaluating the expression a+b, the python run-time must first inspect the objects a and b to find out their type, which is not known at compile time. It then invokes the appropriate addition operation, which may be an overloaded user-defined method. Java, on the other hand, can perform an efficient integer or floating point addition but requires variable declarations for a and b, and Java does not allow overloading of the + operator for instances of user-defined classes.

           

4.The Python statement,

map(lambda x: x * x, [9, 8, 7, 6])

evaluates to the list,

[81, 64, 49, 36]           

5.A program written in Python will always take more time to execute that a logically equivalent program written in Java or C++.

6.Python has dynamic typing and binding, and everything in Python is an object. As in Smalltalk, Python classes themselves are objects. In Python 3.5, built-in types can be used as base classes for extension by the user.

           

7.Python lists may be used as keys in dictionaries.

8.Python includes three types of built-in data structures: lists, immutable lists called tuples, and hash tables called dictionaries.

9.Python tuples are derived from (inherit) from Python lists.

10.Python tuples may be used as keys in dictionaries.

11.Some programming languages were designed to enable optimal runtime performance on particular hardware.

12.Some programming languages were designed to prevent programmer control of dynamic heap memory allocation.

13.Formal descriptions of language syntax often do not include descriptions of the lowest-level syntactic units. Such small units are called lexemes, and the description of lexemes can be given separate from the syntactic description of the language. In class, flex or lex were used to describe lexemes.

14.Backus-Naur Form (BNF) is used to describe the syntax of programming languages with context-free grammars.

Select all of the following input streams that are syntactically correct based on the following BNF:

<S> ::=<A><B><C>

<A> ::= a<A> | a

<B> ::= b<B> | b

<C> ::= c<C> | c

options:

           

15.aaabccccccc

16.aabbccaa

17.abc

18.bbb

           

19.Some programming languages were designed with the goal of being easily embedded as scripting languages in other programs/applications.          

20.Some programming languages were designed to be terse i.e. express the most semantic information in the fewest characters of input.     

Select all of the following input streams that are syntactically correct based on the following BNF:

<S> ::=<A><B><C>

<A> ::= a<A> | a

<B> ::= b<B> | b

<C> ::= c<C> | c

21. aaabccccccc

22. aabbccaa

23. abc

24. bbb

Explanation / Answer

Your point number 14 and 15 are not clear. Please let me know if anything else you need on this.