This document describes a novel sorting algorithm that employs a merge methodology to minimize compares. It is implemented generically using recursion. The algorithm separates nodes into a main list and auxiliary "attic" list, then merges the lists after sorting each individually. A JUnit test is included to test the sorting result.
Goal of this talk is to get through performance analysis process of simple calculator application implemented as a set of microservices with following FOSS toolset: k6 and gatling for traffic generation, prometheus for monitoring, perf Linux profiler and FlameGraph project for flame graphs generation.
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...Tsundere Chen
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime -Part 2
This is the slide for PyCon TW 2017 Day 3 PyPy's approach to construct domain-specific language runtime's Slide, and this is part 2, Part 1 is jserv's work, refer to his slide
Goal of this talk is to get through performance analysis process of simple calculator application implemented as a set of microservices with following FOSS toolset: k6 and gatling for traffic generation, prometheus for monitoring, perf Linux profiler and FlameGraph project for flame graphs generation.
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...Tsundere Chen
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime -Part 2
This is the slide for PyCon TW 2017 Day 3 PyPy's approach to construct domain-specific language runtime's Slide, and this is part 2, Part 1 is jserv's work, refer to his slide
JAVA OOP project; desperately need help asap im begging.Been stuck.pdffantasiatheoutofthef
JAVA OOP project; desperately need help asap im begging.
Been stuck on this for a week since my OOP skills are not good at all. Due in a couple hours so
im desperate. Codes needed will be provided at the end, thank you.
Codes:
DotChaser.java:
import java.util.*;
public class DotChaser {
public static Random rand = new Random(System.currentTimeMillis());
/**
* A "Thing" moves in a grid world. A TypeA Thing randomly
* decides to turn left or right (or not turn) every "round",
* and, afterward, takes a step forward. A TypeB Thing
* only considers making a random turn every 10th round.
*
* A STATIC CLASS? OH NO! GET IT OUT OF HERE!
*/
public static class Thing {
// dir: 0=North, 1=East, 2=South, 3=West.
// timeSinceLast: this is only important for "TypeB" Things.
public int row, col, dir, timeSinceLast;
public char lab = 'r';
public boolean isTypeB;
}
/**
* YOU'LL NEED TO PUT THIS SOMEWHERE ELSE
* HINT: WOULDN'T IT BE NICE TO HAVE A LIST OR QUEUE SO THAT
* WE DON'T HAVE TO USE NODES HERE?
* This class is for linked lists of Thing's
*/
public static class Node {
public Thing data;
public Node next;
}
// EEEEEK! STATIC METHODS!!! PLEASE FIND THEM A BETTER HOME.
public static void rightTurn(Thing t) {
t.dir = (t.dir + 1) % 4;
}
public static void leftTurn(Thing t) {
t.dir = (t.dir + 3) % 4;
}
public static void maybeTurn(Thing t) {
int i = rand.nextInt(3);
if (t.isTypeB) {
t.timeSinceLast++;
if (t.timeSinceLast == 10) {
t.timeSinceLast = 0;
if (i == 1) {
rightTurn(t);
}
if (i == 2) {
leftTurn(t);
}
}
} else {
if (i == 1) {
rightTurn(t);
}
if (i == 2) {
leftTurn(t);
}
}
}
public static void step(Thing t) {
final int[] dc = {
0, 1, 0, -1
}, dr = {
1, 0, -1, 0
};
t.row += dr[t.dir];
t.col += dc[t.dir];
}
/**
* This static method is ok :)
*/
public static void main(String[] args) {
int N = 200;
if( args.length != 0 )
N = Integer.parseInt(args[0]);
// INSTEAD OF A NODE, CREATE SOMETHING MORE USER-FRIENDLY.
Node L = null;
int count = 0;
while( true ) {
// Every N rounds, add another typeA and typeB Thing.
if( count % N == 0 ) {
// Add a typeA thing to the list.
// (GEE, THAT'S A LOT OF CODE FOR JUST CREATING ONE THING)
Thing tA = new Thing();
tA.row = 45;
tA.col = 50;
Node nA = new Node();
nA.data = tA;
nA.next = L;
L = nA;
// Add a typeB thing to the list
Thing tB = new Thing();
tB.row = 55;
tB.col = 50;
tB.lab = 'b';
tB.isTypeB = true;
Node nB = new Node();
nB.data = tB;
nB.next = L;
L = nB;
}
// Print out each thing.
// (SEEMS LIKE A NICE PRINTALL() METHOD CALL WOULD WORK HERE)
// (SEEMS LIKE A toString() METHOD IN THE CLASS WOULD ALSO BE NICE)
for( Node T = L; T != null; T = T.next )
System.out.println(T.data.row + " " + T.data.col + " " + T.data.lab);
System.out.println("done");
System.out.flush();
// Move each thing.
// (SEEMS LIKE A NICE MOVEALL() METHOD CALL WOULD WORK HERE)
for( Node T = L; T != null; T = T.next ) {
maybeTurn(T.data);
step(T.data);
}
count++;
}
}
}
Lab2_Tester.java
import org.junit.Test;
import static org.junit.Assert.assertEqual.
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfkostikjaylonshaewe47
Implement a queue using a linkedlist (java)
Solution
LinkedQueueImplement.java
import java.util.*;
class Node
{
protected int data;
protected Node link;
public Node()
{
link = null;
data = 0;
}
public Node(int d,Node n)
{
data = d;
link = n;
}
public void setLink(Node n)
{
link = n;
}
public void setData(int d)
{
data = d;
}
public Node getLink()
{
return link;
}
public int getData()
{
return data;
}
}
class linkedQueue
{
protected Node front, rear;
public int size;
public linkedQueue()
{
front = null;
rear = null;
size = 0;
}
public boolean isEmpty()
{
return front == null;
}
public int getSize()
{
return size;
}
/* Function to insert an element to the queue */
public void insert(int data)
{
Node nptr = new Node(data, null);
if (rear == null)
{
front = nptr;
rear = nptr;
}
else
{
rear.setLink(nptr);
rear = rear.getLink();
}
size++ ;
}
/* Function to remove front element from the queue */
public int remove()
{
if (isEmpty() )
throw new NoSuchElementException(\"Underflow Exception\");
Node ptr = front;
front = ptr.getLink();
if (front == null)
rear = null;
size-- ;
return ptr.getData();
}
/* Function to check the front element of the queue */
public int peek()
{
if (isEmpty() )
throw new NoSuchElementException(\"Underflow Exception\");
return front.getData();
}
/* Function to display the status of the queue */
public void display()
{
System.out.print(\"\ Queue = \");
if (size == 0)
{
System.out.print(\"Empty\ \");
return ;
}
Node ptr = front;
while (ptr != rear.getLink() )
{
System.out.print(ptr.getData()+\" \");
ptr = ptr.getLink();
}
System.out.println();
}
}
/* Class LinkedQueueImplement */
public class LinkedQueueImplement
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
/* Creating object of class linkedQueue */
linkedQueue lq = new linkedQueue();
/* Perform Queue Operations */
System.out.println(\"Linked Queue Test\ \");
char ch;
do
{
System.out.println(\"\ Queue Operations\");
System.out.println(\"1. insert\");
System.out.println(\"2. remove\");
System.out.println(\"3. peek\");
System.out.println(\"4. check empty\");
System.out.println(\"5. size\");
int choice = scan.nextInt();
switch (choice)
{
case 1 :
System.out.println(\"Enter integer element to insert\");
lq.insert( scan.nextInt() );
break;
case 2 :
try
{
System.out.println(\"Removed Element = \"+ lq.remove());
}
catch (Exception e)
{
System.out.println(\"Error : \" + e.getMessage());
}
break;
case 3 :
try
{
System.out.println(\"Peek Element = \"+ lq.peek());
}
catch (Exception e)
{
System.out.println(\"Error : \" + e.getMessage());
}
break;
case 4 :
System.out.println(\"Empty status = \"+ lq.isEmpty());
break;
case 5 :
System.out.println(\"Size = \"+ lq.getSize());
break;
default :
System.out.println(\"Wrong Entry \ \");
break;
}
/* display queue */
lq.display();
System.out.println(\"\ Do you want to continue (Type y or n) \ \");
ch = scan.next().charAt(0);
} while (ch == \'Y\'|| ch == \'y\');
}
}
Output :
Linked Queue Test
Queue Operations
1. inse.
The async/await paradigm is implemented in a variety of different popular programming languages, but it is not the same thing everywhere.
In this presentation I'll show you an overview of the basic asyncrounous programming in Rust "flavor".
We will se the why the community had decided to introduce this paradigm, and how it has matched some critical aspects with the Rust philosophy.
JVM Mechanics: Understanding the JIT's TricksDoug Hawkins
In this talk, we'll walkthrough how the JIT optimizes a piece Java code step-by-step. In doing so, you'll learn some of the amazing feats of optimization that JVMs can perform, but also some surprisingly simple things that prevent your code from running fast.
Slides from my Confitura 2012 presentation. The issues discussed during the talk will be described in my new (free!) ebook - see https://github.com/tomekkaczanowski/bad-tests-good-tests
These are the 4 functions #include KiostreamP using namespac.pdfJUSTSTYLISH3B2MOHALI
These are the 4 functions
#include KiostreamP using namespace std; stuct godeType. int info; aodeNype link; void
createList(nodeType*& first, nodeType & last); void printList nodeType & first int main(0
nodeType first, last unt numi greateList first, last) printList(first); SystemC PAUSE\"); return 0;
void createList nodeType & first, nodeType & last) int number; nodeType *newNode;
Solution
//EXAMPLE PROGRAM FOR SINGLE LINKED LIST
# include
# include
# include
struct node
{
int number;
node *next;
};
class singlelist
{
node *first,*prev,*temp,*curr;
public:
singlelist()
{
first=NULL;
}
void create()
{
cout<<\"Stop by -999\"<>temp->number;
while(temp->number!=-999)
{
temp->next=NULL;
if(first==NULL)
{
first=temp;
prev=first;
}
else
{
prev->next=temp;
prev=temp;
}
temp=new node;
cin>>temp->number;
} //end of while
}
void deletenode()
{
int num;
cout<<\"\ Enter the number to delete \";
cin>>num;
if(first->number==num)
{
first=first->next;
return;
}
else
{
prev=first;
curr=first->next;
while(curr->next!=NULL)
{
if(curr->number==num)
{
prev->next=curr->next;
return;
}
prev=curr;
curr=curr->next;
}
}
if(curr->number==num)
{
prev->next=NULL;
return;
}
cout<<\"\ No such number\";
}
void insertbefore()
{
int nu;
temp=new node;
cout<<\"\ Enter the number \";
cin>>temp->number;
cout<<\"\ before the number \";
cin>>nu;
temp->next=NULL;
prev=first;
curr=first;
/* if(first==NULL) //if the list is empty then we can insert in this way
{
first=temp;
return;
}*/
if(curr->number==nu)
{
temp->next=first;
first=temp;
return;
}
else
{
prev=curr;
curr=curr->next;
while(curr->next!=NULL)
{
if(curr->number==nu)
{
prev->next=temp;
temp->next=curr;
return;
}
prev=curr;
curr=curr->next;
}
}
if(curr->number==nu)
{
prev->next=temp;
temp->next=curr;
return;
}
cout<<\"\ No such number \";
}
void insertafter()
{
int nu;
temp=new node;
cout<<\"\ Enter the number \";
cin>>temp->number;
cout<<\"\ After the number \";
cin>>nu;
temp->next=NULL;
prev=first;
curr=first;
/* if(first==NULL) //if the list is empty then we can insert in this way
{
first=temp;
return;
}*/
if(curr->number==nu)
{
temp->next=first->next;
first->next=temp;
return;
}
else
{
prev=curr;
curr=curr->next;
while(curr->next!=NULL)
{
if(curr->number==nu)
{
temp->next=curr->next;
curr->next=temp;
return;
}
prev=curr;
curr=curr->next;
}
}
if(curr->number==nu)
{
curr->next=temp;
temp->next=NULL;
return;
}
cout<<\"\ No such number \";
}
void print()
{
cout<<\" The list is \"<number<<\"-->\";
temp=temp->next;
}
cout<<\"Nil\"<>ch;
switch(ch)
{
case 1:
s.insertbefore();
s.print();
break;
case 2:
s.insertafter();
s.print();
break;
case 3:
s.deletenode();
s.print();
break;
case 4:
s.print();
break;
case 5:
s.print();
exit(1);
}
}
getch();
}.
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfmail931892
How do I fix it in LinkedList.java?
this is what i did
LabProgram.java
LinkedList.java:
/**
* Defines a doubly-linked list class
* @author
* @author
*/
import java.util.NoSuchElementException;
public class LinkedList {
private class Node {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
private int length;
private Node first;
private Node last;
private Node iterator;
/**** CONSTRUCTORS ****/
/**
* Instantiates a new LinkedList with default values
* @postcondition
*/
public LinkedList() {
first = null;
last = null;
iterator = null;
length = 0;
}
/**
* Converts the given array into a LinkedList
* @param array the array of values to insert into this LinkedList
* @postcondition
*/
public LinkedList(T[] array) {
}
/**
* Instantiates a new LinkedList by copying another List
* @param original the LinkedList to copy
* @postcondition a new List object, which is an identical,
* but separate, copy of the LinkedList original
*/
public LinkedList(LinkedList original) {
}
/**** ACCESSORS ****/
public T getFirst() throws NoSuchElementException {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return first.data;
}
public T getLast() throws NoSuchElementException {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return last.data;
}
/**
* Returns the data stored in the iterator node
* @precondition
* @return the data stored in the iterator node
* @throw NullPointerException
*/
public T getIterator() throws NullPointerException {
if (iterator != null){
return iterator.data;
}else{
throw new NullPointerException("Iterator is off the end opf the list.");
}
}
/**
* Returns the current length of the LinkedList
* @return the length of the LinkedList from 0 to n
*/
public int getLength() {
return length;
}
/**
* Returns whether the LinkedList is currently empty
* @return whether the LinkedList is empty
*/
public boolean isEmpty() {
return length == 0;
}
/**
* Returns whether the iterator is offEnd, i.e. null
* @return whether the iterator is null
*/
public boolean offEnd() {
return iterator == null;
}
/**** MUTATORS ****/
public void addFirst(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
newNode.next = first;
first.prev = newNode;
first = newNode;
}
length++;
}
public void addLast(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
last.next = newNode;
newNode.prev = last;
last = newNode;
}
length++;
}
/**
* Inserts a new element after the iterator
* @param data the data to insert
* @precondition
* @throws NullPointerException
*/
public void addIterator(T data) throws NullPointerException{
if(iterator != null){
Node newNode = new Node(data);
newNode.next = iterator.next;
iterator.next = newNode;
if (iterator == first){
first = newNode;
}
}else{
throw new NullPointerException("Iterator is off the end opf the list.");
}
}
/
public void remov.
Using NetBeansImplement a queue named QueueLL using a Linked List .pdfsiennatimbok52331
Using NetBeans
Implement a queue named QueueLL using a Linked List (same as we did for the stack). This
implementation must be used in all the following problems.
Implement a queue QueueST using a stack (use StackLL).
Test your implementations in the main with examples.
Solution
Answer:-
import java.util.*;
/* Class Node */
class Node
{
protected int data;
protected Node link;
/* Constructor */
public Node()
{
link = null;
data = 0;
}
/* Constructor */
public Node(int d,Node n)
{
data = d;
link = n;
}
/* Function to set link to next Node */
public void setLink(Node n)
{
link = n;
}
/* Function to set data to current Node */
public void setData(int d)
{
data = d;
}
/* Function to get link to next node */
public Node getLink()
{
return link;
}
/* Function to get data from current Node */
public int getData()
{
return data;
}
}
/* Class linkedQueue */
class linkedQueue
{
protected Node front, rear;
public int size;
/* Constructor */
public linkedQueue()
{
front = null;
rear = null;
size = 0;
}
/* Function to check if queue is empty */
public boolean isEmpty()
{
return front == null;
}
/* Function to get the size of the queue */
public int getSize()
{
return size;
}
/* Function to insert an element to the queue */
public void insert(int data)
{
Node nptr = new Node(data, null);
if (rear == null)
{
front = nptr;
rear = nptr;
}
else
{
rear.setLink(nptr);
rear = rear.getLink();
}
size++ ;
}
/* Function to remove front element from the queue */
public int remove()
{
if (isEmpty() )
throw new NoSuchElementException(\"Underflow Exception\");
Node ptr = front;
front = ptr.getLink();
if (front == null)
rear = null;
size-- ;
return ptr.getData();
}
/* Function to check the front element of the queue */
public int peek()
{
if (isEmpty() )
throw new NoSuchElementException(\"Underflow Exception\");
return front.getData();
}
/* Function to display the status of the queue */
public void display()
{
System.out.print(\"\ Queue = \");
if (size == 0)
{
System.out.print(\"Empty\ \");
return ;
}
Node ptr = front;
while (ptr != rear.getLink() )
{
System.out.print(ptr.getData()+\" \");
ptr = ptr.getLink();
}
System.out.println();
}
}
/* Class LinkedQueueImplement */
public class LinkedQueueImplement
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
/* Creating object of class linkedQueue */
linkedQueue lq = new linkedQueue();
/* Perform Queue Operations */
System.out.println(\"Linked Queue Test\ \");
char ch;
do
{
System.out.println(\"\ Queue Operations\");
System.out.println(\"1. insert\");
System.out.println(\"2. remove\");
System.out.println(\"3. peek\");
System.out.println(\"4. check empty\");
System.out.println(\"5. size\");
int choice = scan.nextInt();
switch (choice)
{
case 1 :
System.out.println(\"Enter integer element to insert\");
lq.insert( scan.nextInt() );
break;
case 2 :
try
{
System.out.println(\"Removed Element = \"+ lq.remove());
}
catch (Exception e)
{
System.out.println(\"Error : \" + e.getMessage());
}
break;
case 3 .
OrderTest.javapublic class OrderTest { Get an arra.pdfakkhan101
OrderTest.java
public class OrderTest {
/**
* Get an array of specified size and pass it to Order.order().
* Report the results.
*/
public static void main(String[] args) {
if (args.length != 1) {//1
System.out.println(\"Usage: java OrderTest sizeOfArray\ \"
+ \"\\tor\ \\tjava OrderTest arrayFile\");
System.exit(1);
}
// create or read the int[]
int size = 0;
int[] array = new int[0];//5
try {
size = Integer.parseInt(args[0]);
array = ArrayOfInts.randomizedArray(size);
} catch (NumberFormatException nfe) {//8
try {
array = ArrayOfInts.arrayFromFile(args[0]);
size = array.length;
} catch (Exception e) {
System.err.println(\"unable to read array from \" + args[0]);
System.exit(1);//14
}
}
System.out.println(\"before:\");//15
for (int i = 0; i < array.length; i++) {//2 n
System.out.printf(((i+1) % 10 > 0) ? \" %d\" : \" %d\ \", array[i]);//1
}
int myNum = Order.order(array); //this is the call we want to measure
System.out.println(\"\ after:\");//18
for (int i = 0; i < array.length; i++) {//2 n
System.out.printf(((i+1) % 10 > 0) ? \" %d\" : \" %d\ \", array[i]);
}
System.out.println(myNum);
}
}
ArrayOfInts.java
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.Scanner;
public class ArrayOfInts {
/**
* Returns an array of consecutive ints from 1 to size.
*/
public static int[] orderedArray(int size) {
int[] a = new int[size];
for (int i = 0; i < size; i++) {
a[i] = i+1;
}
return a;
}
/**
* Returns a randomized array containing ints from 1 to size.
*/
public static int[] randomizedArray(int size) {
ArrayList aL = new ArrayList();
for (int i = 0; i < size; i++) {
aL.add(i+1);
}
Collections.shuffle(aL);
int[] a = new int[size];
for (int i = 0; i < size; i++) {
a[i] = aL.get(i);
}
return a;
}
/**
* Writes an int[] to a plain-text file with ints separated by spaces.
* Useful for creating input files for repeatable tests.
*/
public static void arrayToFile(int[] array, String outfile) {
try {
FileWriter fw = new FileWriter(outfile);
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter outFile = new PrintWriter(bw);
for (int i : array) {
outFile.print(i + \" \");
}
outFile.close();
} catch (IOException e) {
System.err.println(\"Could not write to \" + outfile + \"\ \" + e);
}
}
/**
* Read ints from a file and return them in an int[]
*/
public static int[] arrayFromFile(String infile) throws FileNotFoundException,
InputMismatchException {
Scanner scan = new Scanner(new File(infile));
ArrayList aL = new ArrayList();
while (scan.hasNext()) {
aL.add(scan.nextInt());
}
scan.close();
int[] a = new int[aL.size()];
for (int i = 0; i < a.length; i++) {
a[i] = aL.get(i);
}
return a;
}
}
Order.java
public class Order {
/**
* Take an int[] and reorganize it so they are in ascending order.
*/
public static int order(int[] array) .
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfclimatecontrolsv
PROBLEM STATEMENT:
In this assignment, you will complete DoubleEndedList.java that implements the ListInterface as
well as an interface called DoubleEndedInterface which represents the list's entries by using a
chain of nodes that has both a head reference and a tail reference. Be sure to read through the
code and understand the implementation.
WHAT IS PROVIDED:
- A driver class to test your code. You should not modify this file!
- A list interface (ListInterface.java)
- A double ended interface (DoubleEndedInterface.java)
- An incomplete DoubleEndedList class (DoubleEndedList.java)
WHAT YOU NEED TO DO:
4. Complete the DoubleEndedList class
4. Run the driver and make sure your output is exactly the same as mine (at the bottom of
Driver.java)
\} // end else numberofEntries--; else throw new IndexOut0fBoundsException("Illegal position
given to remove operation."); return result; // Return removed entry }//endreturnreve public T
replace(int givenPosition, T newEntry) \{ T replace(int givenPosition, T newEntry) \{ if
((givenPosition >=1)&& (givenPosition <= numberOfEntries)) \{ // Assertion: The list is not
empty Node desiredNode = getNodeAt (givenPosition); ToriginalEntry = desiredNode.getData();
desiredNode.setData(newEntry); return originalEntry; f // end if else throw new
IndexOut0fBoundsException("Illegal position given to replace operation."); replace if ((
givenPosition >=1)&& (givenPosition <= number0fEntries)) \{ // Assertion: The list is not
empty Node desiredNode = getNodeAt ( givenPosition); T originalEntry = desiredNode.
getData( ); desiredNode.setData(newEntry); return originalentry; \} // end if throw new
Index0ut0fBoundsException("Illegal position given to replace operation."); \} // end replace
public T getEntry(int givenPosition) \{ if ((givenPosition >=1) \&\& (givenPosition < =
number0fEntries ) ) \{ // Assertion: The list is not empty return getNodeAt (givenPosition).
getData(); else // end if throw new IndexOut0fBoundsException("Illegal position given to
getEntry operation."); \} // end getEntry public boolean contains ( T anEntry) \{ boolean found =
false; Node currentNode = firstNode; while (!found && (currentNode != null)) \{ if
(anEntry.equals (currentNode.getData())) else found = true; \} // end while currentNode =
currentNode. getNextNode () ; return found; \} // end contains public int getLength() \{ return
numberofEntries; \} // end getLength public boolean isEmpty() \{ return number0fEntries ==0;
\} // end isEmpty public T[] toArray() \{ // The cast is safe because the new array contains null
entries aSuppressWarnings ("unchecked") T[] result =(T[]) new 0bject [numberofEntries]; //
Unchecked cast int index =0; Node currentNode = firstNode; while ((index < numberOfEntries)
\&\& (currentNode != null)) \& result [ index ]= currentNode. getData () ; currentNode =
currentNode.getNextNode ( ); index++; 3 // end while return result; 3 // end toArray // Returns a
reference to the node at a given position. // Precondition: L.
1. /* Copyright 2014 Thomas Knudstrup
*
* A Novel Sort Algorithm :
* Employing a merge methodology minimizing compares.
* Implemented generically utilizing recursion.
* With a JUnit test to stimulate and test the result
*
*/
package tom.example.code;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class Sorter {
int count = 0;
Node<String> root;
Attic<String> attic;
@Test
public void testSort()
{
int i = 1;
Node<String> newRoot = attic.sort();
while(newRoot.next != null)
{
System.out.println("" + i++ + ":" +newRoot.key);