Ask Question, Ask an Expert


Ask Programming Language Expert

 (1) Sort a list of distinct numbers in ascending order, using the following divideand- conquer strategy (Quicksort): divide the list of numbers into two lists: one that contains all items that are strictly smaller than the first item (often called the pivot), and another with all those items that are strictly larger than the first item. Then the two smaller lists are sorted using the same procedure. Once the two lists are sorted, the pieces are juxtaposed. For ex, given (11 8 14 7) the pivot is 11. We make two lists, (8 7) and (14). The second is already sorted; sorting the first - pivot is 8 - yields (7 8). Putting the three pieces together: (7 8) 11 (14) ==> (7 8 11 14).

(2) prepare a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

(define stack1 (make-stack))
(define stack2 (make-stack))

prepare procedures to manipulate stacks, e.g.

(stack1 'empty?) ==> boolean
(stack1 'push! item) ==> pushes item on top of stack
(stack1 'top) ==> returns top element of stack,
leaves stack unchanged
(stack1 'pop!) ==> throws away top element of stack
(stack1 'print) ==> prints some representation of the stack from top to bottom, enclosed in brackets etc….

Your tests should include making several stacks, pushing on one what is popped from the other, attempts to pop from an empty stack etc.

Also prepare a procedure to reverse a list by using two stacks.

(3) Implement your own streams.

(a) prepare (delay ) as a special form for (lambda () ) and (force ).

(b) prepare (stream-cons x y) as a special form, as discussed in class.

(c) prepare stream analogues of some familiar list processing functions, including: (stream-car str)

(stream-cdr str)
(stream-null? str)
(stream-ref str n) --- returns the nth
element in stream str
(stream-filter pred str) --- makes a new stream of
elements satisfying pred
(stream-for-each proc str) --- applies proc to each
element of str for side effect
(first n str) --- makes a stream of the
first n items in str
(list->stream lis) --- makes a stream from
list lis
(stream->list str) --- opposite coercion

For ex, if you have defined a stream of even integers called evens, you can display the first 50 even integers as follows:
(stream-for-each (lambda (x) (display x)(display "
")) (first 50 evens)).

Test your functions convincingly!

(d) Now define a bunch of streams to test your functions:

(i) an infinite stream of 1's

(ii) an infinite stream of all even integers

(iii) an infinite stream of random numbers between 1 and 100

(iv) prepare a predicate (prime? n) that tests for primality and use it to create a stream of all primes

(4) (i) Add the special form let to the metacircular interpreter (see ch4- mceval.scm from SICP and the version on the course website).

Hint: remember let is just syntactic sugar for a lambda expression and so a reprepare to the lambda form is all that is required.

(ii) What changes are needed in the metacircular interpreter so that Scheme uses dynamic instead of lexical scoping?


As always, test thoroughly and present your test results clearly. Do not forget to demonstrate that your changes to the metacircular interpreter work in all cases!

Your assignment should include a README.TXT file that contains details of the testing you have performed and any special requirements that have for setup. All Scheme files should have the extension .rkt. All text files should have the extension .txt.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91109
  • Price:- $65

Priced at Now at $65, Verified Solution

  • AsyU replied

    Good work, good quality solution provided by you guys which help me alot, seriously i recommend to my all mates and once again thank you so much for delivering good and authentic solution...

Have any Question? 

Related Questions in Programming Language

Using the machine model find the minimum initiation

Using the machine model, find the minimum initiation interval and a uniform schedule for the iterations, for the following loop: for(i =1; i A[i] = B[i-1] + 1; B[i] = A[i-1] +2; } Remember that the counting of iterations ...

Wite a method to computer the following series mi 12 23

Write a method to computer the following series: m(i) = 1/2 + 2/3 + . . . + i/i + 1 Write a test program that displays the following table: I m(i) 1 0.5000 2 1.1667 . . . 19 16.4023 20 17.3546 Formulas to achieve the abo ...

Design a class named pet which should have the following

Design a class named Pet, which should have the following fields: •Name - The name field holds the name of a pet. •Type - The type field holds the type of animal that is the pet. Example values are "Dog", "Cat", and "Bir ...

Question 1briefly explain these main programming paradigm

Question 1: Briefly explain these main programming paradigm (Logic, Functional, Object Oriented, Procedural, Imperative and Aspect-oriented), and for each of these paradigms name at least one language that can be used fo ...

Assignment research projectwrite an overview of any two of

Assignment: Research Project Write an overview of *any two* of the below topics. Each overview should be between one half and one full page long. You should use a minimum of two sources for each overview; make sure to re ...

Write a program which1 asks the user to enter a letter

Write a program which: 1. Asks the user to enter a letter grade (A, B, C, D, F) or (a, b, c, d, f) 2. Validates that the entry is a letter grade (A, B, C, D, F) or (a, b, c, d, f) 3. The program then asks the user to ent ...

Test 1you are permitted the use of pre-written notes

Test 1 You are permitted the use of pre-written notes, previous labs and the textbook. You are NOT permitted the help of the Lab TA or the Internet. Any cheating will result in a report Academic Integrity Violation and a ...

Create a base class that will include the properties of

Create a base class that will include the properties of some type of data related to the company you work for or a favorite hobby. For example, I work for a healthcare provider, so my base class might be "Medical Facilit ...

Spreadsheet exercise1 run the spreadsheet program in your

Spreadsheet Exercise 1. Run the spreadsheet program in your computer and type the following:   A B C D E F 1 PAYROLL 2 XYZ COMPANY Employee Name Department Degree Salary Need Increase? 3 Nasser Mechanical Master 15000   ...

Sum of digits in a string design a program that asks the

Sum of Digits in a String Design a program that asks the user to enter a string containing a series of single digit numbers with nothing seperating them. The program should display the sum of all the single digit numbers ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro

Describe what you learned about the impact of economic

Describe what you learned about the impact of economic, social, and demographic trends affecting the US labor environmen