Consider two linked lists list1 with Integer values [1,2,3] and list2 with Integer values [4,5,6,7,8,9]
Suppose the merge method is called on list1 with list2 as parameter.
How many time will the following loop while((ptrThis != null) && (ptrParam != null)) iterate? Blank 1. Fill in the blank, read surrounding text.
After 3 iterations what will the value of ptrThis be? Blank 2. Fill in the blank, read surrounding text.
What will the value of ptrParam be? Blank 3. Fill in the blank, read surrounding text.
Do the pointer in both lists reach null at the same time? Yes/No Blank 4. Fill in the blank, read surrounding text.
void merge(Node *first, Node **second)
{
Node *firstRef = first;
// finding the lat node of first linked list
while (firstRef->next != NULL)
{
firstRef = firstRef->next;
}
firstRef->next = *second;
}
Comments
Leave a comment