Ask Question, Ask an Expert

+61-413 786 465

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

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

  • 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

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As