Python Question (write programs)

Sigchi4life
Category:
Computer Science
Price: $5 USD

Question description

Requirement:

1. You cannot import any module

2. The programs must be solved by Recursion 


Question:

1. Write program

1.Write a program that asks the user for a binary string that also contains x's. A binary string is a sequence of 1's and 0's. Your program should display all possible binary strings where the x's can be replaced with either 1's or 0's. 

a.Examples

  1. Enter a binary string: 1011 

    1011
    
  2. Enter a binary string: 10x0 

    1000
    1010
    
  3. Enter a binary string: xx0x

    0000
    0001
    0100
    0101
    1000
    1001
    1100
    1101


2. Write program

1.Write a program that is called funa() that implements the following function (part a&b below)

2.Write one more program that also is called funa() that implements the same function from last question but only makes one recursive call per recursion.  

a.

funa(0)=1

funa(1)=2

funa(2)=3

funa(3)=4

funa(n)= funa(n−1)+ funa(n−3)+ funa(n−4) 

b. Examples

  1. Enter a value for n: 3 

    funa(3) = 4

  2. Enter a value for n: 5 

    funa(5) = 12

  3. Enter a value for n: 15 
       funa(15) = 1428 

Studypool has helped 1,244,100 students
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1831 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors