Write a procedure that produces independent stack, Data Structure & Algorithms

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.

Posted Date: 3/30/2013 3:39:31 AM | Location : United States







Related Discussions:- Write a procedure that produces independent stack, Assignment Help, Ask Question on Write a procedure that produces independent stack, Get Answer, Expert's Help, Write a procedure that produces independent stack Discussions

Write discussion on Write a procedure that produces independent stack
Your posts are moderated
Related Questions
The minimum cost spanning tree has broad applications in distinct fields. It represents several complicated real world problems such as: 1. Minimum distance for travelling all o

Q. Write  down a   programme  in  C  to  create  a  single  linked  list also  write the functions to do the following operations (i)  To insert a new node at the end (ii

what are registers? why we need register? Definition? Types? What registers can do for us?

In this unit, we described about the data structure Queue. It had two ends. One is front from where the elements can be removed and the other is rear where the elements can be inse


Q. Write down an algorithm to merge the two sorted arrays into the third array. Do  not perform the sort function in the third array.                           Ans: void m

How many recursive calls are called by the naïve recursive algorithm for binomial coefficients, C(10, 5) and C(21, 12) C(n,k){c(n-1,k)+c(n-1,k-1) if 1 1 if k = n or k = 0

What is wrong with the following algorithm for sorting a deck of cards (considering the basic properties of algorithms)? I. Put the cards together into a pile II. For each ca

Q. Write  down the  algorithm  to  insert  an  element  to  a  max-heap  which  is  represented sequentially.           Ans: The algorithm to insert an element "newkey" to

HLS Colour Model  This model has the double-cone representation shown in Figure 3.40. The three colour parameters in this model are called hue (H), lightness (L), and Saturati