Question
This method has code checking that obj is an instance of DoublyLinkedList, and then either return false or performs the typecast. You will need to
This method has code checking that obj is an instance of DoublyLinkedList, and then either return false or performs the typecast. You will need to perform a list traversal and check that the element in each Entry is equal to the element at the identical index in otherList. The algorithm you must implement in the area labeled // add code here is
here are the pseudocode for completing the following method:
set trav to the first Entry in the linked list
for i = 0 to size
set elem qual to the element at index i in otherList
if !(trav's element and elem are equal elements)
return false
End if
set trav equal to the next Entry in the list
End for
return true
________________________________________________________
public boolean equals(Object obj) {
if (!(obj instanceof List)) {
return false;
} else {
List
if (otherList.size() != size) {
return false;
}
// add your code here
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started