Write procedures to manipulate queues

Assignment Help Other Engineering
Reference no: EM13316023

Code Style and Testing

Refer to the below and the general "Assignment Do's and Don'ts" doc linked to on cuLearn.

- All code has been well indented and has been broken down into reasonably sized procedures (no single line should be too long; aim for about 80 characters each)

- Each procedure has been well documented (but not over-documented - don't just restate the code) with comments, including the purpose of the procedure, the expected inputs, and the expected output

- There is sufficient testing using check-expect and, at a minimum, no code is highlighted by DrRacket when the file is run.

Question 1

An accumulator is a procedure that is called repeatedly with a single numeric argument and accumulates its arguments into a sum. Each time it is called, it returns the currently accumulated sum. Write a procedure make-accumulator that generates accumulators, each maintaining an independent sum. The input to make-accumulator will correctly specify the initial value of the sum; for example

(define A (make-accumulator 5))

(A 10)

15

(A 10)

25

Question 2

Write a procedure (make-queue) that produces independent first-in-first-out queue objects, using a message-passing style.  For example:

(define queue1 (make-queue))

(define queue2 (make-queue))

Write procedures to manipulate queues. At a minimum:

1. (queue1 'empty?): boolean

2. (queue1 'enqueue! item): adds item to the queue

3. (queue1 'front): returns the next element of the queue that would be removed on dequeue

4. (queue1 'back): returns the last element of the queue that would be removed on dequeue (i.e. the most recent element added)

5. (queue1 'dequeue!): throws away the front element

6. (queue1 'print): prints some representation of the queue from front to back

Reference no: EM13316023

Questions Cloud

What effective annual interest rate do they pay : A bank advertises it pays 7% annual interest, compounded daily, on savings accounts, provided the money is left in the account for 4 years. What effective annual interest rate do they pay?
How deep is the well : A person hums into the top of a well and finds that standing waves are established at frequencies of 10, 30, and 50 Hz. How deep is the well
What happens to reserves and the monetary base : If the Fed sells $2 million of bonds to the First National Bank, What happens to reserves and the monetary base? Use T-accounts to explain your answer.
Duties of corporations act and the corresponding fiduciary : Designco Pty Ltd designs, manufactures and distributes craft kits for children. Children use the kits to construct balsa wood models of animals, which can be painted. The directors of the company are Ian and May. Ian and May are also the only shareho..
Write procedures to manipulate queues : Write a procedure (make-queue) that produces independent first-in-first-out queue objects, using a message-passing style.
Find the weight of the heaviest vechicle that can be lifted : The small piston of a hydraulic lift has a raduis of 1 in and the large piston has a radius of 5 in. What is the weight of the heaviest vechicle that can be lifted
If a country wants to keep its exchange rate from changing : If a country wants to keep its exchange rate from changing, it must give up some control over its money supply. Is this statement true, false, or uncertain? Explain your answer.
Is the internet used for advertising : Is the Internet used for advertising and is the Internet used for internal and external information dissemination?
Compare the use of open market operations discounting and : Compare the use of open market operations, discounting, and changes in reserve requirements to control money supply on the following criteria: flexibility, reversibility, effectiveness, and speed of implementation.

Reviews

Write a Review

Other Engineering Questions & Answers

  Environmental engineering design - water treatment plant

A flat field, with a standard surface of water, which needs to get to 50,000 people by means of a water treatment facility that you have to design.

  A repulsive potential energy should be a positive one

Using the data provided on the webvista site in the file marked vdw.txt, try to develop a mathematical equation for the vdW potential we discussed in class, U(x), that best fits the data

  Environmental issue

CEE 357 Winter 2014. Independent writing assignment. Choose any current environmental issue on which a civil/environmental engineer might reasonably work.

  Analysis of the vehicle component

Analysis of the vehicle component: role, work conditions, requirements for the role and

  Non-linear temperature logging circuit

Design a non-linear temperature logging circuit and specify the technical specification of the resistors, capacitors etc. The components for the circuit: temperature sensor, analogue-to-digital converter, Ethernet or USB port, memory, microcontroller..

  Explain what advantages does mpls offer

Conduct research on traffic engineering using MPLS. List a set of goals for traffic engineering. Which of these goals can only be met with MPLS, and which are met by using existing (non-MPLS) protocols. What advantages does MPLS offer

  How much improvement in separation is produced

Reevaluate the separation using the same total amount of solvent in a counter-current cascade. How much improvement in separation is produced?

  Provide a teaching pedagogy reflective of 21st century

Provides safe Web access to students and staff. It also ensures no student or staff member is exposed to illicit web content.

  Find out the transfer function

proper rational system alone,with initial conditions on its input and output Input is a step signal with arbitrary value. Calculate and Plot all the above using MATLAB writing a code.

  Analysis of occupancy through prescriptive code analysis

The project will consist of a written paper and a presentation - Egress and Life Safety Analysis - FIRE 4500 (FIRE 2225)

  Find the ultimate bod of the river water

Environmental engineering, CEE 357 Winter 2014. HW#6 Assignment: -  Find the ultimate BOD of the river water as it enters the lake. Find the value of the rate constant for BOD utilization in the river, k d,riv .

  Calculate the gasoline savings

How much gasoline do vehicles with the following fuel efficiencies consume in one year? Calculate the gasoline savings, in gallons per year, created by the following two options. Show all your work, and draw boxes around your answers.

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