Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Online Programming Languages Assignment

Write a function two-subsets in Scheme that takes a list L of positive integers (duplicates are possible, zero is not considered a positive integer) and some auxiliary parameters of your choice. The function two-subsets returns #t if the list L contains two subsets with equal sums of elements and with equal numbers of elements. Otherwise (if two subsets satisfying the condition above do not exist), the function returns #f. Assume that the list L contains at least two integers.

Note the difference from HW2: here, it is not required that the whole list be split into two subsets. In HW3, some elements of the list could be left out from the two subsets. Therefore, every list, which is a solution to HW2 is also be a solution to HW3. However, there are solutions to HW3 that are not solutions to HW2.

It is up to you to choose the auxiliary parameters that two-subsets takes. All auxiliary parameters must be numeric (not lists) and should have initial values set to zero. For example, if L is ‘(1 2 3) and if you decide to use two additional auxiliary parameters, then two-subsets must be called as follows:

(two-subsets '(1 2 3) 0 0)

If there are three auxiliary parameters, then the function must be called:

(two-subsets '(1 2 3) 0 0 0) and so on.

Note that the function must be called two-subsets. Other names will not be accepted. The list must precede the auxiliary parameters, which are initially set to zeroes.

There is no need to optimize your code. Try to come up with a working solution.

Examples (for the sake of illustration, two auxiliary parameters are used):

(two-subsets '(7 7) 0 0) returns #t. The two subsets are {7} and {7}.
(two-subsets '(7 7 1) 0 0) returns #t. The two subsets are {7} and {7}.
(two-subsets '(5 3 2 4) 0 0) returns #t. The two subsets are {2, 5} and {3, 4}.
(two-subsets '(5 3 21 2 4) 0 0) returns #t. The two subsets are {2, 5} and {3, 4}.
(two-subsets '(2 13 7 5 16 11) 0 0) returns #t. The two subsets are {7, 11} and
{5, 13}.
(two-subsets '(1 2 3 6 9) 0 0) returns #f.
(two-subsets '(10 4 7 102 36 6 17 54) 0 0) returns #f.

The whole solution must be packed in one recursive function two-subsets which must look as follows:
(define two-subsets (lambda ()
(cond
...
)))

In other words, you have to choose your auxiliary parameters and define a COND statement. Nested COND statements are allowed.
Inside COND, you can use ONLY the following constructs:
- null?
- cond
- car
- cdr
- else
- +
- =
- not
- and
- #t
- #f
- two-subsets
- the names of your parameters, such as list, sum, etc.
- numeric constants, such as 0, 1, 2, etc.
- parentheses

You cannot use a construct if it is not listed above. In other words, your code must define and use only one function, two-subsets, which must be defined using the template and the constructs listed above. The use of built-in functions is not allowed.

If your program uses a construct not on the list, then it is not a solution to the homework.

It is not allowed to bypass the homework requirements by packing several functions in one function definition using a numeric flag. In other words, for one value of the numeric flag the function does one thing and for other value of the flag the function does something else.

Here is an example of packing several function using a numeric flag as a second parameter:

(define two-subsets (lambda (list flag) (cond

((= flag 0) the function implements one type of functionality) ((= flag 1) the function implements a second type of functionality) (else the function implements a third type of functionality )

)))

Here, we have three functions (corresponding to flag values of 0, 1, and 2) packed in one COND statement. The flag is not related to the problem at hand and it used for the sole purpose of packing different functionalities in one COND statement. This is not allowed.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M92291530

Have any Question?


Related Questions in Programming Language

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Php amp session managment assignment -this assignment looks

PHP & SESSION MANAGMENT ASSIGNMENT - This assignment looks at using PHP for creating cookies and session management. Class Exercise - Web Project: Member Registration/Login This exercise will cover adding data connectivi ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Question 1 what is hadoop explaining hadoop 2 what is

Question: 1. What is Hadoop (Explaining Hadoop) ? 2. What is HDFS? 3. What is YARN (Yet Another Resource Negotiator)? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As