Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

University of British Columbia CPSC 110 Assignment 7 Phase 1

Beoordeling
-
Verkocht
-
Pagina's
10
Cijfer
A+
Geüpload op
15-10-2021
Geschreven in
2021/2022

University of British Columbia CPSC 110 Assignment 7 Phase 1

Instelling
Vak

Voorbeeld van de inhoud

;; Problem Set 7 Phase 1 Solution (THIS IS A TWO-PHASE PEER GRADED PROBLEM)


NOTE!

The following applies to each of the problems in phase one of the problem set:

You are required to design each function as a 2-one-of problem.
Provide signature, purpose, stub, cross-product of types table (filled
using your examples (see next paragraph)),
and examples. DO NOT IMPLEMENT THE FUNCTION.

You must include a properly formed cross-product of types comment table to
receive credit for each problem. You must render it as text in a comment
box. It should come after the purpose. You may find it helpful to draw your
cross-product on paper for your design and then use a tool like
http://www.asciiflow.com/#Draw to help you render it.

Use your examples to fill in the cross product of types table. Remember,
the content of the table does not need to be fully-formed code. See the
videos and the 2-One-Of practice problem solutions for examples of what is
acceptable.

After you have filled in the table, you should simplify it.
As part of the simplification, assign a number to each subclass that
produces different answers. Consult the Coursera practice problem solutions
for examples of this.

Problem 1:

Suppose you have rosters for players on two opposing tennis teams, and each
roster is ordered by team rank, with the best player listed first. When both
teams play, the best players of each team play one another,
and the second-best players play one another, and so on down the line. When
one team has more players than the other, the lowest ranking players on
the larger team do not play.

In this problem you will begin to design a function that takes two lists of
players and produces a list of matches, according to the approach described
above. DO NOT IMPLEMENT THE FUNCTION.

;; Player is String
;; interp. the name of a tennis player.
(define P0 "Maria")
(define P2 "Serena")

#;
(define (fn-for-player p)
(... p))



;; Roster is one of:
;; - empty
;; - (cons Player Roster)
;; interp. a team roster, ordered from best player to worst.
(define R0 empty)
(define R1 (list "Eugenie" "Gabriela" "Sharon" "Aleksandra"))
(define R2 (list "Maria" "Nadia" "Elena" "Anastasia" "Svetlana"))

#;
(define (fn-for-roster r)
(cond [(empty? r) (...)]
[else
(... (fn-for-player (first r))

, (fn-for-roster (rest r)))]))



(define-struct match (p1 p2))
;; Match is (make-match Player Player)
;; interp. a match between player p1 and player p2, with same team rank
(define M0 (make-match "Eugenie" "Maria"))
(define M1 (make-match "Gabriela" "Nadia"))

#;
(define (fn-for-match m)
(... (match-p1 m) (match-p2 m)))



;; ListOfMatch is one of:
;; - empty
;; - (cons Match ListOfMatch)
;; interp. a list of matches between one team and another.
(define LOM0 empty)
(define LOM1 (list (make-match "Eugenie" "Maria")
(make-match "Gabriela" "Nadia")))

#;
(define (fn-for-lom lom)
(cond [(empty? lom) (...)]
[else
(... (fn-for-match (first lom))
(fn-for-lom (rest lom)))]))


Solution:
;; Roster Roster -> ListOfMatch
;; given two team rosters produce a list of matches for all pairwise ranks.

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
15 oktober 2021
Aantal pagina's
10
Geschreven in
2021/2022
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

$3.49
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF


Ook beschikbaar in voordeelbundel

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
StuviaGuides West Virgina University
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
16178
Lid sinds
7 jaar
Aantal volgers
8362
Documenten
5972
Laatst verkocht
2 uur geleden
Accounting, Finance, Statistics, Computer Science, Nursing, Chemistry, Biology & More — A+ Test Banks, Study Guides & Solutions

As a Top 1st Seller on Stuvia and a nursing professional, my mission is to be your light in the dark during nursing school and beyond. I know how stressful exams and assignments can be, which is why I’ve created clear, reliable, and well-structured resources to help you succeed. I offer test banks, study guides, and solution manuals for all subjects — including specialized test banks and solution manuals for business books. My materials have already supported countless students in achieving higher grades, and I want them to be the guide that makes your academic journey easier too. I’m passionate, approachable, and always focused on quality — because I believe every student deserves the chance to excel.

Lees meer Lees minder
4.3

2292 beoordelingen

5
1569
4
305
3
183
2
74
1
161

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen