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 Fall Final Exam 2 Exam Review Questions with Verified Solutions | 100% Pass Guaranteed | Graded A+

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

CSCI-2041: Advanced Programming Principles 2024 – 2025 CSCI-2041 Fall Final Exam 2 Exam Review Questions with Verified Solutions | 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
6
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

  • csci 2041 final exam

Content preview

CSCI-2041: Advanced Programming
Principles 2024 – 2025 CSCI-2041 Fall
Final Exam 2 Exam Review Questions
with Verified Solutions | 100% Pass
Guaranteed | Graded A+




Administrator
[COMPANY NAME] [Company address]

, Name: ID#: X500: @umn.edu A


CS 2041: Practice Final SOLUTION
Fall 2018
University of Minnesota
Exam period: 20 minutes
Points available: 40

Background: OCaml’s standard library has muta- 1 # let table = Hashtbl.create 20;;
ble, polymorphic hash table implementation which 2 # Hashtbl.add table "Goku" 8001;;
maps keys to values in the Hashtbl module which 3 # Hashtbl.add table "Krillin" 1770;;
4# Hashtbl.add table "Piccolo" 3500;;
is demonstrated in a REPL nearby. Like the tree
5 # Hashtbl.add table "Vegeta" 18000;;
maps we created, Hashtbl provides higher-order 6
func- tions for operating on the key/value # let kpower = Hashtbl.find_opt table "Krillin";;
7
associations in the map. val kpower : int option = Some 1770
8
9 # let gpower = Hashtbl.find_opt table "Gohan";;
Problem 1 (5 pts): Write a function print_all 10 val gpower : int option = None
which prints out all key/value bindings in a hash ta- 11
12 # #use "hash_funcs.ml";;
ble of string/integers. Use the higher-order function 13 val print_all : (string, int) Hashtbl.t -> unit = <fu
Hashtbl.iter func tbl where func is passed keys 14 val total_power : (’a, int) Hashtbl.t -> int = <fun>

and values from the hash table and returns unit. It 15

is demonstrated in the REPL session. 16 # print_all table;; (* demo print_all *)
17 Krillin -> 1770
18 Vegeta -> 18000
SOLUTION 19 Piccolo -> 3500
20 Goku -> 8001
1 let print_all table = 21 - : unit = ()
2 let print k v = 22
3 printf "%s -> %d\n" k v 23 # total_power table;; (* demo total_power *)
4 in 24 - : int = 31271
5 Hashtbl.iter print table;
6 ;;




Problem 2 (5 pts): Write a function SOLUTION
total_power which totals the values stored in a 1 let total_power table =
2 let total k v sum =
hash table with integer values. Use the higher-order 3 sum+v
func- tion Hashtbl.fold func tbl initial where 4 in
func is passed keys, values, and a running total. 5 Hashtbl.fold total table 0
It is demonstrated in the REPL session. 6 ;;




Problem 3 (5 pts): A5’s Calculon drew a distinction between a lambda expression and a closure.
Describe the similarities and differences between these two things.
SOLUTION: The parser produces lambda expressions which are part of the parse tree. They have a pa-
rameter and a body of code to execute. The evaluator produces a Closure which is a variant of data_t
like IntDat and BoolDat. Closure’s also have a parameter and code to evaluate when applied but add a
variable map which tracks all variables that were defined at the time the Closure was created.
2A

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