Question: 1) A) Write a method to find the maximum value of a list of integers. The node definition is given below. Assume your method signature
1)
A) Write a method to find the maximum value of a list of integers. The node definition is given below. Assume your method signature is public static int listMax(IntNode node) and that node will not be null initially. Your solution may not use recursion.
public class IntNode {
private int value;
private IntNode next;
public int getInt() { return value; }
public void setInt(int v) { value = v; }
public IntNode getNext() { return next; }
public void setNext(IntNode n) { next = n; }
}
B) In this unit, we introduced three kinds of list ADTs, including the actual indexed list ADT provided by Java (see table). There are two primary ways such a table could be implemented: arrays and linked structures. Based on your knowledge of these data structures, complete the following table:
| Method | Description | Array Big-Oh | Linked Big-Oh |
| void add(E element) | Adds element to the end of the list. | ||
| void add(int index, E element) | Inserts element at the index. | ||
| E get(int index) | Returns element at the index. | ||
| void remove(int index) | Removes element at the index. | ||
| void remove(E object) | Removes first occurrence of the object. | ||
| void set(int index, E element) | Replaces element at the index. | ||
| int size() | Returns number of elements in the list. |
On the table, make bold the operations which have a different order. Give a brief explanation for the difference below.
C) In order to properly answer the last question, several assumptions may have been made. What did you assume? For example, did write your Big-Oh in terms of array resizing? Or did you assume that the array didn't need to resize?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
