Results 1 to 2 of 2

Thread: Stacks

  1. #1
    Malv is offline Member
    Join Date
    Jun 2013
    Posts
    62
    Rep Power
    0

    Default Stacks

    Given the following interface for Stack objects:
    Java Code:
    public interface Stack<AnyType>{
    public boolean empty(); // true if stack empty
    public AnyType top(); // returns top element
    public AnyType pop(); // returns and removes top
    public void push(AnyType val); //adds to top
    }
    and the following interface for Simple array objects:
    Java Code:
    public interface SimpArray<AnyType>{
    public AnyType get(int i); // returns the value at
    // index i
    }
    Answer the following questions:
    i. Precisely describe how two stacks can be be used to implement
    the get() operation of SimpArray. Note, your implementation
    does not have to be efficient.

    How do I describe this question?

    ii. Can a single stack be used to implement a SimpArray datatype?
    Briefly justify your answer.


    What does this question means?

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,439
    Blog Entries
    7
    Rep Power
    20

    Default Re: Stacks

    Quote Originally Posted by Malv View Post
    How do I describe this question?
    I'd say: the question is well formulated; the note is a real spoiler.

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Can somebody help me with stacks?
    By sim18 in forum New To Java
    Replies: 3
    Last Post: 10-08-2012, 07:06 PM
  2. stacks
    By nevets93 in forum New To Java
    Replies: 6
    Last Post: 02-25-2011, 03:32 AM
  3. Help with stacks
    By kMel90 in forum New To Java
    Replies: 3
    Last Post: 12-05-2010, 01:02 AM
  4. Stacks
    By Zosden in forum Advanced Java
    Replies: 15
    Last Post: 05-05-2008, 08:16 AM
  5. Using Stacks
    By ravian in forum New To Java
    Replies: 7
    Last Post: 11-28-2007, 09:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •