Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jmromer/linked_list_exercises
https://github.com/jmromer/linked_list_exercises
data-structures-algorithms demo linked-list ruby
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jmromer/linked_list_exercises
- Owner: jmromer
- Created: 2015-10-02T21:19:43.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-02T22:06:28.000Z (about 9 years ago)
- Last Synced: 2023-08-05T16:38:42.624Z (over 1 year ago)
- Topics: data-structures-algorithms, demo, linked-list, ruby
- Language: Ruby
- Homepage:
- Size: 129 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Linked List Exercises
=====================### Reverse a linear linked list
Both non-destructively and with mutation:
```
λ reverse_linked_list 5Usage: reversed_linked_list [LIST_LENGTH]
original linked list:
{ 7, 9, 0, 6, 0 }
reversed (sans mutation):
{ 0, 6, 0, 9, 7 }
reversed (in-place)
{ 0, 6, 0, 9, 7 }
```### Floyd's cycle detection algorithm
Use it to determine if a linear linked list has cyclically infinite length.
For a finite list:
```
λ detect_infinite_list 5Usage: detect_infinite_list [LIST_LENGTH] # default: 5, for infinite: inf
Finite list:
{ 8, 1, 4, 5, 2 }Cycle detection result:
false
```For an infinite list:
```
λ detect_infinite_list infUsage: detect_infinite_list [LIST_LENGTH] # default: 5, for infinite: inf
Infinite list:
#>>>>Cycle detection result:
true
```