0 votes 0 votes Options: 10, 12,14, 16, 18, 20 20, 18, 16, 14, 12, 10 12, 10, 16, 14, 20, 18 NONE DS test-series zeal + – DAWID15 asked Dec 22, 2022 DAWID15 529 views answer comment Share Follow See all 3 Comments See all 3 3 Comments reply Kabir5454 commented Dec 22, 2022 reply Follow Share none ? 0 votes 0 votes DAWID15 commented Dec 22, 2022 reply Follow Share They marked B as right one. But I feel A should be the answer. 1 votes 1 votes Kabir5454 commented Dec 22, 2022 reply Follow Share Sorry my bad . correct answer is (B) . 0 votes 0 votes Please log in or register to add a comment.
Best answer 1 votes 1 votes So , we got the initial list and the last while loop just print the list in reverse order . So correct answer is (B) . https://stackoverflow.com/questions/9086372/how-to-compare-pointers#:~:text=Two%20pointers%20of%20the%20same,2).&text=%5B...%5D,are%20null%2C%20they%20compare%20equal. Kabir5454 answered Dec 22, 2022 • selected Dec 23, 2022 by DAWID15 Kabir5454 comment Share Follow See all 3 Comments See all 3 3 Comments reply DAWID15 commented Dec 22, 2022 reply Follow Share @Kabir5454 so The reason why we got reverse list is because when the loop breaks the FRONT pointer is pointing to the element 20. That means now due to this the list will start from 20 onwards. RIght?Please do reply if this is the reason.If that’s the case then I overlooked the final position of pointer and so I felt the answer should have been A. 0 votes 0 votes Kabir5454 commented Dec 22, 2022 reply Follow Share There are 4 pointers namely ,$Head$,$Tail$ ,$Front$,$Back$ . $Head$ points to starting node of the list . $Tail$ points to ending node of the list . Stating of the program $Front=Head$ , which implies $Front$ also start pointing to starting node of the list and $Back=Tail$ , which implies $Back$ also start pointing to last node of the list. in the program we manipulate $Front$ and $Back$ pointer but remember $Head$,$Tail$ pointer still points to starting node and ending node of the list. After the while($Front$!=$Back$) loop breaks both $Front$ and $Back$ points to $Null$ that’s the reason the while loop terminates . Now after that we again initialize $Back=Tail$ .[ $Tail$ still points to end of the list] . Now the last while loop is iterating the while loop from backwards Which produce output as reverse of the list . (I already attached each step while when the first while loop runs then what will be the output in each iteration) 1 votes 1 votes DAWID15 commented Dec 23, 2022 reply Follow Share Ah! Got it. Thanks. 0 votes 0 votes Please log in or register to add a comment.