Lab 04

Double Double Linked List

 

Objective:

 

Write a doubly linked list of type double.  This link list is similar to the singly linked list except that each node in addition to having data and a next link it now has a previous link. 

Lab Solution

 

Requirements:

 

 

 

 

Additional Notes:

 

Add Node After Current Visual Concept

Remove Current Node Visual Concept

Example Dialog:

 

------------------------------------------------------

Double Double Linked List Tester

------------------------------------------------------

 

------------------------------------------------------

Inserting and Contains Test

------------------------------------------------------

 

SUCCESS: true

 

------------------------------------------------------

Removing Test

Removing first item, third item, and last item

------------------------------------------------------

 

SUCCESS: true

 

------------------------------------------------------

Modified Values Test

Changing all even values to negative values

------------------------------------------------------

 

SUCCESS: true

 

------------------------------------------------------

Printing the list

------------------------------------------------------

 

1.0

3.0

-4.0

5.0

-6.0

7.0

-8.0

Print last element: -8.0

Solutions Tests:

  1. Is your name written as a comment in all source files?
  2. Does the solution compile (No Syntax Errors)?
  3. Do all the tests work with the provided code?

a.       Insert and Contains Test?

b.      Delete Test?

c.       Modifying Values Test?

d.      Prints the correct last element?

 

Lab Report

  1. Create a section named “Problem” and describe this lab’s problem in your own words. (10pts).
  2. Create a section named “Solution Description” and describe how the code solves the problem in your own words. (10pts).
  3. Create a section named “Problems Encountered” and describe the various syntax, run-time, and logic errors that were encountered while implementing the solution. (10pts).
  4. If the reference to an object is lost and thus the object is now unreachable, what does the Java Virtual Machine (JVM) do with said object? (10pts).
  5. Describe the advantages and disadvantages for using a Linked List instead of an Array. (10pts).
  6. What are some advantages and disadvantages of using a doubly linked list versus a singly linked list? (10pts).

 

For Questions 07-10 you may assume the following String linked list code is provided.

 

  1. Using the provided code and assuming the linked list already has the data “Abc”, “efG”, “HIJ”, “kLm”, “noP”, the following code snippet’s purpose is to print all the values in the String linked list. Does this method work as described and if so, what does it print to the console? If the method does not work as described, then detail all syntax, run-time, and logic errors and how they may be fixed. (10pts)

 

  1. Using the provided code and assuming the linked list already has the data “Abc”, “efG”, “HIJ”, “kLm”, “noP”, the following code snippet’s purpose is to return the longest String in the linked list. Does this method work as described and if so, what String does this return? If the method does not work as described, then detail all syntax, run-time, and logic errors and how they may be fixed. (10pts)

 

  1. Using the provided code and assuming the linked list already has the data “Abc”, “efG”, “HIJ”, “kLm”, “noP”, the following code snippet’s purpose is to replace all “target” Strings with another String (the parameter “rValue”). Does this method work as described and if so, if we assume the value “Abc” is given as the target, then what is the resulting linked list values? If the method does not work as described, then detail all syntax, run-time, and logic errors and how they may be fixed. (10pts)

 

  1. Using the provided code and assuming the linked list already has the data “Abc”, “efG”, “HIJ”, “kLm”, “noP”, the following code snippet’s purpose is to remove the first five elements of the linked list. Does this method work as described and if so, what is the resulting linked list values? If the method does not work as described, then detail all syntax, run-time, and logic errors and how they may be fixed. (10pts)

 

Finally

Upload the Lab Solution’s source code (.JAVA file(s)) and the Lab Report’s text file to the CSCE Dropbox.