Question: This assignment has to do with converting between sets, bit strings, and shortest latticepaths as we have been studying in class. Sets are represented by
This assignment has to do with converting between sets, bit strings, and shortest latticepaths as we have been studying in class. Sets are represented by lists and are subsets of n The nbit strings will be lists of length n where each entry is a or eg for a bit string Lattice paths of length n will be lists of length n whereeach entry is either the string right or the string upegrightuprightrightupYou will write three functions, one from each of the following groups Sets & Bit Stringsa Create a function setToBit whose inputs are an integer n and a subset A nso n is the cardinality of the larger set that A is a subset ofThe function will return an nbit string that corresponds to the subset A Forinstance, if n and A then your function will return the bitstring note that the s are in positions and whichcorrespond to the elements of Ab Create a function bitToSet whose input is a bit string B The function willreturn a subset ie list that corresponds to the bit string B For instance, ifB then your function will return the subset Sets & Lattice Pathsa Create a function setToLattice whose inputs are an integer n and a subsetA nso n is the cardinality of the larger set that A is a subsetof The function will return a lattice path of length n that corresponds to thesubset A For instance, if n and A then your function will returnthe bit string rightupuprightuprightuprightnote that the upentries are in positions and which correspond to the elements of Ab Create a function latticeToSet whose input is a lattice path P The function willreturn a subset ie list that corresponds to the lattice path P For instance, ifP upuprightrightuprightrightup then your function will returnthe subset Bit Strings & Lattice Pathsa Create a function bitToLattice whose input is a bit string B The functionwill return a lattice path that corresponds to the bit string B For instance, ifB then your function will return the listuprightuprightrightuprightupup
b Create a function latticeToBit whose input is a lattice path P The functionwill return a bit string that corresponds to the lattice path P For instance, ifP upuprightrightuprightrightup then your function will returnthe bit string Make sure your functions are well documented. You should have oneline comments usingthe single line comments with # written in complete sentences that describe what each lineof code does.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
