Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following information might be useful, please let me know if you need any other information Description Hi Everyone, Here is assignment 5 of 62:206

image text in transcribed
The following information might be useful, please let me know if you need any other information image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
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. 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

Define Administration and Management

Answered: 1 week ago

Question

Define organisational structure

Answered: 1 week ago

Question

Define line and staff authority

Answered: 1 week ago

Question

Define the process of communication

Answered: 1 week ago

Question

Explain the importance of effective communication

Answered: 1 week ago

Question

What lessons in OD contracting does this case represent?

Answered: 1 week ago

Question

Does the code suggest how long data is kept and who has access?

Answered: 1 week ago