You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
0a1b753203 | 7 years ago | |
---|---|---|
.. | ||
resources | 7 years ago | |
README.md | 7 years ago | |
linked-list-find-length.go | 7 years ago |
README.md
LinkedList Find Length Source
What It Is
For example, the function should return 5 for linked list [1 -> 3 -> 1 -> 2 -> 1]
METHOD 1 (Iterative Solution)
-
- Initialize count as 0
-
- Initialize a node pointer, current = head.
-
- Do following while current is not NULL a) current = current -> next b) count++;
-
- Return count
- Input: Linked List =
[1 -> 3 -> 1 -> 2 -> 1]
- Output: count of nodes is
5
Algorithm Complexity
Complexity | Notation |
---|---|
Time Complexity |
O(n) |