The book name is Java An introduction to problem sloving 7ed Plz give the code i
ID: 3854967 • Letter: T
Question
The book name is Java An introduction to problem sloving 7ed
Plz give the code in java and it match with the prof output below. Plz provide your output and match with my prof output.
The Assignment:
Chapter 12:
Programming Projects 9: This project is found starting on page 932.
Assignment Guidelines:
Write a parameterized class definition for a doubly linked list that has a parameter for the type of data stored in a node. Make the node class an inner class. Choosing which methods to define is part of this project. Also, write a program to thoroughly test your class definition.
Note:
This program is based on code from Listing 12.9. The solution given here includes support for iteration, both forward and reverse. Both forward and reverse iteration use the moreToIterate method, but backward iteration uses the resetIterationReverse rather than resetIteration. The ListNode class includes a previous instance variable which makes the previous variable in the outer class unnecessary. To make reverse iteration (especially resetIterationReverse) easier to write, there is a reference to the tail of the list as well as to the head of the list. An additional method, findInList, looks for an element in the list and sets current to point to that element if it is found. If it is not found, current is set to null. The method showListState is for testing and debugging purposes and prints the head of the list, the current element, the tail, and the number of elements in the list.
References:
Listing 12.9
Note:
The assignment must at least contain the following classes:
1. doublyLinkedList, in file doublyLinkedList.java and must contain the node class, as an inner class.
2. doublyLinkedListDemo, in file doublyLinkedListDemo.java
Listing 12.9
Sample Run:
----jGRASP: operation complete.
============================
============================
Find Elephant in list. Should NOT BE found.
Not found.
Head: Albatross Current: null Tail: Dolphin 4 items
Albatross
Baboon
Cheetah
Dolphin
============================
Find Cheetah in list. Should BE found.
Found.
Head: Albatross Current: Cheetah Tail: Dolphin 4 items
Albatross
Baboon
Cheetah
Dolphin
============================
Delete from the end of the list.
Head: Albatross Current: Elephant Tail: Elephant 5 items
Head: Albatross Current: null Tail: Dolphin 4 items
Albatross
Baboon
Cheetah
Dolphin
Iterate list in reverse.
Head: Albatross Current: Elephant Tail: Elephant 5 items
Beginning iteration.
Head: Albatross Current: Elephant Tail: Elephant 5 items
Head: Albatross Current: Dolphin Tail: Elephant 5 items
Head: Albatross Current: Cheetah Tail: Elephant 5 items
Head: Albatross Current: Baboon Tail: Elephant 5 items
Head: Albatross Current: Albatross Tail: Elephant 5 items
Finished iterating.
Head: Albatross Current: null Tail: Elephant 5 items
============================
Iterate to end of list.
Head: Albatross Current: Cheetah Tail: Elephant 5 items
Beginning iteration.
Head: Albatross Current: Cheetah Tail: Elephant 5 items
Head: Albatross Current: Dolphin Tail: Elephant 5 items
Head: Albatross Current: Elephant Tail: Elephant 5 items
Finished iterating.
Head: Albatross Current: null Tail: Elephant 5 items
============================
Add at beginning of list.
Head: Albatross Current: Cheetah Tail: Elephant 5 items
Albatross
Baboon
Cheetah
Dolphin
Elephant
============================
============================
Delete from the middle of the list.
Deleting current node: Caribou
Head: Baboon Current: Cheetah Tail: Elephant 4 items
Baboon
Cheetah
Dolphin
Elephant
============================
Go to previous node
Head: Baboon Current: Cheetah Tail: Elephant 5 items
Baboon
Caribou
Cheetah
Dolphin
Elephant
============================
Add more nodes to end of list.
Head: Baboon Current: Dolphin Tail: Elephant 5 items
Baboon
Caribou
Cheetah
Dolphin
Elephant
============================
Delete the first node.
Baboon
Caribou
Cheetah
============================
Add node to the middle of the list.
Head: Alligator Current: Baboon Tail: Cheetah 3 items
Head: Alligator Current: Baboon Tail: Cheetah 4 items
Alligator
Baboon
Caribou
Cheetah
============================
Add nodes to the end of the list.
Head: Alligator Current: Alligator Tail: Baboon 2 items
Head: Alligator Current: Baboon Tail: Cheetah 3 items
Alligator
Baboon
Cheetah
============================
Add a node to an empty list.
Head: Alligator Current: null Tail: Alligator 1 items
Head: null Current: null Tail: null 0 items
----jGRASP exec: java DoublyLinkedListDemo
Explanation / Answer
Given below is the solution to the given problem in Java. Comments are included in code below for reference. Sample execution output is also provided below.
File: DoublyLinkedList.java
File: DoublyLinkedListDemo.java
Sample Output:
============================
Find Elephant in list. Should NOT BE found.
Not found.
Head: Albatross Current: null Tail: Dolphin 4 items
Albatross
Baboon
Cheetah
Dolphin
============================
Find Cheetah in list. Should BE found.
Found.
Head: Albatross Current: Cheetah Tail: Dolphin 4 items
Albatross
Baboon
Cheetah
Dolphin
============================
Delete from the end of the list.
Head: Albatross Current: Elephant Tail: Elephant 5 items
Head: Albatross Current: null Tail: Dolphin 4 items
Albatross
Baboon
Cheetah
Dolphin
============================
Iterate list in reverse.
Head: Albatross Current: Elephant Tail: Elephant 5 items
Beginning iteration.
Head: Albatross Current: Elephant Tail: Elephant 5 items
Head: Albatross Current: Dolphin Tail: Elephant 5 items
Head: Albatross Current: Cheetah Tail: Elephant 5 items
Head: Albatross Current: Baboon Tail: Elephant 5 items
Head: Albatross Current: Albatross Tail: Elephant 5 items
Finished iterating.
Head: Albatross Current: null Tail: Elephant 5 items
============================
Iterate to end of list.
Head: Albatross Current: Cheetah Tail: Elephant 5 items
Beginning iteration.
Head: Albatross Current: Cheetah Tail: Elephant 5 items
Head: Albatross Current: Dolphin Tail: Elephant 5 items
Head: Albatross Current: Elephant Tail: Elephant 5 items
Finished iterating.
Head: Albatross Current: null Tail: Elephant 5 items
============================
Add at beginning of list.
Head: Albatross Current: Cheetah Tail: Elephant 5 items
Albatross
Baboon
Cheetah
Dolphin
Elephant
============================
Delete from the middle of the list.
Deleting current node: Caribou
Head: Baboon Current: Cheetah Tail: Elephant 4 items
Baboon
Cheetah
Dolphin
Elephant
============================
Go to previous node.
Head: Baboon Current: Cheetah Tail: Elephant 5 items
Baboon
Caribou
Cheetah
Dolphin
Elephant
============================
Add more nodes to end of list.
Head: Baboon Current: Dolphin Tail: Elephant 5 items
Baboon
Caribou
Cheetah
Dolphin
Elephant
============================
Delete the first node.
Head: Baboon Current: null Tail: Cheetah 3 items
Baboon
Caribou
Cheetah
Deleting current node: Caribou
============================
Add node to the middle of the list.
Head: Alligator Current: Baboon Tail: Cheetah 3 items
Head: Alligator Current: Baboon Tail: Cheetah 4 items
Alligator
Baboon
Caribou
Cheetah
============================
Add nodes to the end of the list.
Head: Alligator Current: Alligator Tail: Baboon 2 items
Head: Alligator Current: Alligator Tail: Cheetah 3 items
Alligator
Baboon
Cheetah
============================
Add a node to an empty list.
Head: Alligator Current: null Tail: Alligator 1 items
Head: null Current: null Tail: null 0 items
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.