Ask Question

The following numbers are inserted into a linked list in this order:

10, 20, 30, 40, 50, 60

What would the following statements display?

pCur = head->next;

cout
cout data << endl;

a) 20 30

b) 40 50

c) 10 20

d) 30 40

+4
Answers (1)
  1. 12 April, 16:23
    0
    A. 20 30

    Explanation:

    Given

    Linked list: 10, 20, 30, 40, 50, 60

    Required

    The output of the following code segment

    pCur = head->next;

    cout
    cout data << endl;

    A linked list operates by the use of nodes which begins from the head to the next node, to the next, till it reaches the last;

    The first line of the code segment; "pCur = head->next; " shifts the node from the head to the next node

    The head node is the node at index 0 and that is 10;

    This means that the focus has been shifted to the next at index 1 and that is 20;

    So, pCur = 20

    The next line of the code segment; cout
    i. e. "20 " [Take note of the blank space after 20]

    The last line "cout data << endl; " contains two instructions which are

    1. pCur = next->data;

    2. cout
    (1) shifts focus to the next node after 20; This gives pCur = 30

    (2) prints the value of pCur

    Hence, the output of the code segment is 20 30
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “The following numbers are inserted into a linked list in this order: 10, 20, 30, 40, 50, 60 What would the following statements display? ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers