Ask Question, Ask an Expert

+1-415-315-9853

info@mywordsolution.com

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?

Testing

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 mywordsolution.com 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

1 loops the greatest and the least- write a program with a

1. Loops: The greatest and the least- Write a program with a loop that lets the user to enter a series of integers. The use should enter -99 to signal the end of the series. After all the numbers have been entered, the p ...

Assignmentyou will write a program that acts like a simple

Assignment You will write a program that acts like a simple calculator for binary numbers. You should read in a string of input that has the format: number operator number. Each of the numbers should be presented in two' ...

Engineering programmingi need this now please accurate

Engineering programming I need this now please accurate answers and must be high rated Problem #1 Write a program that asks the user to input the number of miles and convert the miles to kilometers, and then print the ou ...

Purposethe purpose of this assignment is to practice using

Purpose: The purpose of this assignment is to practice using loops, selections, and other basic features of Java in order to solve a real-world problem. Program Description: The Jeddah Broker Company is one of the compan ...

The briefyour small development team of ideally three

The Brief Your small development team of (ideally) three people has been asked to implement and test the Human Resource Information System desktop application. Your software product will be a database- backed desktop app ...

Add a swift class file to the project that illustrates and

Add a SWIFT class file to the project that illustrates and contains the following: • The class name is 'Calculator' • Has public variables of the type float called numerator, denominator and total. • Has a method called ...

Programming lab assignment set awhat to submitcomplete

Programming Lab Assignment (Set A) What to Submit Complete Problem Solving Steps 1 - 3 (check plan, data analysis, initial algorithm, and refinement algorithm) for the following programs. 1. (Name: lab1a-1.cpp) Write a p ...

Cp1404cp5632 2016 sp22252 assignment 1 - shopping list

CP1404/CP5632 2016 SP2/22/52 Assignment 1 - Shopping List 1.0 Task: You are to plan and then code a console-based program in Python 3, as described in the following information and sample output. This assignment will hel ...

The given machine description will provide the basis for

The given machine description will provide the basis for this assignment. You will create a virtual machine/operating system for the machine described below that will accept programs in the target machine language. The d ...

Write a program to test for the case of a math equation

Write a program to test for the case of a math equation entered via the keyboard using the SWITCH-CASE operator. Types of equations to test for: x + y  x / y   x * y and x - y. The program is to ask for the following: 1. ...

  • 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

A cola-dispensing machine is set to dispense 9 ounces of

A cola-dispensing machine is set to dispense 9 ounces of cola per cup, with a standard deviation of 1.0 ounce. The manuf

What is marketingbullwhat is marketing think back to your

What is Marketing? • "What is marketing"? Think back to your impressions before you started this class versus how you

Question -your client david smith runs a small it

QUESTION - Your client, David Smith runs a small IT consulting business specialising in computer software and techno

Inspection of a random sample of 22 aircraft showed that 15

Inspection of a random sample of 22 aircraft showed that 15 needed repairs to fix a wiring problem that might compromise

Effective hrmquestionhow can an effective hrm system help

Effective HRM Question How can an effective HRM system help facilitate the achievement of an organization's strate