Question

A. Write a recursive method that returns the sum of n to 1. B. Declare two...

A. Write a recursive method that returns the sum of n to 1.

B. Declare two attributes of a Node<E> object

C. Give a line of code to create a node object that can create a double.

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

//A
//recursive method that returns sum of n to 1
int sum(int n)
{
   if(n<=1)return n;
   return sum(n-1)+n;//recursive call
}

//B
class Node<E>
{
   //two attributes
   E data;
   Node<E> next;
}

//C
   Node<Double> node = new Node<Double>();
  

Add a comment
Know the answer?
Add Answer to:
A. Write a recursive method that returns the sum of n to 1. B. Declare two...
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