Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I don't know how to start this program and it seems as though I need to make 3 different sets of bits and check what

I don't know how to start this program and it seems as though I need to make 3 different sets of bits and check what exactly is similar or different to them.

(In Python Please)(Python 3 BSsets.py)

Create 3 sets of bit strings and determine the relations between.

import sys

''' provided strings are immutable, but lists are mutable replace(s,i,c) turns string s into a list, replaces s[i] with c, then turns the list back into a string and returns it ''' def replace(s,i,c): s=list(s) s[i]=c s = ''.join(s) return s

''' return a string with n c-s ''' def stringn(n,c):

''' given bit string bs of size n, return the next (boolean increment) e.g. '00000' -> '00001' '01011' -> '01100' '11111' -> '00000' ''' def next(bs,n):

''' return the set of all length n>=2 bitstrings that start with '11' or end with '1' ''' def s11x1(n):

''' return the set of all length n>=2 bitstrings that start with '11' ''' def s11x(n):

''' return the set of all length n>=2 bitstrings that end with '1' ''' def sx1(n):

''' provided ''' if __name__ == "__main__": # sets of bit strings size n n = int(sys.argv[1]) if n<2: print( 'argument must be>= 2' ) sys.exit() s3 = s11x1(n) print( 'len(s3) =', len(s3) ) s2 = s11x(n) print( 'len(s2) =', len(s2) ) s1 = sx1(n) print( 'len(s1) =', len(s1) ) print( 'len(s1&s2):', len(s1&s2) ) print( 's3 == s2|s1:', s3 == s2|s1 ) print( 'len(s3) == len(s2)+len(s1)-len(s2&s1):', len(s3) == len(s2)+len(s1)-len(s2&s1) )

(This is all I was given to complete the code. If it helps its part of "1.14 Sets of Bit Strings" in Zybooks)

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_2

Step: 3

blur-text-image_3

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

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

Students also viewed these Databases questions