ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 22 May 2017 My Price 8.00

The cartesian-product

Here are 3 problems about Racket Programming Language:

Question #1:

Define and test a procedure memv that takes an element and a list and returns the first cdr whose car is eqv? to the element, or #f if the element is absent from the list.

>  (memv 'a '(a b c))

'(a b c)

>  (memv 'b '(a ? c))

#f

> (memv 'b '(a b c b))

'(b c b)

 

Question #2:

The cartesian-product is defined over a list of sets (again simply lists that by our agreed upon convention don't have duplicates). The result is a list of tuples (i.e. lists). Each tuple has in the first position an element of the first set, in the second position an element of the second set, etc. The output list should contains all such combinations. The exact order of your tuples may differ; this is acceptable.

>  (cartesian-product '((5 4) (3 2 1)))

((5 3) (5 2) (5 1) (4 3) (4 2) (4 1))

 

Question #3:

The procedure powerset takes a list and returns the power set of the elements in the list. The exact order of your lists may differ; this is acceptable.

>  (powerset '(3 2 1))

'((3 2 1) (3 2) (3 1) (3) (2 1) (2) (1) ())

>  (powerset '())

'(( ))

Answers

(11)
Status NEW Posted 22 May 2017 06:05 AM My Price 8.00

-----------

Not Rated(0)