COS 301 Spring 2023 Quiz 1 Study Guide

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What year did Alan Turing first propose the Turing Machine and why?

1936 was a big year for Computer Science.

What year did Alonzo Church first propose the lambda-calculus and why?

1946 was also a big year. That was the year ENIAC was unveiled.

Who were Alan Turing and Alonzo Church and what were some of their contributions to Computer Science?

Alan Turing as a PhD student of Alonzo Church. Alan Turing developed the Turing Machine and Alonzo Church developed the lambda-calculus to prove that there were some things that are not computable. They later proved the two approaches were equivalent in their power to express computation.

What goes in an activation record?

An activation record holds information like local variables, the program counter, the stack pointer, and other state information necessary for a function invocation.

When is an activation record created?

An activation record is created each time a function is called.

When is an activation record deleted?

An activation record is deleted when a function returns.

What notation did John Backus develop and what was one of its first uses?

Backus developed Backus-Naur Format (BNF) notation, which was used in the development of Algol 60.

What do Prolog and Python have in common?

Both Python and Prolog run on virtual machine implementations. Python's virtual machine is internal to the interpreter. Prolog's virtual machine is called WAM (Warren Abstract Machine).

What idea did both John von Neumann and Alan Turing contribute to?

Both von Neumann and Turing contributed to the idea of a stored-program computer.

Who invented C++? C? Standard ML? Prolog? Python? Java?

C++ was invented by Bjourne Stroustrup. C was created by Dennis Ritchie. Standard ML was primarily designed by Robin Milner. Prolog was designed by Alain Colmerauer and Philippe Roussel with the assistance of Robert Kowalski. Python was created by Guido van Rossum. Java was the work of Green team and James Gosling.

When does an item in the heap get created?

Data on the heap is created at runtime.

Construct a leftmost derivation for the infix expression 4 + (a - b) * x using the grammar in section 2.9.3, proving that this infix expression is in L(G) for the given grammar.

E ⇒ T Rest E ⇒ F RestT Rest E ⇒ 4 RestT Rest E ⇒ 4 Rest E ⇒ 4 + T Rest E ⇒ 4 + F RestT Rest E ⇒ 4 + (E) RestT Rest E ⇒ 4 + (T Rest E)RestT Rest E ⇒ 4 + (F RestT Rest E) RestT Rest E ⇒ 4 + (a RestT Rest E)RestT Rest E ⇒ 4 + (a Rest E) RestT Rest E ⇒ 4 + (a − T Rest E) RestT Rest E ⇒ 4 + (a − F Rest E) RestT Rest E ⇒ 4 + (a − b Rest E) ⇒ 4 + (a − b) RestT Rest E ⇒ 4 + (a − b) ∗ F RestT Rest E ⇒ 4 + (a − b) ∗ x RestT Rest E ⇒ 4 + (a − b) ∗ x Rest E ⇒ 4 + (a − b) ∗ x

Why are Eckert and Mauchly famous?

Eckert and Mauchly designed and built ENIAC.

What does the parse tree look like for the rightmost derivation of (5 * x) + y?

Exactly like the parse tree for any other derivation of (5 * x) + y. There is only one parse tree for the expression given this grammar.

Define a regular expression so that negative and non-negative integers can both be specified as tokens of the infix expression language.

In order to define both negative and positive numbers, we can use the choice operator. letter.letter* + digit.digit* + '-'.digit.digit* '+' + '-' + '*' + '/' + '(' + ')'

What is the primary difference between the functional and imperative models?

In the imperative model, the primary operation revolves around updating memory (the assignment statement). In the functional model, the primary operation is function application.

For each step in figure 2.6, is there a shift or reduce operation being performed? If it is a reduce operation, then what production is being reduced? If it is a shift operation, what token is being shifted onto the stack?

In the parsing of 5 * 4 + 3, the following are shift and reduce operations: step A initial condition, step B shift, step C reduce by rule 5, step D reduce by rule 4, step E shift, step F shift, step G reduce by rule 5, step H reduce by rule 3, step I reduce by rule 2, step J shift, step K shift, step L reduce by rule 5, step M reduce by rule 4, step N reduce by rule 1, step O finished parsing with dot on right side and E on top of stack, so pop and complete with success.

What do Standard ML and Prolog's histories have in common?

Standard ML and Prolog were both designed as languages for automated theorem proving first. Then they became general purpose programming languages later.

What language or languages is Standard ML based on?

Standard ML is influenced by Lisp, Pascal, and Algol.

What are some examples of functional languages?

Standard ML, Lisp, Haskell, Scheme

Immutable data is data that cannot be changed or created. The presence of immutable data simplifies the conceptual model of programming. Does the imperative or functional model emphasize immutable data?

The functional model emphasizes immutable data. However, some imperative languages have some immutable data as well. For instance, Java strings are immutable.

