Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a nonrecursive, reference-based implementation of the ADT sorted list o

ID: 3638827 • Letter: 1

Question

1. Write a nonrecursive, reference-based implementation of the ADT sorted list of object as a Java class SortedListRefBased such that
a. Duplicates are allowed
b. Duplicates are not allowed, and operations must prevent duplicates from entering the list.
2. Design and implement an ADT that represents a calendar date. You can represent a date's month, day, and year as integers(for example, 5/15/2011). Include operations that advance the date by one day and provide two operations to display the date by using either numbers(05/16/2011) or words for the months(May 16, 2011). As an enhancement, include the name of the day.

Explanation / Answer

// **************************************************** // Reference-based implementation of ADT list using arrays. // **************************************************** public class List { // reference to linked list of items public static final int MAX_LIST = 20; public static final int NULL = -1; private ListItem item[] = new ListItem[MAX_LIST]; // data private int next[] = new int[MAX_LIST]; // pointer to next item private int head; // pointer to front of list private int free; // pointer to front of free list private int numItems; // number of items in list // Constructor must initialize used list to empty and free list to // all available nodes. public List() { int index; for (index = 0; index