Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started