Need in 3 days. Must be in in R5RS, Write a function has-subtarget?

Виконано Опубліковано %project.relative_time Оплачується при отриманні
Виконано Оплачується при отриманні

1.) The source code must be in R5RS. Any other scheme or lisp dialect.

2.) 1 - 2 page description of your algorithm and its complexity as an ACII text document, MS Word document, or a PDF file.

Write a function has-subtarget? that takes a list of three or more positive integers, duplicates are possible and 0 is not included, and returns true (#t) if there are two non-empty sublists whose sums are both equal to a value in the list that is not part of either sublist. False (#f), if no two such sublists exist. The values of the sublist do not need to be contiguous in the original list.

Not all values need to be used. In other words, values can belong to either sublist or neither sublist. They cannot, however, belong to both sublists at the same time.

The list passed to has-target-num? is flat, i.e., it does not itself contain sublists. It is up to you to choose the auxiliary parameters that has-target-num? takes. Auxiliary parameters are parameters used to help find the solution and are scalar. In other words, they hold single values not a collection of values. The list parameter is mandatory is not an auxiliary parameter. All auxiliary parameters must be numeric and must be initialized to zero when the function is called.

There may be more than two values that have two sublists or more than two sublists that equal some value. In both cases a single true (#t) should be returned.

Example Calls:

If the list is ‘(1 2 3) and you decide to use two additional auxiliary parameters, has-subtarget? should be called as follows.

(has-subtarget? ‘(1 2 3) 0 0)

If three auxiliary parameters are used then the call should be:

(has-subtarget? ‘(1 2 3) 0 0 0)

Test Calls:

‘ (2 1 3 9 4 8) returns true because {2 4 3} and {1 8} both sum to 9.

‘(1 1 2 2) returns true because {1 1} and {2} both sum to 2, however…

‘(1 1 2) returns false because there are no two sublists have sums that are a target in the list.

‘(5 6 7) returns false because no two sublists have sums that are a target in the list.

'(17 35 1 26 24 12 25 40 33 31) returns false.

‘(6 21 84 66 100 53 73 38 29 81 66 69 54 8 94) returns true.

The whole code solution must be packed into one recursive function, has-subtarget?, which must look as follows

(define has-subtarget? (lambda (<list L followed by your auxiliary parameters of your choice>)

(cond

)))

Техніка

ID Проекту: #18237308

Про проект

1 заявка Дистанційний проект Остання активність 5 роки(ів) тому

Доручено:

prefectworld

i can assist you with Must be in R5RS, and i can Write a function has sub-target, I am an expert, I have effectively executed numerous designing errands than you can ever envision both on consultant and off consultant. Більше

$75 USD за 2 дні(-в)
(12 відгуків(-и))
4.3