Question: (a) Linear list can be implemented by an array. Add the following static methods to perform the required functions for the list: (i) truncate(int n)

 (a) Linear list can be implemented by an array. Add the

(a) Linear list can be implemented by an array. Add the following static methods to perform the required functions for the list: (i) truncate(int n) that shortens the list by keeping only the first n elements of list[] .

(ii) reverse() that reverses the order of the element in list[].

(iii) uniqueRandomInts(int n, int max) that restructures list[] to become an array of length n with unique nonnegative random integers that are less than max.

(b) Show the output when successfully executing LinearList in java.

import java.util.Random; public class LinearList { private static Random randl = new Random(); private static int [] list = {20, 36, 16, 36, 7, 48, 67};; public static void display() { if (list != null) { System.out.print("{" + list[0]); for (int i = 1; i

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!