Link to home
Start Free TrialLog in
Avatar of Mallp
Mallp

asked on

Doubly linked list

Why do we refer to say
C = cur->prev->next  

instead of just saying

C = cur

for given 3 nodes A,B & C in a doubly circular sorted linked list.

If I am incorrect then please clearify what does one mean by
cur->prev->next  given that 3 nodes were given node A,B & C.
Avatar of tinchos
tinchos

I would say that it's just the same.

If you post a code using that, maybe I can help you a little more.

Tincho
Avatar of Mallp

ASKER

Here is an example.

void SpecializedList::InsertEnd(int item)
{
      struct node *temp = get_node(item);
      temp->info = item;
      if (head==NULL)
      {       head = temp;                  // head is assigned the value of temp.
            head->prev = temp;            
            head->next = temp;
            temp->prev = head;
            temp->next = head;
            tail = temp;                  // head is also a tail if only one node exists.
      }
      else
      {      
            cur=head;
            while (cur->next != head)
                  cur=cur->next;
            temp->prev = head->prev;
            temp->next = head;
            head->prev->next = temp;
            head->prev = temp;
            tail=temp;
      }
}

Then Mallp

I would say that it's just the same, but I would say that it's just a matter of coding style

It may be clearer to the person who wrote it.

Tincho
ASKER CERTIFIED SOLUTION
Avatar of efn
efn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned.  I will make a recommendation to the moderators on its resolution in approximately one week.  I would appreciate any comments by the experts that would help me in making a recommendation.

It is assumed that any participant not responding to this request is no longer interested in its final deposition.

If the asker does not know how to close the question, the options are here:
https://www.experts-exchange.com/help.jsp#hs5

Tinchos
EE Cleanup Volunteer
I think I answered it.

--efn
efn

I didn't post a recommendation for this as I'm directly involved in it and personally I would rather avoid judging the questions I participated in unless the recommendation is fairly clear to me.
I just posted the message just waiting for the asker to close his question.

Lets wait to see if he shows up and if that does not happen I'll post a recommendation for it.

Tincho
Tincho,

OK, no problem, thanks for your cleanup efforts.

--efn
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: efn {http:#9705722}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer