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

    Default fixedPoint for Stacks

    Hi guys

    Have some questions on this problem.

    Here is my answer for part 1 :

    Java Code:
    public void stackArrange(ArrayList list1, ArrayList list2){
            Stack s = new ArrayStackImpl();
            while(!list1.isEmpty()){
                if(s.empty() == true){
                    s.push(list1.get(list1.size() -1));
                    list1.remove(list1.size() - 1);
                }else if(list1.get(list1.size() -1).toString().compareTo(s.top().toString()) > 0){ // if e > s.top()
                    list2.add(s.pop());
                    if(s.empty() == true || s.top().toString().compareTo(list1.get(list1.size() -1).toString()) >= 0){//s.empty == true || s.top >= e
                        s.push(list1.get(list1.size() -1));
                        list1.remove(list1.size() - 1);
                    }
                }else if(list1.get(list1.size() -1).toString().compareTo(s.top().toString()) <= 0){ // e <= s.top()
                    s.push(list1.get(list1.size() -1));
                    list1.remove(list1.size() - 1);
                }
            }
            if(list1.isEmpty()){
                while(s.empty() == false){
                    list2.add(s.pop());
                }
            }
        }
    Once you have answered part 1 above add a second method to your Arranger class with the signature:

    public void fixedPoint(ArrayList list1,
    ArrayList list2)

    fixedPoint repeatedly feeds list1 through stackArrange until the output of stackArrange is the same as its input. This process of feeding the result of a method to itself until it stops changing its input is called reaching a fixed-point. Once the input stops changing you should return this result in list2.

    In implementing fixedPoint you will need to record the previous input to stackArrange so you can compare it with the output. You can test fixedPoint using ArrangerDriver2.java in the starting files. The result you should get is not specified here (you can probably guess what the result will be) but, given the way that stackArrange works you can know it will be a permuation of list1.

    Can anyone explain what does fixedPoint do?

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

    Default Re: fixedPoint for Stacks

    Quote Originally Posted by Malv View Post
    Hi guys

    Have some questions on this problem.

    Here is my answer for part 1 :
    What problem? What part 1?

    Jos
    cenosillicaphobia: the fear for an empty beer glass

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

    Default Re: fixedPoint for Stacks

    part 2 which is the fixedpoint.

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

    Default Re: fixedPoint for Stacks

    Quote Originally Posted by Malv View Post
    part 2 which is the fixedpoint.
    What part 2? Care to show us mortals the problem description? Or do we have to guess ...

    Jos
    cenosillicaphobia: the fear for an empty beer glass

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

    Default Re: fixedPoint for Stacks

    Once you have answered part 1 above add a second method to your Arranger class with the signature:

    public void fixedPoint(ArrayList list1,
    ArrayList list2)

    fixedPoint repeatedly feeds list1 through stackArrange until the output of stackArrange is the same as its input. This process of feeding the result of a method to itself until it stops changing its input is called reaching a fixed-point. Once the input stops changing you should return this result in list2.

    In implementing fixedPoint you will need to record the previous input to stackArrange so you can compare it with the output. You can test fixedPoint using ArrangerDriver2.java in the starting files. The result you should get is not specified here (you can probably guess what the result will be) but, given the way that stackArrange works you can know it will be a permuation of list1.

  6. #6
    kanasuke is offline Member
    Join Date
    Jul 2013
    Posts
    1
    Rep Power
    0

    Default Re: fixedPoint for Stacks

    can anyone explain part 2? i'm kinda lost what it is looking for...
    Last edited by kanasuke; 07-17-2013 at 09:56 AM.

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

    Default Re: fixedPoint for Stacks

    Quote Originally Posted by kanasuke View Post
    bump...

    can anyone explain part 2? i'm kinda lost what it is looking for...
    And who are you? Bumping some else's thread? The OP didn't bother to tell us the requirements (we had to guess) and he finally gave us part of it while the other part(s) are also essential to the problem; that's why everybody can only ignore this thread. A fixed point x w.r.t. a relation R is a point such that R(x) == x; that's all I can say about it. Better PM the OP so you can work on this problem together.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    noobplus's Avatar
    noobplus is offline Senior Member
    Join Date
    Feb 2012
    Location
    chennai,south of India(south east of asia)
    Posts
    232
    Rep Power
    3

    Default Re: fixedPoint for Stacks

    Hi, I forgot all java basics, since I had some short term memory problems, Now what should I do? I've interview day after tomorrow on Core Java . I've downloaded Cay S HorstMann's e-book.

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

    Default Re: fixedPoint for Stacks

    I allow bumping from anyone and anyone can comment on these issues. Mods just dont see people of the same problem trying to solve the same problem in a thread.

  10. #10
    noobplus's Avatar
    noobplus is offline Senior Member
    Join Date
    Feb 2012
    Location
    chennai,south of India(south east of asia)
    Posts
    232
    Rep Power
    3

    Default Re: fixedPoint for Stacks

    Quote Originally Posted by Malv View Post
    I allow bumping from anyone and anyone can comment on these issues.
    but both of them will have incomplete questions as a result

    regards
    dhilip

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

    Default Re: fixedPoint for Stacks

    Quote Originally Posted by noobplus View Post
    Hi, I forgot all java basics, since I had some short term memory problems, Now what should I do? I've interview day after tomorrow on Core Java . I've downloaded Cay S HorstMann's e-book.
    Cancel the appointment and protect yourself from a disgraceful failure.

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  12. #12
    noobplus's Avatar
    noobplus is offline Senior Member
    Join Date
    Feb 2012
    Location
    chennai,south of India(south east of asia)
    Posts
    232
    Rep Power
    3

    Default Re: fixedPoint for Stacks

    But I know all class rules, I can make it.. I'm studying fields atm.. I remember file handling , and still I doubt this article would help me...
    interview core java 129 questions
    Edited to add: should I read that web site? or book?
    regards
    dhilip
    Last edited by noobplus; 07-17-2013 at 08:42 AM.

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

    Default Re: fixedPoint for Stacks

    Quote Originally Posted by noobplus View Post
    But I know all class rules, I can make it.. I'm studying fields atm.. I remember file handling , and still I doubt this article would help me...
    interview core java 129 questions
    Edited to add: should I read that web site? or book?
    regards
    dhilip
    and why are you commenting on my thread?

  14. #14
    noobplus's Avatar
    noobplus is offline Senior Member
    Join Date
    Feb 2012
    Location
    chennai,south of India(south east of asia)
    Posts
    232
    Rep Power
    3

  15. #15
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,029
    Rep Power
    6

    Default Re: fixedPoint for Stacks

    Am I alone when I say that I am completely and utterly confused about what this thread is all about!?

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

    Default Re: fixedPoint for Stacks

    Quote Originally Posted by gimbal2 View Post
    Am I alone when I say that I am completely and utterly confused about what this thread is all about!?
    Nope, it's hopeless; I'm out of this thread.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

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

    Default Re: fixedPoint for Stacks

    Please close this thread, moderators.

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
  •