COMP 2210 Lab 8: Linked Nodes solution

$25.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (2 votes)

This lab focuses on the fundamental mechanics of using singly- and doubly-linked nodes as containers for physical storage. After completing the lab you should

  • Understand creation and linking of singly-linked nodes.
  • Understand creation and linking of doubly-linked nodes.

(This document is available outside of Canvas here.)

Set-up

  1. Open the COMP2210/labs directory on your Engineering H: drive. (If you didn’t complete the previous lab where you created this directory structure, do so now.)
  2. Create the lab08 directory.
  3. Download the zip file associated with this lab, store it in the COMP2210/labs/lab08 directory, and unzip the file.
  4. Open jGRASP to the lab08 directory.

Singly-linked nodes

  1. Open SinglyLinked.java in jGRASP and compile it.
  2. Set a breakpoint on line 18: client.basicExamples();
  3. Start the debugger and wait until execution is paused at the breakpoint.
  4. Step in to the call to basicExamples().
  5. Single-step to line 54: n = new Node(1);
  6. Open a viewer on n.
  7. Step over each remaining statement in basicExamples, making sure you understand the effect of each statement. (You may want to step in to the calls to length and contains.)

Close the viewer and end program execution.

  1. Clear any previous breakpoints you set in SinglyLinked.java.
  2. Set a breakpoint on line 19: client.add().
  3. Start the debugger and wait until execution is paused at the breakpoint.
  4. Step in to the call to add().
  5. Single-step to line 142: System.out.println(toString(n));
  6. Open a viewer on n.
  7. Click on the Interactions tab in the jGRASP Desktop.
  8. Use Interactions to practice inserting the node referenced by temp at various locations in the pointer chain. (You’ll have to repeat these steps each time you want to practice an insertion.)

Close the viewer and end program execution.

  1. Clear any previous breakpoints you set in SinglyLinked.java.
  2. Set a breakpoint on line 20: client.delete().
  3. Start the debugger and wait until execution is paused at the breakpoint.
  4. Step in to the call to delete().
  5. Single-step to line 157: System.out.println(toString(n));
  6. Open a viewer on n.
  7. Click on the Interactions tab in the jGRASP Desktop.
  8. Use Interactions to practice deleting various nodes in the pointer chain. (You may have to repeat these steps when you want to practice multiple deletions.)

Close the viewer and end program execution.

Doubly-linked nodes

  1. Open DoublyLinked.java in jGRASP and compile it.
  2. Set a breakpoint on line 18: client.basicExamples();
  3. Start the debugger and wait until execution is paused at the breakpoint.
  4. Step in to the call to basicExamples().
  5. Single-step to line 52: m = new Node(2);
  6. Open a viewer on n.
  7. Step over each remaining statement in basicExamples, making sure you understand the effect of each statement. (You may want to step in to the calls to length and contains.)

Close the viewer and end program execution.

  1. Clear any previous breakpoints you set in DoublyLinked.java.
  2. Set a breakpoint on line 19: client.add().
  3. Start the debugger and wait until execution is paused at the breakpoint.
  4. Step in to the call to add().
  5. Single-step to line 138: System.out.println(toString(n));
  6. Open a viewer on n.
  7. Click on the Interactions tab in the jGRASP Desktop.
  8. Use Interactions to practice inserting the node referenced by temp at various locations in the pointer chain. (You’ll have to repeat these steps each time you want to practice an insertion.)

Close the viewer and end program execution.

  1. Clear any previous breakpoints you set in DoublyLinked.java.
  2. Set a breakpoint on line 20: client.delete().
  3. Start the debugger and wait until execution is paused at the breakpoint.
  4. Step in to the call to delete().
  5. Single-step to line 156: System.out.println(toString(n));
  6. Open a viewer on n.
  7. Click on the Interactions tab in the jGRASP Desktop.
  8. Use Interactions to practice deleting various nodes in the pointer chain. (You may have to repeat these steps when you want to practice multiple deletions.)

Close the viewer and end program execution.