Question: Write the following methods for a standard unordered singly linked list. There is a head pointer, but no tail pointer 7. // inserts the given
Write the following methods for a standard unordered singly linked list. There is a head pointer, but no tail pointer 7. // inserts the given key into the first position in the list (head) public void insertFirst (int key) // inserts the given key at the end of the list (there is no tail pointer) public void insertLast (int key) // inserts the keyl into the position immediately following the last instance of // key2 if key2 exists in the list. Otherwise, the keyl is inserted at the en of // the list. public void insertafter (int keyl, int key2) // removes the given key from the list if it exists, otherwise does nothing public void delete (int key)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
