File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ <h1 align =" center " >LinkedList Find Length Source</h1 >
2
+
3
+ [ What It Is] ( #what-it-is )
4
+
5
+ ## What It Is
6
+
7
+ For example, the function should return 5 for linked list ` [1 -> 3 -> 1 -> 2 -> 1] `
8
+
9
+ ![ Preview Thumbnail] ( https://raw.githubusercontent.com/Dentrax/Data-Structures-with-Go/master/linked-list-find-length/resources/find-length.png )
10
+
11
+
12
+ METHOD 1 (Iterative Solution)
13
+ --------------------------
14
+
15
+ * 1 ) Initialize count as 0
16
+ * 2 ) Initialize a node pointer, current = head.
17
+ * 3 ) Do following while current is not NULL
18
+ a) current = current -> next
19
+ b) count++;
20
+ * 4 ) Return count
21
+
22
+ > * Input: Linked List = ` [1 -> 3 -> 1 -> 2 -> 1] `
23
+ > * Output: count of nodes is ` 5 `
24
+
25
+ ** Algorithm Complexity**
26
+
27
+ | Complexity | Notation |
28
+ | ----------------- | :---------:|
29
+ | ` Time Complexity ` | ` O(n) ` |
You can’t perform that action at this time.
0 commit comments