2 votes 2 votes DS data-structures linked-list made-easy-test-series + – Sourabh Kumar asked Jan 31, 2016 recategorized Jan 7 by Hira Thakur Sourabh Kumar 3.0k views answer comment Share Follow See 1 comment See all 1 1 comment reply Sourabh Kumar commented Feb 1, 2016 reply Follow Share i think it is the answer 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes P1 ----> P1 --> Next P2 ---> P2 --> Next --> Next Everytime when P1 cross 1 element, P2 will cross 2 element. P2 will be null then P1 will be at position (length of LINKED LIST)/2 i.e. Middle of the list. Digvijay Pandey answered Feb 1, 2016 Digvijay Pandey comment Share Follow See all 3 Comments See all 3 3 Comments reply Sourabh Kumar commented Feb 1, 2016 i edited by Sourabh Kumar Feb 1, 2016 reply Follow Share How the ternary conditions works Means If p2 next =! 0 Then p2=p2 next next If p2 next =0 Then p2=0 Am I right Then p1 will point mid+1 position. 0 votes 0 votes rude commented Apr 5, 2016 reply Follow Share Sourabh, Conditional operator is used to check that (P->next) should not be NULL, else if it is NULL then (P->next->next) will cause runtime error and program will crash. If you want to read more about this then read it here. http://www.geeksforgeeks.org/write-a-c-function-to-print-the-middle-of-the-linked-list/ 0 votes 0 votes Sourabh Kumar commented Apr 28, 2016 reply Follow Share My friends can you explain littile bit more Bcz I want to know how the above ternary condition work in the program. How can we replace this condition by if else Is the way I write above is correct I know a==b? Condition but don't know a=b? And anywhere in let us c book I don't see a=b? condition 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes It is printing mid+1 ..... Anup dogrial answered Jan 6, 2020 Anup dogrial comment Share Follow See all 0 reply Please log in or register to add a comment.