Skip to content

Commit 0a1b753

Browse files
committed
update readme & added image
1 parent 3b809c5 commit 0a1b753

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

linked-list-find-length/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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)` |
Loading

0 commit comments

Comments
 (0)