Академический Документы
Профессиональный Документы
Культура Документы
Assignment 1
Due Date: 2nd November, 2019
a. Prove the following 5x4 − 37x3 + 13x − 4 = O(x4 ). You must find the c and n0.
b. Give a big-O estimate for each of these functions and prove your answer.
(i) 3n + n3 + 4
(ii) 1 + 2 + 3 + · · · + n + 3n2
Part 2 (Arrays)
Implement in Java the class ArrayUtility, which offers basic operations over one-
dimensional and two-dimensional arrays. All methods must be implemented as class
methods (i.e., static methods). The signature of the methods in the ArrayUtility class are
the following:
1. public static int findMax(int[] A, int i, int j): returns the maximum value occurring in
the array A between position i and j.
2. public static int findMaxPos(int[] A, int i, int j): returns the position of the maximum
value in the array A between position i and j.
3. public static int findMin(int[] A, int i, int j): returns the minimum value in the array A
between position i and j.
4. public static int findMinPos(int[] A, int i, int j): return the position of the minimum
value in the array A between position i and j.
1
Reminder: Own your work
5. public static void swap(int[] A, int i, int j): swaps the elements in position i and j in the
array A.
Part 3 (LinkedList)
Implement the Link (Node) and Linkedlist class with the following method
implementations:
NB: Your LinkedList class should implement the List interface (available in java
library)
LinkedList:
public LinkedList(){
head = new Node(null); //head is the same as first
size = 0;
Methods:
a. public boolean isEmpty();
2
Reminder: Own your work
// removes the item from the list that has the given index
// precondition: none
// postcondition: removes the first item in the list whose equal method
// matches that of the given item