Question: Suppose you have a class to represent a list. See prototype below. When you study the implementation of the class you remember that you implemented
Suppose you have a class to represent a list. See prototype below. When you study the implementation of the class you remember that you implemented it as a doubly linked list. Write DeleteAfter. Be sure to handle all error situations. public class ListClass { public ListClass(void) { List = 0 }; //constructor - initializes list to be empty public InsertAfter(itemtype item, int index); //validates index, inserts item at any position in list public itemtype DeleteAfter(int index); //validates index, deletes item at position index in a list, returns item handles any deletion //other useful functions of class omitted private boolean VerifyIndex (int index); //validates that index is position within list private ListNode PtrTo ( int index ); //returns a reference to the node at position index private ListNode List; //nodeptr private int Length; } //elsewhere you define private class ListNode { itemtype data; ListNode Right, Left; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
