Hi Nitin

 

Reply embedded.

 

Thanks!! and have a nice day!!

Jaspreet

 

-----Original Message-----
From: nithin kotekar [mailto:[EMAIL PROTECTED]]
Sent
:
Friday, December 24, 2004 8:15 PM
To: [EMAIL PROTECTED]
Subject: (PT) query

 

Hi everybody,

 

Here's my query please revert if anybody could help me out.

1. How do i reverse a n single linked list in one iteration?

(i.e.) the linked list data contents should not be altered only temperoray variables and pointers can be assigned

 

            Jaspreet- > Well Nitin, of late my hobby has been to give atleast 1 technical interview per week. This has become a standard question these days.

I wish the companies could ask something different and innovative. Okkie, here’s the solution: (Apologies for no comments)

 

p = head;

q = p->next;

p->next = NULL;

while (q != NULL)

{

            r = q->next;

            q->next = p;

            p = q;

            q = r;

}

 

            Now what I would like u to try is to reverse a doubly linked list. Something different…

 

2. how do i take out the looping problem in a large linked list?

(All linked list are single linked list and can have an structure say struct node n{

int data;

struct node *p;

} so on)

 

            Jaspreet -> I gave a solution but I guess it was not liked by the group members. Lets c…

 

            Have 2 pointers to start of the linked list. Increment one pointer by 1 node and the other by 2 nodes. If there’s a loop the 2nd pointer will meet the

1st pointer somewhere. If it does, then you know there’s one. Lets c if some1 has a more efficient solution.

Thanks and Regards

Nithin

 

Yahoo! Groups Sponsor

ADVERTISEMENT
click here


Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.

To unsubscribe : [EMAIL PROTECTED]






Note:
This message is for the named person's use only.  It may contain confidential, proprietary or legally privileged information.  No confidentiality or privilege is waived or lost by any mistransmission.  If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender.  You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. MINDTECK (INDIA) LTD and any of its subsidiaries each reserve the right to monitor all e-mail communications through its networks.
Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity.
 
Thank You.



To unsubscribe : [EMAIL PROTECTED]




Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to