Question

1) A Ramanujam number can be written two different ways as the sum of two cubes—i.e....

1) A Ramanujam number can be written two different ways as the sum of two

cubes—i.e. , there exist distinct a, b, c, and d such that a3 +b3 = c3 +d3. Generate

all Ramanujam numbers where a, b, c, d < n.

3-18. What method would you use to look up a word in a dictionary?

3-19. Imagine you have a closet full of shirts. What can you do to organize your shirts

for easy retrieval?

3-20. Write a function to find the middle node of a singly-linked list.

3-24. What is the best data structure for maintaining URLs that have been visited by

a Web crawler? Give an algorithm to test whether a given URL has already been visited, optimizing both space and time.

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

3-18) Hash tables would be used to look up a word in dictionary. It is the best structure of key,value pairs to store corresponding values of a particular key in dictionary.

3-19) arrange the used ones behind the unused ones. That will represent a queue mechanism, so the unused ones will be in the front, as and when a new shirt is removed and used, it'll be put at the end. this will help in organizing the shirts better and redundancy will also be reduced.

3-20)let's find the count of nodes in the list. iterating over the list again from beginning to count/2 element that is the middle element. display it.

code is below

void printMiddle()
{
Node temp = head;
int count =0,value;
//Node last = head;
while(temp != null)
{
   count +=1;
   temp = temp.next;
}
temp = head;
  
while (temp != null && value<=count/2)
{
temp = temp.next;
}
System.out.println("The middle element is " +
temp.data );
}
}

3-24) best data structure for web crawler tracing is stack. it follows last in first out mechanism. so best data structure is stack

Add a comment
Know the answer?
Add Answer to:
1) A Ramanujam number can be written two different ways as the sum of two cubes—i.e....
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