100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CSCI-2041: Advanced Programming Principles 2024 – 2025 CSCI-2041 Final Exam Practice Questions with and Answers | 100% Pass Guaranteed | Graded A+ | $14.99
Add to cart

Exam (elaborations)

CSCI-2041: Advanced Programming Principles 2024 – 2025 CSCI-2041 Final Exam Practice Questions with and Answers | 100% Pass Guaranteed | Graded A+ |

 16 views  0 purchase

CSCI-2041: Advanced Programming Principles 2024 – 2025 CSCI-2041 Final Exam Practice Questions with and Answers | 100% Pass Guaranteed | Graded A+ |

Preview 2 out of 5  pages

  • October 19, 2024
  • 5
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • csci 2041 final exam
All documents for this subject (11)
avatar-seller
YourAssignmentHandlers01
CSCI-2041: Advanced Programming
Principles 2024 – 2025 CSCI-2041
Final Exam Practice Questions with
and Answers | 100% Pass Guaranteed
| Graded A+ |




Administrator
[COMPANY NAME] [Company address]

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


CS 2041: Practice Final
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 7 # let kpower = Hashtbl.find_opt table "Krillin";;
associations in the map. 8 val kpower : int option = Some 1770
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
Write your code for print_all here.
19 Piccolo -> 3500
20 Goku -> 8001
21 - : unit = ()
22
23 # total_power table;; (* demo total_power *)
24 - : int = 31271




Problem 2 (5 pts): Write a function Write your code for total_power here.
total_power which totals the values stored in a
hash table with integer values. Use the higher-order
func- tion Hashtbl.fold func tbl initial where
func is passed keys, values, and a running total. It
is demonstrated in the REPL session.




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.




2A

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller YourAssignmentHandlers01. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $14.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

52928 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$14.99
  • (0)
Add to cart
Added