Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement (in python) a scheme predicate called set-equal that takes as input two lists representing sets and returns true if the lists represent the same

Implement (in python) a scheme predicate called set-equal that takes as input two lists representing sets and returns true if the lists represent the same set and false otherwise. Thus, the call:

set-equal ( [ 1, [2, [3, 4]]] [ [[4 ,3], 2], 1]]]] ) should return True

and the call

set-equal ( [ 1, [2, [3, 4]]], [ [4, 3 ,2], 1]]]] ) should return False.

Note that here sets can themselves contain sets.Hint: first, remember that set-equality is not primitive. To say that two sets A and B are equal is equivalent to saying that A is a subset of B and B is a subset of A. So first define a procedure setSubset roughly in this way: setSubset (A,B)

if the first element of A is not a set, then find out if it is a member of B (use Pythons build-in in operator)if the first element of A is a set, then find out if there is an identical set within B Thus, if the first element of B is a set, determine whether every element of the first element of A is in the first element of B And if the first element of B is not a set, continue on look for the first element of A in the remainder of B

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions