Computer Programming II Assignment 3: Linked List Utility Class, Assignments of Computer Science

Information about assignment 3 for cs122/504 computer programming ii course at pace university, spring 2006. Students are required to design and implement a linkedlistutility class with methods to create, reverse, print, and find the length of a linked list using node objects. The node class definition and assignment instructions.

Typology: Assignments

Pre 2010

Uploaded on 08/09/2009

koofers-user-08b
koofers-user-08b 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CRN: 22430/21519 Pace University Spring 2006
CS122/504 Computer Programming II
Assignment 3
Assigned on March 14, 2006
Due on April 11, 2006
1. Design and implement a linked list utility class LinkedListUtility based on the Node objects
defined below:
class Node {
int v;
Node next;
public Node(int v, Node next) {
this.v = v;
this.next = next;
}
}
The class should support the following methods:
a. public Node makeList(int n);
Return a linked list of n nodes, the first having value 1, the second having value 2, …,
the last having value n.
b. public int length(Node v);
Return the length of a linked list with v pointing to its first node.
c. public Node reverse(Node v);
Reverse the order of the linked list with v pointing to its first node, and return the
reference for the first node of the reversed linked list.
d. public void print(Node v);
Print in order the values of a linked list with v pointing to its first node.
Also write the main() method of the class to test out your LinkedListUtility class
implementation.
The assignment is also posted in forum Assignments inside Discussion Board of CS122/504
Blackboard. Submit a single source file as an attachment to your reply to my assignment 3 thread.
Please add assignment name, your name, your assignment completion date, and the above assignment
problem description as comments at the beginning of your source code.
Please make sure that your program works correctly, and the source code is formatted properly with
proper column alignment and line indentation. Add necessary concise comments to your tricky points
for helping readers understand your program. There will be penalties for lacking necessary comments
or improper code alignment or indentation.

Partial preview of the text

Download Computer Programming II Assignment 3: Linked List Utility Class and more Assignments Computer Science in PDF only on Docsity!

CRN: 22430/21519 Pace University Spring 2006

CS122/504 Computer Programming II

Assignment 3

Assigned on March 14, 2006 Due on April 11, 2006

  1. Design and implement a linked list utility class LinkedListUtility based on the Node objects defined below: class Node { int v; Node next;

public Node(int v, Node next) { this.v = v; this.next = next; } }

The class should support the following methods:

a. public Node makeList(int n); Return a linked list of n nodes, the first having value 1, the second having value 2, …, the last having value n. b. public int length(Node v); Return the length of a linked list with v pointing to its first node. c. public Node reverse(Node v); Reverse the order of the linked list with v pointing to its first node , and return the reference for the first node of the reversed linked list. d. public void print(Node v); Print in order the values of a linked list with v pointing to its first node.

Also write the main() method of the class to test out your LinkedListUtility class implementation.

The assignment is also posted in forum Assignments inside Discussion Board of CS122/ Blackboard. Submit a single source file as an attachment to your reply to my assignment 3 thread.

Please add assignment name, your name, your assignment completion date, and the above assignment problem description as comments at the beginning of your source code.

Please make sure that your program works correctly, and the source code is formatted properly with proper column alignment and line indentation. Add necessary concise comments to your tricky points for helping readers understand your program. There will be penalties for lacking necessary comments or improper code alignment or indentation.