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
Determine the class invariants- Ruby Ruby has many predefined exceptions classes (like ArgumentError) and new ones can be created easily by sub-classing StandardError, so it's

So far, we now have been concerned only with the representation of single stack. What happens while a data representation is required for several stacks? Let us consider an array X

There are four data type groups:  Integer kepts whole numbers and signed numbers Floating-point Stores real numbers (fractional values). Perfect for storing bank deposit

Explain the term - Branching There are two common ways of branching: case of ..... otherwise ...... endcase  if ..... then ..... else ..... endif   case of

Painter's Algorithm As the name suggests, the algorithm follows the standard practice of a painter, who  would paint the background (such as a backdrop) first, then the major d

Write a program that uses the radix sort to sort 1000 random digits. Print the data before and after the sort. Each sort bucket should be a linked list. At the end of the sort, the

Define data model?  A data model is a collection of conceptual tools for explaning data, data relationships, data semantics and consistency constraints.

Q. Write down an algorithm to insert a node in the beginning of the linked list.                         Ans: /* structure containing a link part and link part

differences between direct and indirect recursion

A graph with n vertices will absolutely have a parallel edge or self loop if the total number of edges is greater than n-1