|
-
Linked list problem
quest: find midlle element of a linked list in one traversal.
I have one soln. but i dnt think that goes in one traversal
it is
first=list;
sec=list;
while(sec->next != NULL)
{
first=first->next;
sec=sec->next->next;
}
cout<<first->val;
As when we are checking sec->next we are accessing linked list . and by incrementing first=first->next we are also traversing LL . so its not parrallel working not a single traversal
Any other soln.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks