tag:blogger.com,1999:blog-8712770457197348465.post1870265609418647817..comments2016-06-29T08:39:36.007-07:00Comments on Javarevisited: How do you find length of a Singly Linked list using Loop and RecursionJavin Paulhttps://plus.google.com/114528699166048052030noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-8712770457197348465.post-2785534069471015912016-05-20T21:46:39.963-07:002016-05-20T21:46:39.963-07:00Does this program is also the solution of question...Does this program is also the solution of question "How to find length of linked list in one pass"? I am not sure, please clarify.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-10343015951743173792016-05-20T21:45:30.533-07:002016-05-20T21:45:30.533-07:00@Anonymous, you can find a generic implementation ...@Anonymous, you can find a generic implementation of a Singly linked list in Java <a href="http://java67.blogspot.com/2016/01/how-to-implement-singly-linked-list-in-java-using-generics-example.html" rel="nofollow">here</a>.Javin Paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-13433862489011590042015-04-23T17:12:00.199-07:002015-04-23T17:12:00.199-07:00why recursive method doesn't work?
I tried it ...why recursive method doesn't work?<br />I tried it for head as well, but it keep returns 0 instead of number of nodes....Hengame Hoseinihttp://www.blogger.com/profile/00549308762180449992noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-90324653463871926832014-12-15T22:22:42.673-08:002014-12-15T22:22:42.673-08:00This question was asked to me as well, but they al...This question was asked to me as well, but they also asked me to find the complexity of both iterative and recursive solution. I said that if whether you use two pointer or one pointer approach you are checking almost each element, which means it's O(n) on times. Then he said, can you optimize the solution to reduce the time atleast to logarithimic or constant time. This question I couldn'Joytinoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-41520096040998610942014-10-13T22:57:48.880-07:002014-10-13T22:57:48.880-07:00Can you write a generic implementation of Singly l...Can you write a generic implementation of Singly linked list in Java?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-57157779265962434762014-10-13T22:57:06.321-07:002014-10-13T22:57:06.321-07:00Java LinkedList is indeed Doubly linked list imple...Java LinkedList is indeed Doubly linked list implementation of List and Deque interface in Java, as stated by Java doc. The do have two pointers first and last to point at both end of linked list. Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-4387597247835595112014-04-21T08:39:31.911-07:002014-04-21T08:39:31.911-07:00If Java LinkedList is doubly Linked List, then it ...If Java LinkedList is doubly Linked List, then it should contaion two null elements, one in the begining and other at the end. Please correct if I am wrongPanchamhttp://www.blogger.com/profile/03916691972111159446noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-52969345323630456802013-12-20T21:18:09.972-08:002013-12-20T21:18:09.972-08:00Java LinkedList is doubly Linked List. Java LinkedList is doubly Linked List. Aditya Chaudharyhttp://www.blogger.com/profile/15621484663643907417noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-2200661831048435782013-04-28T15:56:07.802-07:002013-04-28T15:56:07.802-07:00@Durai
Even i wonder why they ask this question.
...@Durai<br /><br />Even i wonder why they ask this question.<br /><br />@Linked list : Anyways thanks for sharing informationAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-5882904722100067652013-02-13T21:11:39.722-08:002013-02-13T21:11:39.722-08:00Just wondering why the interviewer asks these kind...Just wondering why the interviewer asks these kind of questions when we have an size() method to get the size?<br /><br />-DuraiAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-12193664148995733212012-06-03T20:30:40.586-07:002012-06-03T20:30:40.586-07:00This example to find length of linked list can als...This example to find length of linked list can also be extended to solve problems like how do you find middle element of linked list in Single pass or how to you find nth element from last in linked list in one loop. key here is to use two pointer one incrementing one at a time while other incrementing two at a time.LinkedListhttp://en.wikipedia.org/wiki/Linked_listnoreply@blogger.com