Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Scheme in DrRacket please. ;Q4.1 ; enter your code here: ;Q4.2 ;Q4.3 ; Step 1 size-n problem: Lines of code ; ----> ; Step

Using Scheme in DrRacket please.

image text in transcribed

;Q4.1 ; enter your code here:

;Q4.2

;Q4.3 ; Step 1 size-n problem: Lines of code ; ---->

; Step 2 Stopping condition: Lines of code ; ---->

; Step 3 size-m problem: Lines of code ; ---->

; Step 4: Lines of code ; ---->

;Q4.4 ; enter your code here:

;Test cases (define x1 '(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) ) (define x2 '(1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) ) (define x3 '(0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1) ) (define x4 '(1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0) ) (define x5 '(1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1) ) (define x6 '(1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 0) )

(display "n-bit-adder Output ") (n-bit-adder x1 x2 32) (n-bit-adder x3 x4 32) (n-bit-adder x5 x6 32) (n-bit-adder x2 x3 32) (n-bit-adder x4 x5 32) (n-bit-adder x1 x6 32) ; Expected outputs ;(0 (1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)) ;(0 (1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)) ;(1 (1 0 1 1 1 0 0 0 1 1 1 0 0 1 0 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 1)) ;(1 (0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0)) ;(1 (1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1)) ;(0 (1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 0))

This is all the information I was given. I don't have any other information to add.

4 The diagram in Figure 4 shows the design of an n-bit adder using n one-bit full adders, where n=32 in the diagram. The basic idea is to use the full adders to work on each pair of digits, with the adders passing the carry values between them. The carryOut of bit-i is the carryIn of bit i+1, where the carryIn of bit 0 is 0 . The procedure should have three parameters: A,B, and n, where A and B are two lists representing two binary inputs numbers, and n is the length of A and B: (n-bit-adder ABn ). Two solutions are acceptable: (1) Follow the design in Figure 4, or (2) follow the binary addition algorithm given in the lecture slides. In both cases, you must call at least one of the procedures that you defined in Question 3. You may define one or more helper procedures. Figure 4. The design of a 32-bit adder 4.1 Define a procedure (tail lst), which returns the last element of lst. 4.2 Define a procedure (rmtail lst), which returns the list without the last element of lst. For 4.3 Follow the fantastic-four abstract approach to design your recursive solution to implement the diagram in Figure 4. You must also explain: (1) What is the size-n problem of your procedure? List the lines of code you use. (2) What are the stopping condition and its return value? List the lines of code you use. (3) What is the size-(n-1) problem? List the lines of code you use. (4) What are the steps to construct the size-n problem solution from the size-(n-1) solution. List the lines of code you use. Write the answers as comments in the program, so that your entire program file is executable. 4.4 Following the fantastic-four steps that you have designed in the previous question, implement the nbit adder, and test the program. Note: your (n-bit-adder A B n) must call a recursive procedure, e.g., (recursive-add A B c), where c is a carry. You can follow the lecture slides to write these two procedures. However, you cannot use (quotient t 2) and (remainder t 2). Instead, you must call your (full-adder (tail A) (tail B) c). You can use (car (full-adder (tail A) (tail B) c)) and (cdr (full-adder (tail A) (tail B) c)) to obtain the carry and sum, respectively. Test your program using the given test cases and make sure they generate the output matching with the expected output. In the output, the left-most element is the carry-out of the n-bit adder. If the carry-out is 1 , it represents an overflow in the adder. The remaining elements of the list are the sum

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

Step: 3

blur-text-image

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

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions

Question

reCAPTCHA added more useful value than version one. True False

Answered: 1 week ago

Question

Strong analytical, communication, and problem-solving skills

Answered: 1 week ago