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


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

Q. The degree of a node is defined as the number of children it has. Shear show that in any binary tree, the total number of leaves is one more than the number of nodes of degree 2

Q. Using array to execute the queue structure, write down an algorithm/program to (i) Insert an element in the queue. (ii) Delete an element from the queue.

if two relations R and S are joined, then the non matching tuples of both R and S are ignored in

Q. The system allocates the memory for any of the multidimensional array from a big single dimensional array. Describe two mapping schemes that help us to store the two dimensi

Q. Explain the term hashing? Explain any five well known hash functions.                         Ans: Hashing method provides us the direct access of record from the f

Decision Tree - ID3 algorithm: Imagine you only ever do one of the following four things for any weekend:   go shopping   watch a movie   play tennis   just

Define the term - Array A fixed length, ordered collection of values of same type stored in contiguous memory locations; collection may be ordered in several dimensions.

A company is carrying out a survey by observing traffic at a road junction. Every time a car, bus or lorry passed by road junction it was noted down. 10 000 vehicles were counted d

Linear search is not the most efficient way to search an item within a collection of items. Though, it is extremely simple to implement. Furthermore, if the array elements are arra