Question: Java Help: Please answer both parts of the question fully: (a). Given a linked list of integers, write a method that computes and prints the

Java Help: Please answer both parts of the question fully:

(a). Given a linked list of integers, write a method that computes and prints the pairwise sums which is illustrated below with an example. If the linked list has values 5,3,2,9,3,15,22 from head to tail, the pairwise sums would be 8,5,11,12,18,37 which is the sum of two consecutive values from left to right. Notice the output will be of size one less than the original. You will output the pairwise sums exactly as above on a single line, comma separated. If the original list is of size 0 or 1 then print an appropriate error message. Make sure your code works for a linked list of any size, not just for the example above. Estimate the time-complexity of your algorithm.

(b). Given an arraylist of Strings, write a method that checks if any two strings in the arraylist when concatenated is identical to any other String in the arraylist. For example, if the arraylist has [cat, dog, dot, ca, t, do,t,g], then the answer would be to print Yes, ca at location 3 and t at location 4 together form cat at location 0. Of course, there are other answers too, for instance, do and t form dot or do and g form dog. Any one answer is good enough. Concatenate operation is done by the usual + in Java. Estimate your algorithms run-time complexity.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!