Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

answer please drom 63 to 67 LTE 4G+ \"il 20% 7:24 PM Question Anonymous Asked ab

ID: 3910655 • Letter: A

Question

answer please drom 63 to 67

LTE 4G+ "il 20% 7:24 PM Question Anonymous Asked about hours ago 5. Define the method union for the class LinkedBag 56. Define the method intersection for the cdass LinkedBag 57. Define the method difference for the class LinkedBag 8 In a doubly linked chain, Define a class to represent a node in a doubly linked chain. Write the class as an inner class of a dass that implements the ADT bag. You can omit set and get methods FirstNode 59. Repeat question 12, but instead write the class within a package that corntains an implementation of the ADT bag. Set and get methods will be necessary 60. List the steps necessary to add a node to the beginning of the doubly linked chain. 6t, List the steps necessary to remove the first node from the b ning of the doubly linked chain 62. If currentNode in the contains method becomes null. What value does the method return when the bag is not empty public boolean contains(T anEntry) [ boolean found false Node current Node firstNode while (found && (currentNode :e nul) t if (anEntry.equals(currentNode.data)) true else nt Node.next; current return 63. Trace he execution of the method contains when the bag is empty. What is the r 64. The code that we developed to add a node to an empty chain is Node newNode - new Node(newEntry); firstNode newNode; code that we just developed to add to the beginning of a chain is e newNode - new Node(newEntry); newNode.next firstNode firstNode newNode Why do these three statements also work correctly when the chain is empty 65. What steps are necessary to remove the first node in a chain of five nodes 66. What steps are necessary to remove the third node in a chain of five nodes 67. Instead of calling the method getReferenceTo,c ould the method remave e called the original definition of contains Explain.srfun answer them all please ! from 55 to 67 ( ignore 58 and 65) 0 There are no answers yet

Explanation / Answer

63 ) Answer: false

Explanation: when the bag is empty so firstNode is null, found is initialised to false and currentNode is set to null as firstNode is null since the Bag is Empty. So the while loop condition is not satisfied.

It returns false


64) YES, The 3 statement will work .

Explanation :
firstNode = newNode it works because firstNode is null and Now the firstNode because the newNode

II) Since firstNode = null for empty bag, So newNode.next = null and firstNode = newNode will also work
So firstNode is the newNode now.


65) Lets Consider the first Five Node

A-->B-->C-->D-->E
|
firstNode

Since firstNode points to A and we need to remove A. so JUST Make firstNode point to B
firstNode = firstNode.next

The above statement will forget about A and it will be removed from our list


66) A-->B-->C-->D-->E
|
firstNode

secondNode = firstNode.next
thirdNode = firstNode.next.next

Now Since we need to remove third node, So B should point to D ..Means 2nd Node next pointer(B) should pOINT TO 3RD node Next Pointer (D)

secondNode.next = thirdNode.next

The ablve statement will link B-->D and C will be removed

A-->B-->D-->E


67)
NO, getReference will return the reference of node if found OR will return null if node is not found.
Contains cannot be called because it returns true or false.
returning true means Node is present but we need to iterate again for reference


Thanks, PLEASE UPVOTE if helpful