Help in java please - Programming - HWzone Forums
Skip to content
  • Create an account
  • About Us

    Hello Guest!

    Please note - in order to participate in our community, comment and open new discussions, you must join as a registered member.

    Our members enjoy many advantages, including the ability to participate in discussions, enjoy raffles and promotions for members of the site, and receive our weekly content directly by email.

    Do not like being harassed by email? You can register for the site but do not submit your registration to the weekly email updates.

Help in java please


Recommended Posts

Hi, must have help I would love for you to help me
Question in line:
Write an action that takes a que queue and returns a new queue that is the inverse of the queue's organ order
For: que [1,2,3,4] the queue will be returned [4,3,2,1]
*** Without the use of additional data structures, recursion hint ***

Write a new queue and I got entangled with it who can help me with reversing a new queue and the recursion will thank him very much !!smile.gif

Please help with the format I got entangled and when I see a way I understand according to it



We use head, remove and such 

That means in Node and Queue I would be happy for very urgent help

Link to content
Share on other sites

Your problem is in syntax or "algorithm"?


Try something in this direction (this is pseudo-code, of course):


public Queue reverseQueue (Queue q) {Queue newQ = new ... reverseQueue (q, newQ) return newQ} // this is the recursive function private void reverseQueue (Queue orig, Queue reversed) {if orig not empty {T element = q.remove () // first in queue reverseQueue (orig, reversed) reversed.add (element) // add to end of queue}}


Note: You wrote "Without the use of additional data structures, "recursion hint", but in a sense we use the call stack as a stack.


Exercise (to make sure you understand): Do you need a new appointment? Or can it be done using only the original queue?

Link to content
Share on other sites

Join the discussion

You can then join the discussion and then join our community. If you already have an account with us, please Log in now To comment under your username.
Note that: The comment will appear to the surfers after approval by the board management team.

Add a comment

×   The content pasted is with formatting.   Remove formatting

  Only 75 emoji are allowed.

×   Your link has been automatically assimilated.   Show as regular link

×   Your previous content has been automatically restored.   Clear all

×   You can not paste images directly. Upload or insert images from URL.


  • Latest news

  • Buzz-Zone: Everything hot on the net

  • Create new ...

At the top of the news:

new on the site

Amazon's parade continues

Amazon's parade continues

Come and be impressed by another list of great prices for quality hardware products and gadgets that can make your credit cards work overtime