Skip to main content
Add another example
Source Link
mjolka
  • 16.2k
  • 2
  • 29
  • 73

There are bugs in getFirstsetFirst, getLastsetLast, and reverse. Consider this code:

LList list = new LList(Arrays.asList(1));
list.setFirst(new NodeLL(2));
System.out.printf("%d%n", list.getLast().item);

The expected behaviour would be to print 2, but it actually prints 1.

The same goes for this code:

LList list = new LList(Arrays.asList(1));
list.setLast(new NodeLL(2));
System.out.printf("%d%n", list.getFirst().item);

and this:

LList list = new LList(Arrays.asList(2, 1));
TripletLL.reverse(list);
System.out.printf("%d%n", list.getLast().item);

There are bugs in getFirst, getLast, and reverse. Consider this code:

LList list = new LList(Arrays.asList(1));
list.setFirst(new NodeLL(2));
System.out.printf("%d%n", list.getLast().item);

The expected behaviour would be to print 2, but it actually prints 1.

The same goes for this code:

LList list = new LList(Arrays.asList(2, 1));
TripletLL.reverse(list);
System.out.printf("%d%n", list.getLast().item);

There are bugs in setFirst, setLast, and reverse. Consider this code:

LList list = new LList(Arrays.asList(1));
list.setFirst(new NodeLL(2));
System.out.printf("%d%n", list.getLast().item);

The expected behaviour would be to print 2, but it actually prints 1.

The same goes for this:

LList list = new LList(Arrays.asList(1));
list.setLast(new NodeLL(2));
System.out.printf("%d%n", list.getFirst().item);

and this:

LList list = new LList(Arrays.asList(2, 1));
TripletLL.reverse(list);
System.out.printf("%d%n", list.getLast().item);
Source Link
mjolka
  • 16.2k
  • 2
  • 29
  • 73

There are bugs in getFirst, getLast, and reverse. Consider this code:

LList list = new LList(Arrays.asList(1));
list.setFirst(new NodeLL(2));
System.out.printf("%d%n", list.getLast().item);

The expected behaviour would be to print 2, but it actually prints 1.

The same goes for this code:

LList list = new LList(Arrays.asList(2, 1));
TripletLL.reverse(list);
System.out.printf("%d%n", list.getLast().item);