Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

CPSC110 problem set 1 solution

Rating
-
Sold
-
Pages
4
Uploaded on
05-01-2024
Written in
2023/2024

complete solution for problem set 1

Content preview

(@problem 1)
;;
;; Write the BSL expression that most clearly represents the following
;; arithme>c expression:
;;
;; 3^2 + 6 * (6 - 10) / 3
;;
;; which equals 1
;;
;; There is a single BSL expression that both produces the correct result,
;; and most closely matches the structure of the equa>on given above.
;; Although 1 is an expression that evaluates to 1, that is not the
;; correct answer, because it doesn't show the structure of the expression
;; above.
;;
(+ (sqr 3)(/ (* 6 (- 6 10)) 3))


(@problem 2)
;;
;; Given the defini>ons below (LOWER, UPPER and foo),
;; write the step-by-step evalua>on of the following expression:
;;
;; (foo (* 3 4) (+ 0 2))
;;
;; Be sure to show every intermediate evalua>on step, including the original
;; expression and the final result. The steps should NOT be in comments.
;;
;; Stepping ques>ons like this one have only one correct answer. The goal
;; of this problem is to assess whether you have learned the exact BSL step
;; by step evalua>on rules; not whether you can figure out the final
;; result of an expression.
;;

(define LOWER 10)
(define UPPER 20)

(define (foo x y)
(if (and (> x LOWER) (< x UPPER))
(- x (* y 2))
(+ x (* y 3))))

(foo (* 3 4) (+ 0 2))
(foo 12 (+ 0 2))

Document information

Uploaded on
January 5, 2024
Number of pages
4
Written in
2023/2024
Type
OTHER
Person
Unknown
CA$12.18
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
skye3

Get to know the seller

Seller avatar
skye3 UBC
View profile
Follow You need to be logged in order to follow users or courses
Sold
8
Member since
2 year
Number of followers
1
Documents
9
Last sold
2 weeks ago

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

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