Skip to content

Commit

Permalink
updated complexity for approaches
Browse files Browse the repository at this point in the history
  • Loading branch information
GauravWalia19 committed Dec 28, 2018
1 parent 0290e8c commit bf73965
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion datastructures.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ Indexer for Data Structures Lover

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

## :octocat: STACKS

Expand Down
16 changes: 15 additions & 1 deletion docs/complexity.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ This page contains the complexities of different algorithms in this repository.
* LINKED LIST
* [ARRAYLISTS](#arraylists-(JAVA))
* [VECTORS](#vectors-(C++JAVA))
* MISC
* [MISC LISTS](#misc-lists)
* [Find the nth node from end in single linked list](#find-the-nth-node-from-end-in-single-linked-list)
* [STACKS](#stacks)
* [FIXED ARRAY STACK](#fixed-array-stack)
* [DYNAMIC ARRAY STACK](#dynamic-array-stack)
Expand Down Expand Up @@ -432,6 +433,19 @@ SNo. | Operations | Order and Type of Time Complexity O(n) | Order and Type of S
SNo. | Operations | Order and Type of Time Complexity O(n) | Order and Type of Space Complexity
---- | ---------- | -------------------------------------- | ----------------------------------

#### MISC LISTS

##### Find the nth node from end in single linked list

SNo. | APPROACH | Order and Type of Time Complexity O(n) | Order and Type of Space Complexity
---- | ---------- | -------------------------------------- | ----------------------------------
1 | Compute the size while adding | O(n) -- Linear | O(1) -- Constant
2 | Using two current pointers | O(n^2) -- Quadratic | O(1) -- Constant
3 | Using hashtable | O(n) -- Linear | O(n) -- Linear
4 | Using Hashtable while adding | O(1) -- Constant | O(n) -- Linear
5 | Finding node in one scan | O(n) -- Linear | O(1) -- Constant
6 | Using recursion | O(n) -- Linear | O(n) -- Linear

### STACKS

#### FIXED ARRAY STACK
Expand Down

0 comments on commit bf73965

Please sign in to comment.