Write a procedure that produces independent stack objects

Assignment Help Computer Engineering
Reference no: EM13737

(1) Sort a list of distinct numbers in ascending order, using the following divide-and-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.

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

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

Write 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 write a procedure to reverse a list by using two stacks.

(3) Implement your own streams.

(a) Write (delay <expr>) as a special form for (lambda () <expr>) and (force <expr>), as discussed in class.

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

(c) Write 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

(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) write 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

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

Reference no: EM13737

Previous Q& A

  Write a business proposal for a new product

Write a business proposal for a new product or service that your company will launch.

  Sample website project

This website consists of three sections: a narrative, a storyboard, and a business Website.

  Gravity conveyor

Illustrate the cause of the components accelerating from rest down the conveyor.

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Evaluation of a new chemical manufacturing process

Prepare the design and evaluation of a new chemical manufacturing process.


The socio-economic shortcomings that China experienced

  Method of measuring the humidity of the atmosphere

The humidity of air can be determined by use of two different thermometers; a 'dry bulb' thermometer and a 'wet bulb' thermometer. explain how these thermometers can be used to estimate the amount of water vapour in the air.

  Report on a company providing a clear audit trail

Prepare report on providing a clear audit trail to your company.  Prepare a portfolio of analytical reference materials including the financial reports for at least five years. This is your analytical permanent file for the chosen company.

  Redundant sequence identi cation

Redundant sequence identi cation

  Venture capital and private equity

Venture Capital & Private Equity It is argued that VC and PE houses achieve superior returns through ruthlessly focussing management on short to medium term outcomes.


Write a Review


Similar Q& A

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Security policy document project

Analyze security requirements and develop a security policy

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd