# Test Efficiencies in Java Assignment Solution

July 02, 2024
Dr. Zara
🇺🇸 United States
Java
Dr. Zara Silvermist holds a PhD in Computer Science from the University of Texas, where she specialized in cutting-edge research in artificial intelligence and machine learning. With over five years of industry experience, she has completed over 500 Java Homework assignments with precision and expertise.
Key Topics
• Instructions
• Requirements and Specifications
Tip of the day
News

## Instructions

Objective
Write a java assignment program to test efficiency.

## Requirements and Specifications

Write the solutions for
• Testing Efficiency
• Testing internals
• Testing sorted Sequences

Source Code

TEST EFFICIENCY

`import java.util.Random;import edu.uwm.cs351.SortedSequence;import junit.framework.TestCase;public class TestEfficiency extends TestCase { private SortedSequence ss; private static final int POWER = 21; // 1 million entries private static final int TESTS = 100_000; protected void setUp() throws Exception {  super.setUp();  new Random();  try {   assert ss.size() == TESTS : "cannot run test with assertions enabled";  } catch (NullPointerException ex) {   System.err.println("You need to turn off assertions.");   System.err.println("Go to Run Configurations > TestEfficiency and go to the Arguments tab");   System.err.println("and remove -ea from the VM Arguments box.");   throw new IllegalStateException("Cannot run test with assertions enabled");  }  ss = new SortedSequence<>((i1,i2) -> i1 - i2);  int max = (1 << (POWER)); // 2^(POWER) = 2 million  for (int power = POWER; power > 1; --power) {   int incr = 1 << power;   for (int i=1 << (power-1); i < max; i += incr) {    ss.add(i);   }  } } @Override protected void tearDown() throws Exception {  ss = null;  super.tearDown(); } public void testSize() {  for (int i=0; i < TESTS; ++i) {   assertEquals((1<<(POWER-1))-1,ss.size());  } } public void testGet() {  ss.start();  int max = 1 << POWER;  for (int i=2; i < max; i += 2) {   Integer elem = ss.getCurrent();   assertEquals(i/10, elem/10);   ss.advance();  } } public void testRemove() {  int max = (1 << (POWER)); // 2^(POWER) = 2 million  int power = 4;  int incr = 1 << power;  ss.start();  for (int i=1 << (power-1); i < max; i += incr) {   while (ss.getCurrent().intValue() != i) {    assertTrue(ss.getCurrent()/10 <= i/10);    ss.advance();   }   ss.removeCurrent();  }  int removed = 1<<(POWER-power);  assertEquals(max/2 - 1 - removed, ss.size()); } public void testClone() {  int pow = POWER/2;  int num = 1 << pow;  while (pow > 1) {   --pow;   num += (1 << pow);   --pow;   num -= (1 << pow);  }  System.out.println("num = " + num);  ss.add(num-1);  ss.removeCurrent();  assertEquals(num+1, ss.getCurrent().intValue());  SortedSequence c = ss.clone();  assertEquals(num+1, c.getCurrent().intValue());  c.removeCurrent();  assertEquals(num+1, ss.getCurrent().intValue());  assertEquals(num+3, c.getCurrent().intValue());  ss.advance();  assertEquals(num+3, ss.getCurrent().intValue());  assertEquals(num+3, c.getCurrent().intValue());  ss.advance();  assertEquals(num+5, ss.getCurrent().intValue());  assertEquals(num+3, c.getCurrent().intValue());  ss.advance();  assertEquals(num+7, ss.getCurrent().intValue());  assertEquals(num+3, c.getCurrent().intValue()); }}`

TEST INTERNALS

`import edu.uwm.cs351.SortedSequence;public class TestInternals extends SortedSequence.TestInternals { /// Locked tests: @SuppressWarnings("unused") public void test() {  // Which single-character strings can fit in the given  // spots in this tree? (Using case-insensitive ordering)  // C  // / \  // A e  // \ /  // # \$  // Write your answer as a sorted set without spaces  // in which UPPERCASE letters precede lowercase letters.  // For example: {K,k,L}, not {k,K,L} or {K, k, L } or {K,L,k}  String answer1 = Ts(2034396360); // what keys at #  String answer2 = Ts(577043295); // what keys at \$  testCont(false); } @SuppressWarnings("unused") private void testCont(boolean ignored) {  // We are checking the "immediate greater ancestor" property  // for nodes in this tree:  // M  // / \  // / \  // G S  // / \ / \  // D K P W  // / \ \ \ \  // A F L Q Y  // Give the letter or "none"  String answer1 = Ts(960628806); // imm. gr. ancestor of A ?  String answer2 = Ts(1533686037); // imm. gr. ancestor of K ?  String answer3 = Ts(1529894885); // imm. gr. ancestor of Q ?  String answer4 = Ts(1790270167); // imm. gr. ancestor of Y ?  testCont2(false); } @SuppressWarnings("unused") private void testCont2(boolean ignored) {  // What are the valid cursor stacks for this tree?  // M  // / \  // / \  // G S  // / \ / \  // D K P W  // / \ \ \ \  // A F L Q Y  // Write the stack with square brackets, commas, with the top to the right  // but without spaces: e.g. [M,G,F] (when "F" is current)  String answer1 = Ts(1039507205); // the stack after we call start() ("A" is current").  String answer2 = Ts(1892415530); // The stack after we next call advance() ("D" is current").  String answer3 = Ts(1308770658); // The stack when "L" is current  String answer4 = Ts(395215552); // The stack when "Q" is current }}`

TEST SORTED SEQUENCE

