Question

Question 1- Without using extra data structures, write a recursive method recursiveProdcutQueue ( Queue <Integer> q) in Testplease use java

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: If you have any queries related to the answer please do comment. I would be very happy to resolve all your queries.

import java.util.LinkedList;
import java.util.Queue;
public class Test{
public static int recursiveProductQueue(Queue<Integer> q)
{
if(q.size()==0)
{
return 1;
}
int num=q.poll();
return num*recursiveProductQueue(q);
}


public static void main(String []args){
Queue<Integer> q
= new LinkedList<>();
  
for (int i = 1; i <=5; i++)
q.add(i);
System.out.println(recursiveProductQueue(q));
}
}

I.lt Result $javac Test.java Sjava -Xmx128M -Xms16M Tes 120 Execute > Share Source File STDIN 1 import java.util.LinkedList;

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
please use java Question 1- Without using extra data structures, write a recursive method recursiveProdcutQueue (...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT