100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Examen

CSCI-2041: Advanced Programming Principles 2024 – 2025 CSCI-2041 Midterm 2 Exam Review Questions with Correct Answers | 100% Pass Guaranteed | Graded A+ |

Puntuación
-
Vendido
-
Páginas
7
Grado
A+
Subido en
19-10-2024
Escrito en
2024/2025

CSCI-2041: Advanced Programming Principles 2024 – 2025 CSCI-2041 Midterm 2 Exam Review Questions with Correct Answers | 100% Pass Guaranteed | Graded A+ |

Institución
Grado









Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
Grado

Información del documento

Subido en
19 de octubre de 2024
Número de páginas
7
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

Vista previa del contenido

CSCI-2041: Advanced Programming Principles 2024 –
2025 CSCI-2041 Midterm 2 Exam Review Questions with
Correct Answers | 100% Pass Guaranteed | Graded A+ |




Administrator
[COMPANY NAME] [Company address]

, # Midterm 2 Practice Questions

*CSci 2041: Advanced Programming Principles, Fall 2015*

These are some examples of questions similar to those that will
appear on the second midterm.


##1. Program representation and analysis
+ Recall our data types for representing programs and the associated
analysis functions:

```
type expr =
Const of int | Bool of bool
| Add of expr*expr | Mul of expr*expr
| If of expr*expr*expr | Gt of expr*expr | Eq of expr*expr
| Set of string*expr | Name of string
| While of expr*expr | Seq of expr list
| Print of expr | Readint
type result = IntR of int | BoolR of bool | UnitR
type expType = IntT | BoolT | UnitT
type state = (string*result) list
type tyEnv = (string*expType) list
val typeOf : expr -> tyEnv -> expType = <fun>
val eval : expr -> state -> (result * state) = <fun>
```

+ Suppose we were to extend the above representation to allow integer
array values in the program (internally represented as lists of
integers), by adding the following variants to expr:
```
type expr = ...
| NewArr of expr*expr (* NewArr(n,v) makes a new array of n ints set to v *)
| ArrGet of expr*expr (* ArrGet(a,i) returns the item at index i of array a *)
| ArrSet of expr*expr*expr (* ArrSet(a,i,v) returns a copy of a with index i
set to value v *)
| ArrLen of expr (* ArrLen(a) returns the length of array a *)
```
What other types would we need to change in order to evaluate and
typecheck expressions with these features?

+ Recall that a "type judgement" is a rule for assigning a type to an
expression given the types of its subexpressions, e.g:
+ ` e1 : Int , e2 : Int `&rArr; `Add(e1,e2) : Int`
+ `Const i : int`
+ `n : t, e : t` &rArr; `Set(n,t) : Unit`
Assuming that array values have type `Array`, what are the type
judgements for each of the new expression variants above?

+ Using these judgements, write the match clauses for each of the new
variants in `typeOf`.

+ Complete the match clasues in `eval` for each of the new variants in
`typeOf`. We'll make accessing an array at an out of bounds index
result in a runtime exception (e.g. in this situation `failwith
"array index out of bounds"` would be an acceptable result of evaluation)


+ Explain the difference between *static* and *dynamic* program
analyses, and give an example of each.

##2. Induction
Consider the following tree data type:



https://www.coursehero.com/file/13271013/midterm2-practicemd/
$14.99
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada


Documento también disponible en un lote

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
YourAssignmentHandlers01 Udemy
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
26
Miembro desde
1 año
Número de seguidores
1
Documentos
292
Última venta
2 meses hace
Your Assignment Handlers

Unlock Your Academic Potential with Your Assignment Handlers! Are you struggling with academic tasks and need expert assistance? We've got you covered! At Your Assignment Handlers, we specialize in providing top-notch academic support to help you achieve your goals. Here's what we offer: Essays From persuasive to analytical essays, we craft well-researched and compelling papers tailored to your needs. Research Papers Dive deep into any topic with our expertly written research papers, ensuring thorough analysis and accurate citations. Reports Whether it's a business report or a lab report, we deliver clear, concise, and professional documents. Theses and Dissertations Let us help you with one of the most crucial projects of your academic journey. We provide comprehensive support from proposal to final submission. Annotated Bibliographies We create detailed annotated bibliographies that highlight the relevance and quality of your sources. Critical Reviews Get insightful and critical evaluations of literature, articles, or any subject matter. Proposals Need a compelling proposal? We craft persuasive and well-structured proposals that stand out. Additional Services: Assignments: We handle all subjects and levels with expertise. Online Classes Support: Assistance with coursework, participation, and more. Exams Preparation: Get ready to ace your exams with our tailored study guides and tips. Study Guides &amp; Research: Comprehensive guides and research materials to enhance your understanding. Why Choose Us? Quality: High-quality, plagiarism-free content. Timeliness: Always on time, because deadlines matter. Expertise: Skilled professionals with experience in various academic fields. Customization: Personalized services to meet your unique needs. Special Offers: Explore our Payhip shop for exclusive discounts and special offers on our services. Don't miss out on the chance to get the academic support you need at a discounted price! Visit Us Today: Google Your Assignment Handlers Get in Touch: We're here to assist you every step of the way! Whether you have questions or need guidance, feel free to reach out. Your academic success is our top priority. E Mail Us : HYBRIDGRADES101 AT G Mail Your Success, Our Mission. Let's Achieve Academic Excellence Together!

Lee mas Leer menos
2.0

9 reseñas

5
1
4
0
3
2
2
1
1
5

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes