Question: 1) Design and implement -in Python- a function to generate all length-n strings of 0s and 1s, for a given non negative integer n. Your

1) Design and implement -in Python- a function to generate all length-n strings of 0s and

1s, for a given non negative integer n. Your function must have n as the only parameter and

must return a list containing all length-n strings of 0s and 1s. Test your function with a few

different values of n. Submit only the .py fie including your function.

Here is what I have so far for this part:

1) Design and implement -in Python- a function to generate all length-n

2) Design and implement a method for the stack class -discussed in class- that outputs

-prints- the items in the stack from bottom to top with the condition that after the execution

of this method the content of the stack is equal to the content of the stack before the method

was called. You may assume that the items in the stack are printable. You cannot use any

variables of any aggregate data types such as lists or sets or dictionaries etc.

3) Design a method for the linked implementation of a list -discussed in class- so that the

insert method maintains the list in order. You may assume that the list will include integers

only.

def String(n): result = [] for i in range(0, 2 ** n): resultlist = [] for xin range(0, n): resultlist.append('') resultlisti = i VE while(resultlisti): if(resultlisti & 1): resultlist[y] = '1' y = y + 1 resultlisti = resultlisti >> 1 resultliststr = 1 for i in resultlist: resultliststr += i result.append(resultliststr) return result class Stack: def String(n): result = [] for i in range(0, 2 ** n): resultlist = [] for xin range(0, n): resultlist.append('') resultlisti = i VE while(resultlisti): if(resultlisti & 1): resultlist[y] = '1' y = y + 1 resultlisti = resultlisti >> 1 resultliststr = 1 for i in resultlist: resultliststr += i result.append(resultliststr) return result class Stack

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!