Question: please use carry bits 2. Write a function called add_bitwise(bl, b2) that adds two binary numbers. This function must use recursion to perform the bitwise,

please use carry bits

please use carry bits 2. Write a function called add_bitwise(bl, b2) that

2. Write a function called add_bitwise(bl, b2) that adds two binary numbers. This function must use recursion to perform the bitwise, elementary-school" addition algorithm that we discussed in lecture, and it should return the result. It must not perform any base conversions, and it must not call the add function from Problem 2. Your function should add one pair of bits at a time, working from right to left and including any necessary carry bits, as discussed in lecture. For example, when adding 101110 and 100111, you end up with 3 carry bits, as shown in blue below: 111 101110 + 100111 1010101 Notes/hints: Base cases: Because the function will be called recursively on smaller and smaller strings, you will eventually get down to an empty string for one or both of the inputs. If either of the strings (b1 or b2) is the empty string, your function should return the other string. Handling cases that require a carry bit can be the most difficult part of this problem. The trick is to call the function recursively a second time to add in the carry bit! We discussed this in Monday's lecture. . Here are some test cases: >>> add_bitwise('11', '100') result: '111' >>> add_bitwise ('11', '1') result: '100' >>> add_bitwise("', '101') result: '101' add_bitwise('11100', '11110') result: '111010' Make sure to try other test cases to ensure that your function works correctly in all cases

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!