- Questions & Answers
- Accounting
- Computer Science
- Automata or Computationing
- Computer Architecture
- Computer Graphics and Multimedia Applications
- Computer Network Security
- Data Structures
- Database Management System
- Design and Analysis of Algorithms
- Information Technology
- Linux Environment
- Networking
- Operating System
- Software Engineering
- Big Data
- Android
- iOS
- Matlab

- Economics
- Engineering
- Finance
- Thesis
- Management
- Science/Math
- Statistics
- Writing
- Dissertations
- Essays
- Programming
- Healthcare
- Law

- Log in | Sign up

Please finish before the deadline

Assignment 4 CMSPC 461: Programming Language Concepts Prof. Suman Saha, Spring 2023 Due: 11:59 PM, 17thMarch, 2023 Instructions: For this assignment, you need to submit your solution as one single file named as “code.rkt” to Grade- scope. If your file name is not ”code.rkt” or you define a function name that is different from what is specified in the question, Gradescope will not grade your assignment. Please clearly mark your answers using comments so that we can tell the correspondence between your code and questions. You may NOT use any of Schemes imperative features (assignment/loops) or anything else not covered in class. You should use Racket (https://racket-lang.org) for your implementation. For all problems, you can assume all inputs obey the types as specified in a problem. You will have access to some test cases when you submit your code to Gradescope. **(Kindly refer syllabus for late submission and academic integration policies.) We will check your code for plagiarism Question 1 (20 pt) You have opened a credit card company with great cashback benefits for college students. Your company provides yearly cashback to the customer based on how much they spend in a year. The cashback works as follows: • 1% for the first $500 spent • 1.5% for next $500 (i.e. between $500-$1000) • 2% for next $1000 (i.e. between $1000-$2000) • 3% for everything above $2000 Example: Let us say a student spent $100 using this particular credit card in a year, then the student will get $1 as cashback. Another student who spent $2500 will get $47.5 Implement the function cashBack that takes year spent as a parameter and computes the corresponding cashback amount. 1/2 Question 2 (20 pt) Define a recursive function merge, which takes two sorted lists of numbers, and returns one merged list where all numbers are sorted in decreasing order. Assume that all elements are sorted in decreasing order. For example: (merge '( 9 8) '( ) ) ; returns (9 8) (merge '( 7 5 2) '( 9 6 2 ) ) ; returns (9 7 6 5 2 2) (merge '( 2 2 2) '( 3 2 ) ) ; returns (3 2 2 2 2) Question 3 (20 points) Implement the function myGCD that recursively used Euclid’s algorithm to calculate the greatest common divisor of two numbers. Following is the algorithm: myGCD(x,y)= { x if y = 0 myGCD(y, remainder(x, y)) if y > 0 Scheme has a built-in remainder function, which you can use for this problem. Also, Scheme already has a built-in gcd function, which you shouldn’t use. Question 4 (20 points) Write a higher-order function ncall that takes three parameters: n, f, x; it returns x when n = 0, returns f(x) when n = 1, returns f(f(x)) when n = 2, etc. That is, it returns the result of calling fon x, for n times. For instance, invoking ncall with n = 4, a function that adds 1, and x = 2 should return 6. Another example in scheme: a call to (ncall 4 (lambda (x) (+ x 2)) 2) should return 10. In this case f(x)=x+2 (the lambda function) thus for x=2 we are calling f 4 times on x i.e. f(f(f(f(x))))=f(f(f(f(2))))=f(f(f(4)))=f(f(6)))=f(8)=10 Question 5 ( 20 points) Implement the following pseudo code myFunc that takes two non-negative parameters in scheme: begin myFunc(x,y): if x==0: return y+1 else if x>0 and y=0: return myFunc(x-1,1) else if x>0 and y>0: return myFunc(x-1,myFunc(x,y-1)) Note: This is a computationally intensive function. We will not evaluate this using larger numbers (i.e x > 4). Example: (myFunc 3 3) should return 61 2/2

Assignment 4 CMSPC 461: Programming Language Concepts Prof. Suman Saha, Spring 2023 Due: 11:59 PM, 17thMarch, 2023 Instructions: For this assignment, you need to submit your solution as one single file named as “code.rkt” to Grade- scope. If your file name is not ”code.rkt” or you define a function name that is different from what is specified in the question, Gradescope will not grade your assignment. Please clearly mark your answers using comments so that we can tell the correspondence between your code and questions. You may NOT use any of Schemes imperative features (assignment/loops) or anything else not covered in class. You should use Racket (https://racket-lang.org) for your implementation. For all problems, you can assume all inputs obey the types as specified in a problem. You will have access to some test cases when you submit your code to Gradescope. **(Kindly refer syllabus for late submission and academic integration policies.) We will check your code for plagiarism Question 1 (20 pt) You have opened a credit card company with great cashback benefits for college students. Your company provides yearly cashback to the customer based on how much they spend in a year. The cashback works as follows: • 1% for the first $500 spent • 1.5% for next $500 (i.e. between $500-$1000) • 2% for next $1000 (i.e. between $1000-$2000) • 3% for everything above $2000 Example: Let us say a student spent $100 using this particular credit card in a year, then the student will get $1 as cashback. Another student who spent $2500 will get $47.5 Implement the function cashBack that takes year spent as a parameter and computes the corresponding cashback amount. 1/2 Question 2 (20 pt) Define a recursive function merge, which takes two sorted lists of numbers, and returns one merged list where all numbers are sorted in decreasing order. Assume that all elements are sorted in decreasing order. For example: (merge '( 9 8) '( ) ) ; returns (9 8) (merge '( 7 5 2) '( 9 6 2 ) ) ; returns (9 7 6 5 2 2) (merge '( 2 2 2) '( 3 2 ) ) ; returns (3 2 2 2 2) Question 3 (20 points) Implement the function myGCD that recursively used Euclid’s algorithm to calculate the greatest common divisor of two numbers. Following is the algorithm: myGCD(x,y)= { x if y = 0 myGCD(y, remainder(x, y)) if y > 0 Scheme has a built-in remainder function, which you can use for this problem. Also, Scheme already has a built-in gcd function, which you shouldn’t use. Question 4 (20 points) Write a higher-order function ncall that takes three parameters: n, f, x; it returns x when n = 0, returns f(x) when n = 1, returns f(f(x)) when n = 2, etc. That is, it returns the result of calling fon x, for n times. For instance, invoking ncall with n = 4, a function that adds 1, and x = 2 should return 6. Another example in scheme: a call to (ncall 4 (lambda (x) (+ x 2)) 2) should return 10. In this case f(x)=x+2 (the lambda function) thus for x=2 we are calling f 4 times on x i.e. f(f(f(f(x))))=f(f(f(f(2))))=f(f(f(4)))=f(f(6)))=f(8)=10 Question 5 ( 20 points) Implement the following pseudo code myFunc that takes two non-negative parameters in scheme: begin myFunc(x,y): if x==0: return y+1 else if x>0 and y=0: return myFunc(x-1,1) else if x>0 and y>0: return myFunc(x-1,myFunc(x,y-1)) Note: This is a computationally intensive function. We will not evaluate this using larger numbers (i.e x > 4). Example: (myFunc 3 3) should return 61 2/2

Answered Same DayMar 14, 2023

SOLUTION.PDF## Answer To This Question Is Available To Download

- CST8390 Assignment #3 – Data Analysis and Visualization [30%]This assignment relates to the following Course Learning Requirements (CLR). CLR 9: Interpreting and reporting results, presenting...SolvedApr 04, 2024
- CST8390 Assignment #2 – Statistics and Data Analysis [25%]This assignment relates to the following Course Learning Requirements (CLR). CLR 4: Explain the fundamental concepts of data mining and...SolvedMar 06, 2024
- CST8390 Assignment #1 – Data Extraction, Preprocessing, and Analysis [20%]This assignment relates to the following Course Learning Requirements (CLR). CLR 6: Explain basic statistical...SolvedFeb 09, 2024
- 11/20 11/20 11/20 This is a special type of LED light, used even during the day. The Principal wants to find an alternative means of pressing so that as many consecutive light bulbs as possible can be...Dec 04, 2023
- CS 6320.001 - Natural Language Processing - F23Take Test: Homework 3CS 6320.001 - Natural Language Processing - F23 AssignmentsTake Test: Homework 3 Test...SolvedNov 06, 2023
- code in python Write a detailed annotated bibliography for at least 10 bibliographic (find 6 more )referencesfrom scholarly peer-reviewed academic journals about Convolutional Neural Networks...Oct 19, 2023
- Classifying Ships from Automatic Indentification System (AIS) Data — Data Mining (pantelis.github.io)This is the assignment. I need a google colab file that works and does every coding part that is...SolvedOct 06, 2023
- Hello,Its an assignment on Natural Language Processing, I couldn't find this field in Computer Science section. I am attaching the zip file here which has all the required files. In that zip file...SolvedSep 14, 2023
- Need help in Intelligent system analysis, someone needs to have a knowlede of Matlab Grader mathworks ,Sep 12, 2023
- Need help in Matlab Grader homework assignment unable to post the question because you need my login . there are scripts needs to run and then submit. The codes are there that you cannot change but...Sep 12, 2023

Copy and Paste Your Assignment Here

Copyright © 2024. All rights reserved.