Following Information Might Useful Please Let Know Need Information Q43902555

The following information might be useful, please let me knowif you need any other information



Description Hi Everyone, Here is assignment 5 of 62:206 due Sunday, January 19 2020 1. The code part (60%) a. Use the public class NodeSequence to implement Sequence (Sequence was presented in class). b. Provide the bubble sort code using the Sequence. // O(n^2) c. Provide the merge sort code using the Sequence. // O(nlog n) d. In the main function, randomly generate a large sequence containing random integers (over 20,000), and use the two sorts to sort the Sequence and compare the efficiency by a clock. (Hint: You should have one class like public class Node Sequence<E> extends Node PositionList<E> implements Sequence<E> The following is part of your assignment 5 and complete the bridging methods: public Position<E> atindex(int index) and public int indexOf(Position<E>p). * An implementation of a sequence, using a linked position list as its underlying data structure. public class Node Sequence<E> extends Node PositionList<E> implements Sequence<E>{ Il you have to get NodePositionList<E> work. * Default Constructor public Node Sequence() { super(); protected void checkIndex(int i) throws IndexOutOfBoundsException { if (i <oll i >= numElts) throw new IndexOutOfBoundsException(“Index” + i + ” is out of bounds!”); // from interface Sequence * Returns the position containing the element at the given index. public Position<E> atindex(int index) throws Boundary ViolationException { // Write out your work here // Write out your work here * Returns the index of the element stored at the given position. public int indexOf(Position<E>p) throws Invalid PositionException { Il your work is here // from interface Deque * Returns the first element; an exception is thrown if sequence is empty. public EgetFirst throws Empty DequeException { return first().element(); * Returns the last element; an exception is thrown if sequence is empty. public E getLast() throws EmptyDequeException { return last().element(); * Removes the first element; an exception is thrown if sequence is empty. public E removeFirst() throws EmptyDequeException { return remove(first(); return remove(first(); * Removes the last element; an exception is thrown if sequence is empty. public E removeLast() throws Empty DequeException { return remove(last(); // from interface IndexList *Inserts an elemente to be at index i, shifting all elements after this. public void add(int i, Ee) throws IndexOutOfBoundsException { checkIndex(i); if (i == numElts) { addLast(e); } else { addBefore(atlndex(i), e); * Returns the element at index i, without removing it. public E get(int i) throws IndexOutOfBoundsException { checkIndex(i); return atlndex(i).element(); * Domaine and returns the namont at indavi chiftinn the lamante after thie return atIndex().element(): Removes and returns the element at index i, shifting the elements after this. public E remove(int i) throws IndexOutOfBoundsException { checkIndex(0); return remove(atIndex(0)); * Replaces the element at index i with e, returning the previous element at i. public E set(int i, E e) throws IndexOutOfBoundsException { checkIndex(); return set(atIndex(i), e); // from interface iterable public java.util.Iterator<E> iterator() { return new Elementiterator<E>(this); Il other fuctions public String toString() { return toString(this); Clock in Java Found in Brandonu Inbox Hello my friends, I will need it in algorithm analysis (section after recursion). To find time the method call A(parameters) takes, you call try the following code in Java: long start Time = System.currentTimeMillis(); // Millis 1 = 0.001 second A (parameters); long endTime = System.current TimeMillis(); long t = endTime – startTime; I will use this in analysis of algorithms. Show transcribed image text Description Hi Everyone, Here is assignment 5 of 62:206 due Sunday, January 19 2020 1. The code part (60%) a. Use the public class NodeSequence to implement Sequence (Sequence was presented in class). b. Provide the bubble sort code using the Sequence. // O(n^2) c. Provide the merge sort code using the Sequence. // O(nlog n) d. In the main function, randomly generate a large sequence containing random integers (over 20,000), and use the two sorts to sort the Sequence and compare the efficiency by a clock. (Hint: You should have one class like public class Node Sequence extends Node PositionList implements Sequence
The following is part of your assignment 5 and complete the bridging methods: public Position atindex(int index) and public int indexOf(Positionp). * An implementation of a sequence, using a linked position list as its underlying data structure. public class Node Sequence extends Node PositionList implements Sequence{ Il you have to get NodePositionList work. * Default Constructor public Node Sequence() { super(); protected void checkIndex(int i) throws IndexOutOfBoundsException { if (i = numElts) throw new IndexOutOfBoundsException(“Index” + i + ” is out of bounds!”); // from interface Sequence * Returns the position containing the element at the given index. public Position atindex(int index) throws Boundary ViolationException { // Write out your work here
// Write out your work here * Returns the index of the element stored at the given position. public int indexOf(Positionp) throws Invalid PositionException { Il your work is here // from interface Deque * Returns the first element; an exception is thrown if sequence is empty. public EgetFirst throws Empty DequeException { return first().element(); * Returns the last element; an exception is thrown if sequence is empty. public E getLast() throws EmptyDequeException { return last().element(); * Removes the first element; an exception is thrown if sequence is empty. public E removeFirst() throws EmptyDequeException { return remove(first();
return remove(first(); * Removes the last element; an exception is thrown if sequence is empty. public E removeLast() throws Empty DequeException { return remove(last(); // from interface IndexList *Inserts an elemente to be at index i, shifting all elements after this. public void add(int i, Ee) throws IndexOutOfBoundsException { checkIndex(i); if (i == numElts) { addLast(e); } else { addBefore(atlndex(i), e); * Returns the element at index i, without removing it. public E get(int i) throws IndexOutOfBoundsException { checkIndex(i); return atlndex(i).element(); * Domaine and returns the namont at indavi chiftinn the lamante after thie
return atIndex().element(): Removes and returns the element at index i, shifting the elements after this. public E remove(int i) throws IndexOutOfBoundsException { checkIndex(0); return remove(atIndex(0)); * Replaces the element at index i with e, returning the previous element at i. public E set(int i, E e) throws IndexOutOfBoundsException { checkIndex(); return set(atIndex(i), e); // from interface iterable public java.util.Iterator iterator() { return new Elementiterator(this); Il other fuctions public String toString() { return toString(this);
Clock in Java Found in Brandonu Inbox Hello my friends, I will need it in algorithm analysis (section after recursion). To find time the method call A(parameters) takes, you call try the following code in Java: long start Time = System.currentTimeMillis(); // Millis 1 = 0.001 second A (parameters); long endTime = System.current TimeMillis(); long t = endTime – startTime; I will use this in analysis of algorithms.
Expert Answer
Answer to The following information might be useful, please let me know if you need any other information…
OR