Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Stack implementation with given condition

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    2
    My Mood
    Cool
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Stack implementation with given condition, CHALLENGE

    Write programs which implement the interface that is attached, according the following rule

    - Compile and execute in Java 6 environment
    - Use "UTF-8" for the encoding of your programs
    -Use English only. (For all class names, identifiers, method names, comments, etc.)
    -Package name should be "jp.co.worksap.intern" and class name must be "Sortable stack"
    -Consider Execution speed. Implement all methods as fast as possible
    - Suppose every method will be called in the same frequency, so every method should be similarly fast, not part of (or particular) methods.

    package jp.co.worksap.intern;
    /**
    *The Stack class represents a last-in-first-out(LIFO) stack of objects
    *And this class can look at the object which has the highest (lowest or so) value.
    *So every object onto the stack must be comparable to each other.
    *@param<E.
    */
    public interface ISortableStack<E extends Comparable<E>>(
    /**

    *Pushes an item onto the top of this stack.
    *If the Element e is null, throws NullPointerException.
    *
    *
    @param e
    *@throws NullPointerException
    /*
    public void push(E e);

    /**
    *Removes the object at the top of this stack and returns that object as the value of this function.
    *If the stack is empty, throws EmptyStackException.
    *@return
    *@throws EmptyStackException
    */
    public E pop();

    /**
    *Locks at the object which has the middle value among the all objects without removing it from the stack.
    *Returns the object which has the value of following order <code>(size()/2)+1</code>
    *<pre>
    *e.g.
    *When the stack has the following values (1, 2, 5, 4, 2, 6)
    *this method returns 4 and doesn't remove the object.
    *</pre>
    *
    *If the stack is empty, throws EmptyStackException.
    *@return
    *@throws EmptyStackException
    */
    public E peekMidElement();

    /**
    *Looks at the object which has the highest value among the all objects without removing it from the stack.
    *Returns the object which has the value of the following order <code>size()</code>
    *<pre>
    *e.g.
    *When the stack has the following values (1,2,5,4,2,6)
    *this method returns 6 and doesn't remove that object
    *</pre>
    *
    *If the stack is empty, throws EmptyStackException.
    *@return
    *@throws EmptyStackException
    */
    public E peekHighestElement();

    /**
    *Looks at the object which has the lowest value among the all objects without removing it from the stack.
    *Returns the object which has the value of the following order <code>1</code>
    *<pre>
    *e.g.
    *When the stack has the following values (1,2,5,4,2,6)
    *this method returns 1 and doesn't remove the object.
    *</pre>
    *
    *If the stack is empty, throws EmptyStackException.
    *@return
    *@throws EmptyStackException
    */
    public E peekLowestElement();

    /**
    *Returns the number of objects in this stack.
    *@return
    */
    public int size();
    }
    Attached Images Attached Images
    Last edited by Magesh; August 20th, 2011 at 08:00 AM.


  2. #2
    Junior Member
    Join Date
    Aug 2011
    Posts
    2
    My Mood
    Cool
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Stack implementation with given condition

    this is important... deadline 21 aug 2011 till midnight

  3. #3
    Junior Member
    Join Date
    Aug 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Stack implementation with given condition

    i too need the same program...

Similar Threads

  1. Implementation Stack Using Array
    By rainbow9 in forum Java Programming Tutorials
    Replies: 1
    Last Post: August 20th, 2011, 09:48 AM
  2. Have Problem with if condition...Please Help me...
    By Jalpesh Ruparel in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 26th, 2011, 01:54 AM
  3. Waiting until condition
    By aussiemcgr in forum Java Theory & Questions
    Replies: 1
    Last Post: October 22nd, 2010, 09:24 AM
  4. Unable to retriving the data using WHERE condition
    By bhaskar_reddy in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: May 14th, 2010, 02:40 AM
  5. Problem with condition
    By shamed in forum What's Wrong With My Code?
    Replies: 7
    Last Post: December 7th, 2009, 04:51 PM

Tags for this Thread