0% found this document useful (0 votes)
13 views2 pages

CSE221 Structure and Interpretation of Computer Programs IV Semester CSE (Ettimadai)

This document is an exam paper for B.Tech IV Semester students at Amrita School of Engineering, focusing on Structure and Interpretation of Computer Programs. It includes three parts: Part A consists of short answer questions, Part B involves defining procedures for mathematical computations, and Part C requires writing procedures for complex number operations and evaluating a counter procedure. The total marks for the exam are 50, with a duration of 2 hours.

Uploaded by

Supriya M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

CSE221 Structure and Interpretation of Computer Programs IV Semester CSE (Ettimadai)

This document is an exam paper for B.Tech IV Semester students at Amrita School of Engineering, focusing on Structure and Interpretation of Computer Programs. It includes three parts: Part A consists of short answer questions, Part B involves defining procedures for mathematical computations, and Part C requires writing procedures for complex number operations and evaluating a counter procedure. The total marks for the exam are 50, with a duration of 2 hours.

Uploaded by

Supriya M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

AMRITA VISHWA VIDYAPEETHAM

Amrita School of Engineeirng


Department of Computer Science & Engineering
B.Tech IV Semester
CSE221 Structure and Interpretation of Computer Programs
Periodical I

Total Marks: 50
Duration: 2 hours

Part A (5 X 2 = 10 Marks)

1. Translate the following expression into Scheme expression. (2/3 + 4/9)÷(5/11 – 4/3)
2. Define a procedure smaller that takes two numbers as arguments and returns the smaller of them
using the special form if. Also rewrite the same procedure using cond.
3. Construct the following procedure (define (divides? a b) (= (remainder b a)
0)) using lambda.
4. Provide some of the “rights and privileges” of first-class procedures.
5. Give the box-and-pointer representation of (cons (cons 1 2) (cons 3 (cons 4
5))).

Part B (4 X 5 = 20 Marks)

6. Define necessary procedures that compute the sum of the squares of integers from a through b.

7. Define necessary procedures that compute the Least Common Multiple (LCM
) of given two numbers. (Hint: LCM of given two numbers a and b can be calculated as
ab/GCD(a,b) where GCD(a,b) is the Greatest Common Divisor of a and b which is equal to
GCD(b,r) where r is the remainder when a is divided by b.

8. A) Give the output of following expression.


(define a 1)

(let ( (a (+ 4 7)))
(let ( (b (* a 5)))

(+ a b)))

B) Complete the <body> of the following procedure that computes the sum of the squares of a and
b
(define (sum-square a b)
(let ( (+ *)
(* +))
(<body>) ))
9. Given the following procedure repeated, what will be the value of the expression
((repeated square 2) 5) assuming that the procedure square computes the square of a
given number?

(define (repeated p n)
(cond ( (= n 0) (lambda (x) x))
( (= n 1) p)
( else (lambda (x) (p ((repeated p (- n 1)) x))))))

Part C (2 X 10 = 20 Marks)

10. Write necessary procedures (constructor, selectors and rules of operations) for doing
arithmetic operations viz. addition, subtraction and multiplication for complex numbers of the form
a+ib.

11. Imagine that there is a primitive procedure called counter with no arguments, that
returns 1 the first time you call it, 2 the second time and so on. Supposing that the counter has not
been called until now, show with necessary details the outputs of the following procedure calls each
using both applicative and normal order evaluation.

a) (times (counter) (counter))

b) (square (counter))

where the definitions for above procedures times and square are as follows.

(define (times a b) (* a b))

(define (square a) (* a a))

You might also like