Skip to content

Commit bf73965

Browse files
committed
updated complexity for approaches
1 parent 0290e8c commit bf73965

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

datastructures.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Indexer for Data Structures Lover
177177

178178
* APPROACH 6: Using recursion
179179
* [JAVA](Java/Data-Structures/LISTS/MISC/Nth-node-from-end/Approach6.java)
180-
* complexity
180+
* [complexity](docs/complexity.md#find-the-nth-node-from-end-in-single-linked-list)
181181

182182
## :octocat: STACKS
183183

docs/complexity.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ This page contains the complexities of different algorithms in this repository.
8585
* LINKED LIST
8686
* [ARRAYLISTS](#arraylists-(JAVA))
8787
* [VECTORS](#vectors-(C++JAVA))
88-
* MISC
88+
* [MISC LISTS](#misc-lists)
89+
* [Find the nth node from end in single linked list](#find-the-nth-node-from-end-in-single-linked-list)
8990
* [STACKS](#stacks)
9091
* [FIXED ARRAY STACK](#fixed-array-stack)
9192
* [DYNAMIC ARRAY STACK](#dynamic-array-stack)
@@ -432,6 +433,19 @@ SNo. | Operations | Order and Type of Time Complexity O(n) | Order and Type of S
432433
SNo. | Operations | Order and Type of Time Complexity O(n) | Order and Type of Space Complexity
433434
---- | ---------- | -------------------------------------- | ----------------------------------
434435

436+
#### MISC LISTS
437+
438+
##### Find the nth node from end in single linked list
439+
440+
SNo. | APPROACH | Order and Type of Time Complexity O(n) | Order and Type of Space Complexity
441+
---- | ---------- | -------------------------------------- | ----------------------------------
442+
1 | Compute the size while adding | O(n) -- Linear | O(1) -- Constant
443+
2 | Using two current pointers | O(n^2) -- Quadratic | O(1) -- Constant
444+
3 | Using hashtable | O(n) -- Linear | O(n) -- Linear
445+
4 | Using Hashtable while adding | O(1) -- Constant | O(n) -- Linear
446+
5 | Finding node in one scan | O(n) -- Linear | O(1) -- Constant
447+
6 | Using recursion | O(n) -- Linear | O(n) -- Linear
448+
435449
### STACKS
436450

437451
#### FIXED ARRAY STACK

0 commit comments

Comments
 (0)