00:01
This question asks us to implement a method with signature concatenate linked q for the link q class that takes all elements of q2 and appends them to the end of the original q.
00:10
The operation has to run an 01 time and result in q2 being an empty q.
00:14
So 01 time means we actually cannot use any loops because using a loop would mean we would run at an o of end time.
00:30
So here the approach we're going to take is if the list knows are accessible and the q is based on the node itself, and we can adjust the references.
00:40
Instead of having to use a loop, a y loop to check if q2 is empty and then remove everything from q2 to q1, what we can actually do is simply adjust the references so that we can access them directly.
00:53
So public void, concatenate with the link to q.
01:07
With the element and then q we can say list .tail that set next so we're setting the next reference to the tail as and then we're going to set that to the linked cues dot list.
01:30
Head node so we're going to set the next of the tail to the head so that you can continue on then we'll set list dot tail to q .taltel list .tale.
01:42
So now the tail reference points to the end of the q.
01:48
And so this is this first step here.
01:51
We altered the tail references next.
01:55
Right.
01:55
So let's say this is our link node, our original list right here.
01:59
This is our tail node.
02:02
We set the next one to our q...