Find length of a linked list (iterative and recursive) |
Answers
Answered by
0
Answer:
here's your Answer
Hello guys, here is one of the classical programming questions how do you find the length of a linked list using recursion and without recursion. This is not the about the LinkedList class of Java API but the linked list data structure which is made of nodes which contains both data and address of the next node. In order to calculate the length, you need to count all nodes in the linked list. Since it's a singly linked list you can only move in one direction from the head to tail. This coding problem was asked to me on my first interview with a multinational Investment bankAfter that, this question has been asked to me on several occasions in other Programming Job Interviews as well.
Similar questions