1 sort a list of distinct numbers in ascending order using

Assignment Help Computer Engineering
Reference no: EM13346837

(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: EM13346837

Questions Cloud

Comprehensive case studyciao restaurant was a very : comprehensive case studyciao restaurant was a very successful restaurant and was consistently ranked by professional
The frantic pipe layer game1 the completed gamehere is what : the frantic pipe layer game.1 the completed gamehere is what the user interface should look like when completedyou must
Write an essay on one of the subsequent topics1 the most : write an essay on one of the subsequent topics1. the most basic form of empire is the power to command another
Review and explain what the general rules are for : review and explain what the general rules are for agricultural produce using us gaap and
1 sort a list of distinct numbers in ascending order using : 1 sort a list of distinct numbers in ascending order using the following divide-and-conquer strategy quicksort divide
Wite a business proposal for a new product or service : write a business proposal for a new product or service that your company will launch.proposal has to be realistic for
1 create a narrative that describes the site to your : 1. create a narrative that describes the site to your prospective client.2. create a storyboard diagram depicting the
A robot unloads a completed component from a machine and : a robot unloads a completed component from a machine and places it on a gravity conveyor. the conveyor accelerates from
Tic tac toe game - design a gui and implement tic tac toe : tic tac toe game - design a gui and implement tic tac toe game in java-implement a random move using two methods

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

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

  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.

  Implementation of memory management

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

  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

  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?

  Implementation of memory management

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

  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.

  Prepare a proposal to deploy windows server

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

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

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

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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