Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Assignment VIII: Linked Nodes - Data Structures I | COMP 380, Assignments of Data Structures and Algorithms

Material Type: Assignment; Class: DATA STRUCTURES I; Subject: Computer Science; University: Wentworth Institute of Technology; Term: Spring 2007;

Typology: Assignments

Pre 2010

Uploaded on 08/18/2009

koofers-user-emz
koofers-user-emz 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Wentworth Institute of Technology
Division of Professional and Continuing Studies
COMP380 Section 71 - Data Structures I - Spring, 2007
Homework 8 – Linked Nodes
Instructor: Bob Goldstein (617) 912-2512
bob.goldstein@schepens.harvard.edu
http://home.comcast.net/~goldsteinr/Courses/index.html
http://goldstein.eri.harvard.edu/courses/index.html
http://myweb.wit.edu/goldsteinr/Courses/index.html
Due Date: April 3, 2007
Hand In: Printout of program code and dialogue of how it runs.
Purpose: Practice using Nodes to implement linked lists
1. Start with the UseNodes program we did in class. You will also need to make a copy, in your own
project of the Ford and Topp Nodes Class and Node class. The first step is just to get this project
implemented on your own machine and run it.
2. Add a method , insertBefore, to the Nodes class. This method should have the same
structure and operations as the insertAfter method, except that it inserts a node BEFORE
the input node instead of after. Note that you need to handle the special case of insertion at the
front of the list.
3. Add a method sortList to the Nodes class. This should operate by invoking the toArray
method to convert the list to an array, and then use the Arrays.sort() method to do the
sort, then convert the array back to a list.
Extra Credit:
Overload the insertAfter and the insertBefore methods so that you do
NOT have to make a node before calling them.
In other words, the three lines of code (taken from a class example):
Node<String> cNode = new Node<String>();
cNode.nodeValue = "Earth";
Nodes.insertAfter(front,"Venus",cNode);
would be replaced by the single line:
Nodes.insertAfter(front,"Venus");
and the creation of the node will be done INSIDE the overloaded insertAfter method.
/app/work/qkd9ox-413814-2765036-homework8-doc.doc 1 12/3/2020 12/3/2020

Partial preview of the text

Download Assignment VIII: Linked Nodes - Data Structures I | COMP 380 and more Assignments Data Structures and Algorithms in PDF only on Docsity!

Wentworth Institute of Technology

Division of Professional and Continuing Studies

COMP380 Section 71 - Data Structures I - Spring, 2007

Homework 8 – Linked Nodes

Instructor: Bob Goldstein (617) 912- bob.goldstein@schepens.harvard.edu http://home.comcast.net/~goldsteinr/Courses/index.html http://goldstein.eri.harvard.edu/courses/index.html http://myweb.wit.edu/goldsteinr/Courses/index.html Due Date: April 3, 2007 Hand In: Printout of program code and dialogue of how it runs. Purpose: Practice using Nodes to implement linked lists

  1. Start with the UseNodes program we did in class. You will also need to make a copy, in your own project of the Ford and Topp Nodes Class and Node class. The first step is just to get this project implemented on your own machine and run it.

2. Add a method , insertBefore , to the Nodes class. This method should have the same

structure and operations as the insertAfter method, except that it inserts a node BEFORE

the input node instead of after. Note that you need to handle the special case of insertion at the front of the list.

3. Add a method sortList to the Nodes class. This should operate by invoking the toArray

method to convert the list to an array, and then use the Arrays.sort() method to do the

sort, then convert the array back to a list. Extra Credit:

Overload the insertAfter and the insertBefore methods so that you do

NOT have to make a node before calling them. In other words, the three lines of code (taken from a class example): Node cNode = new Node(); cNode.nodeValue = "Earth"; Nodes.insertAfter(front,"Venus",cNode); would be replaced by the single line: Nodes.insertAfter(front,"Venus"); and the creation of the node will be done INSIDE the overloaded insertAfter method. /app/work/qkd9ox-413814-2765036-homework8-doc.doc 1 12/3/2020 12/3/