Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a Doubly Linked List with JAVA Output: The elements of the list are: Al Amy Beth Bob (Pre-written code below) class DLinkedListTemplate { and

Create a Doubly Linked List with JAVA

Output:

The elements of the list are: Al Amy Beth Bob

(Pre-written code below)

class DLinkedListTemplate { and a reference to the next node. */ private class Node { String value; // Value of a list element Node next; // Next node in the list Node prev; // Previous element in the list Node(String val, Node n, Node p) Node(String val) { // Just call the other (sister) constructor this(val, null, null); } } public DLinkedList() { first = null; last = null; } public boolean isEmpty() public int size() public void add(String e) { // Add to end of existing list } } public void add(int index, String e) { } public String toString() { StringBuilder strBuilder = new StringBuilder(); // Use p to walk down the linked list Node p = first; while(p != null) { strBuilder.append(p.value + " "); p = p.next; } return strBuilder.toString(); public String remove(int index) { public boolean remove(String element) // Locate the node targeted for removal Node pred = target.prev; // Node before the target Node succ = target.next; // Node after the target // Route forward and back pointers around // the node to be removed public static void main(String [] args) { DLinkedList ll = new DLinkedList(); ll.add("Amy"); ll.add("Bob"); ll.add(0, "Al"); ll.add(2, "Beth"); ll.add(4, "Carol"); System.out.pr

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago