100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

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

Rating
-
Sold
-
Pages
7
Grade
A+
Uploaded on
19-10-2024
Written in
2024/2025

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










Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
October 19, 2024
Number of pages
7
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

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/

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
YourAssignmentHandlers01 Udemy
View profile
Follow You need to be logged in order to follow users or courses
Sold
26
Member since
1 year
Number of followers
1
Documents
292
Last sold
2 months ago
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!

Read more Read less
2.0

9 reviews

5
1
4
0
3
2
2
1
1
5

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions