https://github.com/vadim-geroim/linked-list-2
Reverse the linked list using mutation
https://github.com/vadim-geroim/linked-list-2
datastructures linked-list rspec ruby
Last synced: 4 months ago
JSON representation
Reverse the linked list using mutation
- Host: GitHub
- URL: https://github.com/vadim-geroim/linked-list-2
- Owner: vadim-geroim
- Created: 2019-09-27T02:37:31.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-27T02:43:40.000Z (over 5 years ago)
- Last Synced: 2025-01-13T08:12:31.679Z (5 months ago)
- Topics: datastructures, linked-list, rspec, ruby
- Language: Ruby
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Linked List #2
Solution and Tests to the Columbia University Linked List #2 problem.## Project structure
- `lib/linked_list.rb` - contains solution
- `spec/linked_list_spec.rb` - includes tests for reverse method the LinkedList using mutation,
and determine if a LinkedList is infinite or not## Solution
- The `reverse_list` method reverse the linked list and return it
- The `is_infinite?` method validate infinite LinkedList and returns `true` or `false`
- The `list_to_array` created as an additional method for testing purpose. When test validates the linked list
it has objects inside and the order of them will be different for reversed list. For validation purpose, I
convert list to array and array to string. That way rspec is able to compare two strings and tests are more readable for other people to review.## Test execution
- Run `bundle install`
- Open terminal window
- From the project directory run `rspec`