`import edu.uwm.cs.junit.LockedTestCase;import edu.uwm.cs351.SortedSequence;public class TestSortedSequence extends LockedTestCase { Integer b1 = 100; Integer b2 = 50; Integer b3 = 33; Integer b4 = 25; Integer b5 = 20; SortedSequence s, se; SortedSequence ss; @Override protected void setUp() {  s = new SortedSequence ((i1,i2) -> i2 - i1);  se = new SortedSequence ((i1,i2) -> i1 - i2);  ss = new SortedSequence (String.CASE_INSENSITIVE_ORDER);  try {   assert 1/(b1-100) == 42 : "OK";   System.err.println("Assertions must be enabled to use this test suite.");   System.err.println("In Eclipse: add -ea in the VM Arguments box under Run>Run Configurations>Arguments");   assertFalse("Assertions must be -ea enabled in the Run Configuration>Arguments>VM Arguments",true);  } catch (ArithmeticException ex) {   return;  } } protected void assertException(ClassexcClass, Runnable f) {  try {   f.run();   assertFalse("Should have thrown an exception, not returned ",true);  } catch (RuntimeException ex) {   if (!excClass.isInstance(ex)) {    assertFalse("Wrong kind of exception thrown: "+ ex.getClass().getSimpleName(),true);   }  } } //// Locked Tests public void test() {  // "ss" is sorted case insensitive (so "a" and "A" are sorted together, before "b" and "B").  ss.add("Foo");  ss.add("FOO");  ss.add("foo");  ss.add("fu");  ss.add("bar");  ss.start();  assertEquals(Ts(540777888), ss.getCurrent());  ss.advance();  assertEquals(Ts(841015913), ss.getCurrent());  ss.add("BAR");  assertEquals(Ts(689167294), ss.getCurrent());  ss.advance();  assertEquals(Ts(1452336162), ss.getCurrent());  testCont(false); } private void testCont(boolean ignored) {  // ss is sorted case-insensitive  // ss = [bar, BAR, *Foo, FOO, foo, fu] ("Foo" is current)  ss.removeCurrent();  assertEquals(Ti(917957413), ss.size());  assertEquals(Ts(359804329), ss.getCurrent());  ss.add("Foo");  assertEquals(Ts(817754356), ss.getCurrent());  ss.advance();  assertEquals(Ts(815169093), ss.getCurrent()); } //// Numbered tests /// test0N: simple tests on the empty sequence public void test00() {  assertEquals(0,s.size()); } public void test01() {  assertFalse(s.isCurrent()); } public void test02() {  s.start(); // doesn't crash } public void test03() {  assertException(IllegalStateException.class,() -> s.getCurrent()); } public void test04() {  assertException(IllegalStateException.class, () -> s.advance()); } public void test05() {  s.start();  assertFalse(s.isCurrent()); } public void test06() {  assertEquals(0,s.size()); } /// test1N: tests of a single element sequence public void test10() {  s.add(b1);  assertEquals(1,s.size()); } public void test11() {  s.add(b2);  assertTrue(s.isCurrent()); } public void test12() {  s.add(b3);  assertSame(b3,s.getCurrent()); } public void test13() {  s.add(b4);  s.start();  assertSame(b4,s.getCurrent()); } public void test14() {  s.add(b5);  s.advance();  assertFalse(s.isCurrent()); } public void test15() {  s.add(b5);  s.advance();  s.start();  assertTrue(s.isCurrent()); } public void test16() {  assertException(NullPointerException.class, ()-> s.add(null));  assertEquals(0,s.size()); } public void test19() {  s.add(b1);  assertEquals(1,s.size());  assertTrue(s.isCurrent());  assertSame(b1,s.getCurrent()); } /// test2N: tests of two element sequences public void test20() {  s.add(b1);  s.add(b2);  assertEquals(2,s.size()); } public void test21() {  s.add(b3);  s.add(b4);  assertTrue(s.isCurrent()); } public void test22() {  s.add(b1);  s.add(b2);  assertSame(b2,s.getCurrent()); } public void test23() {  s.add(b1);  s.add(b2);  s.advance();  assertFalse(s.isCurrent()); } public void test24() {  s.add(b4);  s.add(b5);  s.start();  assertTrue(s.isCurrent());  assertEquals(2,s.size());  assertEquals(b4,s.getCurrent()); } public void test25() {  s.add(b2);  s.add(b5);  s.start();  s.advance();  s.start();  assertTrue(s.isCurrent());  assertEquals(2,s.size());  assertEquals(b2,s.getCurrent()); } public void test26() {  s.add(b1);  s.advance();  s.add(b2);  assertTrue(s.isCurrent());  assertSame(b2,s.getCurrent()); } public void test27() {  s.add(b3);  s.advance();  s.add(b4);  assertEquals(2,s.size());  assertTrue(s.isCurrent());  assertSame(b4,s.getCurrent()); } public void test28() {  s.add(b1);  assertException(NullPointerException.class, () -> s.add(null));  assertEquals(1,s.size()); } /// test3N: tests of three or more element sequences public void test30() {  s.add(b1);  s.add(b2);  s.add(b3);  assertEquals(3,s.size());  assertSame(b3,s.getCurrent());  s.advance();  assertFalse(s.isCurrent());  s.start();  assertSame(b1,s.getCurrent());  s.advance();  assertSame(b2,s.getCurrent());  s.advance();  assertSame(b3,s.getCurrent()); } public void test31() {  s.add(b4);  s.add(b5);  s.advance();  s.add(b1);  assertSame(b1,s.getCurrent());  s.advance();  assertEquals(3,s.size());  assertSame(b4,s.getCurrent());  s.advance();  assertSame(b5,s.getCurrent());  s.advance();  assertFalse(s.isCurrent()); } public void test32() {  s.add(b2);  s.add(b4);  s.start();  s.add(b3);  assertSame(b3,s.getCurrent());  s.advance();  assertSame(b4,s.getCurrent());  s.advance();  assertFalse(s.isCurrent());  s.start();  assertSame(b2,s.getCurrent());  assertEquals(3,s.size()); } public void test33() {  s.add(b1);  assertException(NullPointerException.class, () -> s.add(null));  s.add(b2);  assertSame(b2,s.getCurrent());  s.start();  assertSame(b1,s.getCurrent());  s.advance();  assertTrue(s.isCurrent());  assertSame(b2,s.getCurrent()); } public void test34() {  s.add(b4);  s.add(b5);  s.advance();  s.add(b3);  assertSame(b3, s.getCurrent());  assertEquals(3,s.size());  s.advance();  assertSame(b4,s.getCurrent()); } public void test35() {  s.add(b1);  s.add(b2);  s.add(b3);  s.start();  s.add(b4);  assertSame(b4,s.getCurrent());  s.advance();  assertException(IllegalStateException.class,() -> s.getCurrent() );  s.start();  assertSame(b1,s.getCurrent());  s.advance();  assertSame(b2,s.getCurrent());  s.advance();  assertSame(b3,s.getCurrent()); } public void test36() {  s.add(b5);  s.add(b4);  s.add(b3);  s.start();  s.advance();  s.add(b2);  assertEquals(b2,s.getCurrent());  assertEquals(4,s.size());  s.advance(); } public void test37() {  s.add(b1);  s.advance();  s.add(b2);  s.advance();  s.add(b3);  s.advance();  s.add(b4);  s.advance();  s.add(b5);  s.start();  assertSame(b1,s.getCurrent());  s.advance();  s.advance();  assertSame(b3,s.getCurrent());  s.advance();  s.advance();  s.advance();  assertFalse(s.isCurrent());  assertException(IllegalStateException.class,() -> s.advance() ); } public void test38() {  s.add(b1);  s.add(b2);  s.add(b3);  s.add(b4);  s.add(b5);  s.add(b5);  s.add(b4);  s.add(b3);  s.add(b2);  s.add(b1);  s.add(b1);  s.add(b2);  s.add(b3);  s.add(b4);  s.add(b5);  assertEquals(15,s.size());  s.start();  assertSame(b1,s.getCurrent()); s.advance();  assertSame(b1,s.getCurrent()); s.advance();  assertSame(b1,s.getCurrent()); s.advance();  assertSame(b2,s.getCurrent()); s.advance();  assertSame(b2,s.getCurrent()); s.advance();  assertSame(b2,s.getCurrent()); s.advance();  assertSame(b3,s.getCurrent()); s.advance();  assertSame(b3,s.getCurrent()); s.advance();  assertSame(b3,s.getCurrent()); s.advance();  assertSame(b4,s.getCurrent()); s.advance();  assertSame(b4,s.getCurrent()); s.advance();  assertSame(b4,s.getCurrent()); s.advance();  assertSame(b5,s.getCurrent()); s.advance();  assertSame(b5,s.getCurrent()); s.advance();  assertSame(b5,s.getCurrent()); s.advance();  assertFalse(s.isCurrent()); } public void test39() {  for (int i=0; i < 39; ++i) {   s.add(i);  }  assertEquals(39,s.size());  s.start();  for (int i=0; i < 39; ++i) {   assertTrue(s.isCurrent());   assertEquals(38-i,s.getCurrent().intValue());   s.advance();  }  assertFalse(s.isCurrent()); } /// test4N: tests of removeCurrent public void test40() {  s.add(b1);  s.removeCurrent();  assertFalse(s.isCurrent()); } public void test41() {  s.add(b2);  s.removeCurrent();  assertEquals(0,s.size()); } public void test42() {  s.add(b3);  s.add(b4);  s.removeCurrent();  assertFalse(s.isCurrent());  assertEquals(1,s.size());  s.start();  assertSame(b3,s.getCurrent()); } public void test43() {  s.add(b4);  s.add(b3);  s.start();  s.removeCurrent();  assertTrue(s.isCurrent());  assertSame(b4,s.getCurrent()); } public void test44() {  s.add(b4);  s.add(b5);  s.start();  s.removeCurrent();  assertTrue(s.isCurrent());  assertSame(b5,s.getCurrent()); } public void test45() {  s.add(b4);  s.add(b3);  s.add(b5);  s.start();  s.advance();  s.removeCurrent();  assertSame(b5,s.getCurrent());  s.advance();  assertFalse(s.isCurrent());  assertEquals(2,s.size());  s.start();  assertSame(b3,s.getCurrent()); } public void test46() {  s.add(b4);  s.add(b5);  s.add(b1);  s.removeCurrent();  assertEquals(2,s.size());  assertSame(b4,s.getCurrent()); s.advance();  assertSame(b5,s.getCurrent()); s.advance();  assertFalse(s.isCurrent()); } public void test47() {  s.add(b1);  s.add(b2);  s.add(b3);  s.add(b4);  s.add(b5);  s.start();  assertSame(b1,s.getCurrent()); s.advance();  assertSame(b2,s.getCurrent());  s.removeCurrent();  assertSame(b3,s.getCurrent()); s.advance();  assertSame(b4,s.getCurrent());  s.removeCurrent();  assertSame(b5,s.getCurrent()); s.advance();  assertFalse(s.isCurrent());  s.start();  assertSame(b1,s.getCurrent()); s.advance();  assertSame(b3,s.getCurrent()); s.advance();  assertSame(b5,s.getCurrent()); s.advance();  assertFalse(s.isCurrent()); } public void test48() {  s.add(b1);  s.add(b2);  s.add(b3);  s.add(b4);  s.add(b5);  s.start();  assertSame(b1,s.getCurrent()); s.removeCurrent();  assertSame(b2,s.getCurrent()); s.advance();  assertSame(b3,s.getCurrent()); s.removeCurrent();  assertSame(b4,s.getCurrent()); s.advance();  assertSame(b5,s.getCurrent()); s.removeCurrent();  assertFalse(s.isCurrent());  s.start();  assertSame(b2,s.getCurrent()); s.advance();  assertSame(b4,s.getCurrent()); s.advance();  assertFalse(s.isCurrent()); } public void test49() {  for (int i=0; i < 49; ++i) {   s.add(i);  }  s.start();  for (int i=0; i < 49; ++i) {   assertEquals(48-i,s.getCurrent().intValue());   if ((i%2) == 0) s.removeCurrent();   else s.advance();  }  s.start();  for (int i=0; i < 24; ++i) {   assertEquals(47-i*2,s.getCurrent().intValue());   s.removeCurrent();  }  assertEquals(0,s.size()); } /// test5N: errors with removeCurrent public void test50() {  assertException(IllegalStateException.class, () -> s.removeCurrent()); } public void test51() {  s.add(b1);  s.advance();  assertException(IllegalStateException.class, () -> s.removeCurrent()); } public void test52() {  s.add(b1);  s.removeCurrent();  assertException(IllegalStateException.class, () -> s.removeCurrent()); } public void test53() {  s.add(b1);  s.add(b2);  s.removeCurrent();  assertException(IllegalStateException.class, () -> s.removeCurrent()); } public void test54() {  s.add(b1);  s.add(b2);  s.add(b3);  s.add(b4);  s.add(b5);  s.advance();  assertException(IllegalStateException.class, () -> s.removeCurrent()); } public void test55() {  s.add(b5);  s.advance();  assertException(IllegalStateException.class, () -> s.removeCurrent());  s.add(b4);  s.advance();  s.advance();  assertException(IllegalStateException.class, () -> s.removeCurrent());  s.add(b3);  s.advance();  s.advance();  s.advance();  assertException(IllegalStateException.class, () -> s.removeCurrent());  s.add(b2);  s.advance();  s.advance();  s.advance();  s.advance();  assertException(IllegalStateException.class, () -> s.removeCurrent());  s.add(b1);  assertEquals(5,s.size());  assertSame(b1,s.getCurrent()); s.advance();  assertSame(b2,s.getCurrent()); s.advance();  assertSame(b3,s.getCurrent()); s.advance();  assertSame(b4,s.getCurrent()); s.advance();  assertSame(b5,s.getCurrent()); s.advance();  assertFalse(s.isCurrent()); } /// test6X: tests with distinguished equivalent elements public void test60() {  ss.add("six");  ss.add("Six");  ss.add("Sixty");  ss.add("SIX");  assertEquals("SIX", ss.getCurrent());  ss.advance();  assertEquals("Sixty", ss.getCurrent());  ss.advance();  assertException(IllegalStateException.class, () -> ss.getCurrent()); } public void test61() {  ss.add("six");  ss.add("SIX");  ss.add("six");  ss.start();  assertEquals("six", ss.getCurrent());  ss.advance();  assertEquals("SIX", ss.getCurrent());  ss.advance();  assertEquals("six", ss.getCurrent()); } /// test7X: tests of remove of equivalent elements public void test70() {  ss.add("seven");  ss.add("Seven");  ss.removeCurrent();  assertEquals(1, ss.size());  assertFalse(ss.isCurrent());  ss.start();  assertEquals("seven", ss.getCurrent());  ss.advance();  assertFalse(ss.isCurrent()); } public void test71() {  ss.add("Seven");  ss.add("seven");  ss.start();  ss.removeCurrent();  assertEquals(1, ss.size());  assertEquals("seven", ss.getCurrent()); } public void test72() {  ss.add("seven");  ss.add("seventy");  ss.add("SEVEN");  ss.removeCurrent();  assertEquals(2, ss.size());  assertEquals("seventy", ss.getCurrent());  ss.start();  assertEquals("seven", ss.getCurrent());  ss.advance();  assertEquals("seventy", ss.getCurrent()); } public void test73() {  ss.add("seven");  ss.add("seventy");  ss.add("Seventy");  ss.add("Seven");  ss.start();  ss.advance();  ss.advance();  assertEquals("seventy", ss.getCurrent());  ss.removeCurrent();  assertEquals("Seventy", ss.getCurrent()); } public void test74() {  ss.add("seven");  ss.add("seventy");  ss.add("Seventy-seven");  ss.add("Seven");  ss.add("sevens");  ss.add("SEVEN");  ss.add("Seventy");  ss.start();  ss.advance();  ss.advance();  ss.advance();  ss.advance();  assertEquals("seventy", ss.getCurrent());  ss.removeCurrent();  assertEquals("Seventy", ss.getCurrent()); } public void test75() {  ss.add("seven");  ss.add("five");  ss.add("Five");  ss.add("FIVE");  ss.add("eight");  ss.add("seventy");  ss.add("SEVEN");  ss.add("seventy-five");  ss.start();  ss.advance();  ss.advance();  ss.advance();  ss.advance();  assertEquals("seven", ss.getCurrent());  ss.removeCurrent();  assertEquals("SEVEN", ss.getCurrent());  ss.advance();  assertEquals("seventy", ss.getCurrent());  ss.advance();  assertEquals("seventy-five", ss.getCurrent()); } public void test77() {  ss.add("seven");  ss.add("Seven");  ss.add("seventy");  ss.add("seven");  ss.removeCurrent();  assertEquals("seventy", ss.getCurrent());  ss.start();  assertEquals("seven", ss.getCurrent());  ss.advance();  assertEquals("Seven", ss.getCurrent());  ss.advance();  assertEquals("seventy", ss.getCurrent()); } /// test9N: testing clone public void test90() {  SortedSequence c = s.clone();  assertFalse(c.isCurrent());  assertEquals(0, c.size()); } public void test91() {  s.add(b1);  SortedSequence c = s.clone();  assertTrue(s.isCurrent());  assertSame(b1,s.getCurrent()); s.advance();  assertFalse(s.isCurrent());  assertTrue(c.isCurrent());  assertSame(b1,c.getCurrent()); c.advance();  assertFalse(c.isCurrent()); } public void test92() {  s.add(b1);  s.advance();  SortedSequence c = s.clone();  assertFalse(s.isCurrent());  assertFalse(c.isCurrent());  c.start();  assertTrue(c.isCurrent());  assertSame(b1,c.getCurrent()); } public void test93() {  s.add(b1);  s.add(b2);  SortedSequence c = s.clone();  assertTrue(s.isCurrent());  assertTrue(c.isCurrent());  assertSame(b2,s.getCurrent());  assertSame(b2,c.getCurrent());  s.advance();  c.advance();  assertFalse(s.isCurrent());  assertFalse(c.isCurrent()); } public void test94() {  s.add(b2);  s.add(b1);  s.add(b3);  s.start();  SortedSequence c = s.clone();  assertSame(b1,s.getCurrent());  assertSame(b1,c.getCurrent());  s.advance();  c.advance();  assertTrue(s.isCurrent());  assertTrue(c.isCurrent());  assertSame(b2,s.getCurrent());  assertSame(b2,c.getCurrent());  s.advance();  c.advance();  assertTrue(s.isCurrent());  assertTrue(c.isCurrent());  assertSame(b3,s.getCurrent());  assertSame(b3,c.getCurrent()); } public void test95() {  s.add(b1);  SortedSequence c = s.clone();  s.add(b2);  assertSame(b2,s.getCurrent());  assertSame(b1,c.getCurrent());  s.advance();  assertFalse(s.isCurrent());  c.advance();  assertFalse(c.isCurrent());  assertEquals(1,c.size());  assertEquals(2,s.size()); } public void test96() {  s.add(b1);  s.add(b2);  SortedSequence c = s.clone();  s.add(b3);  assertSame(b3,s.getCurrent());  assertSame(b2,c.getCurrent());  c.advance();  s.advance();  assertFalse(s.isCurrent());  assertFalse(c.isCurrent());  assertEquals(2,c.size());  assertEquals(3,s.size()); } public void test97() {  s.add(b1);  s.add(b2);  s.add(b3);  s.start();  SortedSequence c = s.clone();  assertSame(b1,s.getCurrent());  assertSame(b1,c.getCurrent());  s.removeCurrent();  assertSame(b2,s.getCurrent());  assertSame(b1,c.getCurrent());  assertEquals(2,s.size());  assertEquals(3,c.size()); } public void test98() {  s.add(64);  s.add(32);  s.add(96);  s.add(16);  s.add(48);  s.add(80);  s.add(8);  s.add(24);  s.add(40);  s.add(56);  s.add(72);  s.add(88);  for (int i=4; i < 98; i += 8) {   s.add(i);  }  for (int i=2; i < 98; i += 4) {   s.add(i);  }  for (int i=1; i < 98; i += 2) {   s.add(i);  }  SortedSequence c = s.clone();  assertEquals(97, c.getCurrent().intValue());  c.start();  assertEquals(97, c.getCurrent().intValue());  c.removeCurrent();  s.start();  assertEquals(Integer.valueOf(97), s.getCurrent());  s.advance();  for (int i=1; i < 97; ++i) {   assertEquals(97-i,s.getCurrent().intValue());   assertEquals(97-i,c.getCurrent().intValue());   s.advance();   c.advance();  } } public void test99() {  s.add(b1);  s.add(b2);  s.add(b3);  s.start();  s.advance();  SortedSequence c = s.clone();  c.removeCurrent();  s.add(b4);  assertEquals(4, s.size());  assertEquals(2, c.size());  s.start();  c.start();  assertSame(b1, s.getCurrent());  assertSame(b1, c.getCurrent());  s.advance();  c.advance();  assertSame(b2, s.getCurrent());  assertSame(b3, c.getCurrent());  s.advance();  c.advance();  assertSame(b3, s.getCurrent());  assertFalse(c.isCurrent()); }}`

## Related Samples

Delve into our Java Assignment Samples for expertly crafted solutions to diverse programming challenges. These examples cover core concepts such as object-oriented programming, data structures, and algorithm implementation. Ideal for students seeking practical guidance and a deeper understanding of Java to excel in their coursework and beyond.