cs 115 Introduction to Computer Science 1代写

滑铁卢大学cs115代写

Assignment 5
Due date: Wednesday, February 16th, 5:00 pm Eastern Time
Coverage: Module 06
Files to submit: a05q1.rkt, a05q2.rkt, a05q3.rkt
Assignment Guidelines
Language Level
– Beginning Student with List Abbreviations
General Expectations
– Remember to use defined constants and helper functions where appropriate.
– Follow the full design recipe and the Coding Style document up to and including Section $3.6 .2 .$
Allowable Racket Functions and Special Forms
– define, and, or, not, cond, else, check-expect, check-within, equal?
– Any type predicate such as number? or boolean?
– Any functions on numbers found in Section $2.6$ of the Racket documentation
– Any functions on characters found in Section_2.11_of_the_Racket_decumentation
– Any functions on strings found in Section_2.12. of the_Racket_documentation
– The function symbol=?
– The list functions and values cons, first, second, third, rest, empty, empty?, and list
– You must not use boolean=?
Other Information
– All test data for correctness will always meet the stated assumptions for consumed values.

Problem 1.

Question 1: Prime Factor Decomposition|
A positive integer can be written uniquely as a product of prime factors. We call this prime factor decomposition. For example, $24=2^{3} \cdot 3$, and $42=2 \cdot 3 \cdot 7$.
We will create a new data type, a special kind of list, to represent this kind of data:
1 ;; A PFD, or prime factor decomposition, is a (listof Nat)
2 ;; Requires: the elements are in ascending order
3 ;; the elements are prime numbers.
Include this data definition in your file.
Instead of storing exponents, we will just list the prime factors, with repetition. So $24=2^{3} \cdot 3=2 \cdot 2 \cdot 2 \cdot 3$ will be represented as ( $l$ ist 2223 ), and $42=2 \cdot 3 \cdot 7$ will be
represented as ( list $2.37$ ). The number 1 is the result of the Empty Product, so its prime factor decomposition is empty. A prime number has only one prime factor, so the PFD of a
prime will be a list that contains that value only.
Write a function pfd. It consumes a positive integer $n$, and produces the PFD that represents $n$. For example,
$>(p f d 12)$
$\begin{aligned} 1 & ; \text { A PFD, or } \\ 2 & ; ; \text { Requires: } \\ 3 & ; ; \end{aligned}$
Include this data definition
Instead of storing exponents,
represented as ( list 237
prime will be a list that contair
Write a function pfd. it consu
$>($ pfd 12$)$
(list 2 2 3)
(list 223 )
$>(p f d$ 1)
empty
> (pfd 8191) ; a Mersenne prime:
(list 8191)
You can generate the solution list in the correct order using an appropriate recursion on natural numbers. It should not be necessary to sort.

Problem 2.

Question 2: Scrabble Sorting
Sometimes when sorting, we want to sort using a property of each value, instead of the value itself. Then we have to consider what to do for values for which the property is equal. Which should we prefer? criterion is unchanged. previously came after “was”, and now comes before.

Sorting puts them in order by score. But since IT came before ONE, and they have equal scores, IT still comes before ONE. Similarly, OF and DEAN have equal scores, and remain in the same order.
Think about modelling your solution upon the insertion sort algorithm shown in Lesson 06.4, and writing your own helper function to compare two words. If a word appears multiple times in the input list, it should appear the same number of times in the result.
You may use your own solution to the Scrabble scoring problem from Assignment 4. If you prefer, you may use the posted solution, once it is available.
Submit your solution in the file a05q2. rkt.

Problem 3.

We are going to think about lists of length exactly 3, representing an author, title, and number of pages. Each such list we will call a Book. Because Book is a compound, we’ll include a constructor and and selectors for it:

cs 115 Introduction to Computer Science 1代写请认准UpriviateTA

计算机代写cs115代写请认准UpriviateTA. UpriviateTA为您的留学生涯保驾护航。

CS 115 – Introduction to Computer Science 1
School of Computer Science
University of Waterloo

Where to Begin

Welcome to CS 115!The Winter 2022 term offering of this course will be delivered through UW Online: online.cs.uwaterloo.ca.

Directions on how to access this site can be found on Learn.

Course Philosophy

CS 115 has been designed with the diverse interests, backgrounds, and goals of students always in mind. As we are aware of the varied ways in which this material might be of use in the future, we have included concepts that are beautiful and universal. The focus of the course is foundational concepts in computer science (rather than the mechanics of programming) and ways of thinking about computation (rather than solving tasks in a rote fashion). Students will learn skills that are applicable to new languages and environments, not just those used in the course. Because of the fundamental nature of the concepts taught in CS 115, the course can serve both students whose primary interest in computers is in their use in their chosen areas of study and students intending to minor in CS.

Communication

For questions related to course content, contact an instructor or an ISA. The best place to ask questions is on the edX discussion forum, email or during office hours. For questions about marking, contact the ISAs first, who will consult with the ISC or Instructor if necessary. Contact information for ISAs and Instructors can be found on edX.
If you are confused or need more information about course structure or enrolment, please contact Barbara Daly in MSTeams or through E-mail.

Instructional Support Coordinator (ISC)

Barbara

Barbara Daly
Email: [email protected]
MS Teams: Barbara Daly


FAQ

I have registered during the first week of classes after the first day of classes, what do I do?

Please do not contact your instructor.

When you register for a course you will not be added to Learn or our class roster until the next day. On that day, log into Learn and read the announcement from Monday May 10.

I have registered for the course and a due date has already passed, what do I do?

Please do not contact your instructor.

When you register for a course you will not be added to Learn or our class roster until the next day. Once your registration has been sent to the ISC she will contact you regarding the missed work and how to get caught up in the course.

I have dropped down from CS135 and have missed a significant amount of content.

Please do not contact your instructor.

When you register for a course you will not be added to Learn or our class roster until the next day. On that day, Barbara Daly will send you a detailed email regarding missed work and what expectations we will have of you. Logging into Learn at this time and reading the announcements will be the first step as you await Barbara’s email.