Results 1 to 2 of 2
Like Tree2Likes
  • 2 Post By pbrockway2

Thread: HELP! Stack newbie

  1. #1
    aliala is offline Member
    Join Date
    Jul 2011
    Rep Power

    Question HELP! Stack newbie

    i'm having a trouble here with Stack. please help me.

    how do i find minimum value in a predefined stack with a Object findMin(Stack ori) method? where do i have to declare the stack? in the static main or outside? could you guys please include the coding for implementing this method?

    i'm new to stack and a bit slow with this one. please help me out. asap. Thanks !

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power


    It seems you are confusing two things here:

    * How you would go about finding the minimum value in a stack? This problem does not involve writing any code, but you would describe the steps needed completely and precisely enough to allow you to write code from the description you give.
    * What code would reflect the process you described in step 1. This problem involves meeting all the requirements you have been given in the problem (which I'm guessing is homework of some sort.)

    To address the first question, have a look at the Queue methods and think. Perhaps you could experiment with a pile of pieces of paper to see how, in fact, you would locate the minimum. Don't forget the fact that Stack inherits behaviour from its parent classes - you might decide to search it as you would any other list.

    Post what you've come up with if you get stuck. Also suppose the stack consisted of 666, 1 Jan 2012 and "foo", which would be the minimum? Does the stack have to have some other property before the task even makes sense?

    Once you figured out what you are going to do, you can sensibley start writing code.
    JeffGrigg and Norm like this.

Similar Threads

  1. Stack
    By kayln in forum Eclipse
    Replies: 0
    Last Post: 03-04-2011, 08:14 PM
  2. How big is the stack??
    By mgeno216 in forum New To Java
    Replies: 6
    Last Post: 03-04-2011, 08:04 AM
  3. Stack Calculator
    By Bgreen7887 in forum New To Java
    Replies: 3
    Last Post: 01-28-2011, 11:01 PM
  4. Stack layout
    By blue404 in forum SWT / JFace
    Replies: 0
    Last Post: 03-22-2009, 01:15 PM
  5. Need help please implementing a stack!
    By sfe23 in forum New To Java
    Replies: 0
    Last Post: 02-24-2009, 03:19 PM

Tags for this Thread

Posting Permissions

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