The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+3 votes

Consider the given Doubly Linked List:

Consider C like language code snippet with respect to doubly linked list given

"p" is pointer to linked list node


What is the output?Plz explain

asked in DS by Veteran (81.4k points) | 100 views

Edit : My approach : 

p=first->next->next->next->prev;  // p holds address for node with data value 9
p->next->next->prev=p;            // data value of node holding 10 changes to 9
printf("%d",p->next->next->prev->next->data); prints value of node hold value 8
I got ans 9 ?
plz give explaination


I think 10 will be output...

Why not @ akash.dinkar12

1 Answer

+6 votes
Best answer

Such questions are better done using pointer diagrams . Let us show each step of that as follows :

answered by Veteran (99.9k points)
selected by

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

33,701 questions
40,250 answers
38,858 users