Question: Python pls (Also, the function should be one iterative function and one recursive function Create a function taker_a and taker_b. This function should be one

Python pls (Also, the function should be one iterative function and one recursive function

Create a function taker_a and taker_b. This function should be one iterative function and one recursive function. This function has a two-argument, which linked lists from class lunatic. This function returns an element of lists, start from a. The function starts to return one element from a and one element from b. If there's one list becomes empty, then it will just return the remaining elements of other lists. (The function output result should be the same if its correct functions)

For example

Python pls (Also, the function should be one iterative function and one

a1 = list_transfer(['a','b','c','d','e','f','g'])

b1 = list_transfer(['w','x','y','z'])

print(taker_b(a1,b1))

output = a->w->b->x->c->y->d->z->e->f->g->None

a2 = list_transfer(['a','b','c','d'])

b2 = list_transfer(['w','x','y',1])

print(taker_a(a2,b2))

output = a->w->b->x->c->y->d->1->None

a3 = list_transfer([])

b3 = list_transfer([])

print(taker_a(a3,b3))

print(taker_b(a3,b3))

output = None

class lunatic: count = 0 def __init__(self,val,taker=None): self.val = val self.taker = taker lunatic.count += 1

def list_transfer(b): if b == []: return None up = rear = lunatic(l[0]) for i in b[1:]: rear.taker = lunatic(i) rear = rear.taker return up

def str_transfer(a): k = '' while a != None: k += str(a.val)+'->' a = a.taker return k + 'None'

#WRITE FUNCTION ITERATIVE def taker_a (a : lunatic, b : lunatic): while True: break #WRITE FUNCTION Recursive def taker_b (a : lunatic, b : lunatic): pass

class lunatic: count = 0 def __init_(self,val, taker=None): self.val = val self.taker taker lunatic.count += 1 def list_transfer(b): if b == []: return None up = rear = lunatic(1[0]) for i in b[1:]: rear.taker = lunatic(i) rear = rear.taker return up I! def str_transfer(a): k while a != None: k += str(a.val)+'-> a = a.taker return k + 'None #WRITE FUNCTION ITERATIVE def taker_a (a : lunatic, b: lunatic): while True: break #WRITE FUNCTION Recursive def taker_b (a : lunatic, b: lunatic): pass

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!