What are the origins of the three major computational models that early computer scientists developed?

The origins of the three models are the Turing Machine, the lambda-calculus, and propositional and predicate logic.

Why are the history of Mathematics and Computer Science so closely tied together?

The problems in Mathematics were growing complex enough that many mathematicians were developing models and languages for expressing their algorithms. This was one of the driving factors in the development of computers and Computer Science as a discipline.

What does the programmer do when writing in Prolog?

The programmer provides a database of facts and predicates that tell Prolog about a problem. In Prolog, the programmer describes the problem instead of programming the solution.

What are the three divisions of data memory called?

The runtime stack, global memory, and the heap.

Construct a leftmost derivation for the prefix expression +4 * -abx.

This is a leftmost derivation of the expression. E ⇒ +E E ⇒ +4E ⇒ +4 ∗ E E ⇒ +4 ∗ −EEE ⇒ +4 ∗ −aEE ⇒ +4∗ − abE ⇒ +4 ∗ −abx

Construct a derivation for the infix expression 4 + (a - b) * x.

This is a leftmost derivation of the expression. There are other derivations that would be correct as well. E ⇒ E + T ⇒ T + T ⇒ F + T ⇒ 4 + T ⇒ 4 + T ∗ F ⇒ 4 + F ∗ F ⇒ 4 + (E) ∗ F ⇒ 4 + (E − T ) ∗ F ⇒ 4 + (T − T ) ∗ F ⇒ 4 + (F − T ) ∗ F ⇒ 4 + (a − T ) ∗ F ⇒ 4 + (a − F) ∗ F ⇒ 4 + (a − b) ∗ F ⇒ 4 + (a − b) ∗ x

Construct a rightmost derivation for the expression x * y + z.

This is a rightmost derivation of the expression. There is only one correct rightmost derivation. E ⇒ E +T ⇒ E + F ⇒ E +z ⇒ T +z ⇒ T ∗ F +z ⇒ T ∗ y +z ⇒ F ∗ y +z ⇒ x ∗ y +z

Consider the expression (6 + 5) * 4. What are the contents of the pushdown automaton's stack as the expression is parsed using a bottom-up parser? Show the stack after each shift and each reduce operation.

To complete this problem, it is best to do a rightmost derivation of (6 + 5) * 4 first. Once that derivation is complete, you go through the derivation backwards. The difference in each step of the derivation tells you whether you shift or reduce. Here is the result: E ⇒ T ⇒ T ∗ F ⇒ T ∗ 4 ⇒ F ∗ 4 ⇒ (E) ∗ 4 ⇒ (E + T ) ∗ 4 ⇒ (E + F) ∗ 4 ⇒ (E + 5) ∗ 4 ⇒ (T + 5) ∗ 4 ⇒ (F + 5) ∗ 4 ⇒ (6 + 5) ∗ 4 We get the following operations from this. Stack contents have the top on the right up to the dot. Everything after the dot has not been read yet. We shift when we must move through the tokens to get to the next place we are reducing. Each step in the reverse derivation provides the reduce operations. Since there are seven tokens there should be seven shift operations. 1. Initially: . (6 + 5) * 4 2. Shift: ( . 6 + 5) * 4 3. Shift:(6. + 5 ) ∗ 4 4. Reduce by rule 5: ( F . + 5 ) ∗ 4 5. Reduce by rule 4:(T. + 5 ) ∗ 4 6. Reduce by rule 2:(E. + 5 ) ∗ 4 7. Shift: ( E + .5) ∗ 4 8. Shift: ( E + 5.) ∗ 4 9. Reduce by rule 5: ( E + F.) ∗ 4 10. Reduce by rule 4: ( E + T.) ∗ 4 11. Shift: ( E + T). ∗ 4 12. Reduce by rule 1:(E). ∗ 4 13. Reduce by rule 6: F . ∗ 4 14. Reduce by rule 4: T . ∗ 4 15. Shift: T ∗ . 4 16. Shift: T ∗ 4 . 17. Reduce by rule 5: T ∗ F . 18. Reduce by rule 3: T . 19. Reduce by rule 2: E .

What is the primary goal of imperative, object-oriented programming?

To update memory by updating variables and/or objects as the program executes. The primary operation is memory updates.

How many programs can you write in a logic programming language like Prolog?

You never write a program in Prolog. You write a database of rules in Prolog that tell the single Prolog program (depth first search) how to proceed.


संबंधित स्टडी सेट्स

Chapter 10 Launchpad Practice Quiz Intro to Psych

View Set

Psychiatric-Mental Health Practice Exam HESI

View Set

Interpersonal Communication Skills Ch 3

View Set

Pediatric Nursing - Cardiac Disorders

View Set

Ethics Theme 3 - Teleological Ethics

View Set