1 votes 1 votes Why here implementation A is wrong.I feel it is correct. Niharika 1 asked Jan 16, 2018 Niharika 1 415 views answer comment Share Follow See all 7 Comments See all 7 7 Comments reply Manu Thakur commented Jan 16, 2018 reply Follow Share head is a pointer of type node, which contains the address of the first node. head will be passed as parameter to this function insert, so to hold a pointer we need a double pointer variable. for example int i; int *a = &i; int **b =&a; so, technically code 2 is correct but not code 1. 1 votes 1 votes Niharika 1 commented Jan 16, 2018 reply Follow Share Thank you 0 votes 0 votes thepeeyoosh commented Jan 16, 2018 reply Follow Share @manu Suppose Linked list nodes are like {Data , Next node ptr} Address of head = 4000. Address of head_ref = 5000 Head_ref {4000}| Head{1000} -> {1,2000} -> {2,3000} -> {3, NULL} NewNode{x, NULL} (suppose address of NewNode 6000) After implementation first code NewNode{x, 1000} Head{6000} I here looking everything is fine , how implementation is wrong. Please describe .I am not getting 0 votes 0 votes Ashwin Kulkarni commented Jan 16, 2018 reply Follow Share @manu sir, head_ref is pointer to head pointer thats why ** is correct and also head is pointer to LL so simply * is also correct. I think everything looks fine.! 0 votes 0 votes MiNiPanda commented Jan 16, 2018 reply Follow Share Manu sir, As you said, to hold a pointer variable we a need double pointer variable.. then what type of variable do we need to hold the address of a pointer type variable? 0 votes 0 votes Anu007 commented Jan 16, 2018 reply Follow Share I feel code 1 is also correct. 0 votes 0 votes Manu Thakur commented Jan 16, 2018 reply Follow Share I am sorry! I think code 1 is also correct, as it's pass by value. If function insert is called as insert(1000,5); then head will contain the value 1000, we are not storing the address of head. 0 votes 0 votes Please log in or register to add a comment.