Question: Q1. [3 points] Write a method public Node getSecondToLast(SList S) that takes a Singly List as a parameter. This method returns a reference to the

 Q1. [3 points] Write a method public Node getSecondToLast(SList S) that

Q1. [3 points] Write a method public Node getSecondToLast(SList S) that takes a Singly List as a parameter. This method returns a reference to the node before the last node in the list. Q2. [3 points] Imagine a non-empty CircularList does not have a size variable defined in the class. Write the method public int size 0 which returns the size of this CircularList. Q3. [3 points] Write a method public SList cloneSList(SList S) that takes a Singly List as a parameter. This method creates a copy of the provided list and returns reference to the newly created Singly List. The original list must not be destroyed. Q4. [3 points] Write a method that uses iteration to compute and return the sum of all positive integers in a single dimension array. Analyse this algorithm by showing the number of operations and give the asymptotic running time using the Big Oh notation for the best and the worst cases. Q5. [3 points] Write the method given in Q4 using recursion. Show recurrences using tracing and estimate the running time giving Big Oh notation using the substitution method

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!