From cce9b058055ff993e959b87dbd1d9de1746cd104 Mon Sep 17 00:00:00 2001 From: shrutivanw Date: Tue, 26 Feb 2019 00:34:18 -0800 Subject: [PATCH 01/13] Updating solution Adding solution --- linked_list.rb | 266 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 221 insertions(+), 45 deletions(-) diff --git a/linked_list.rb b/linked_list.rb index c07cdaa7..29e90430 100644 --- a/linked_list.rb +++ b/linked_list.rb @@ -13,116 +13,292 @@ def initialize(value) # Defines the singly linked list class LinkedList def initialize - @head = nil # keep the head private. Not accessible outside this class + @head = nil # keep the head private. Not accessible outside this class end - + # method to add a new node with the specific data value in the linked list # insert the new node at the beginning of the linked list def add_first(value) - raise NotImplementedError + new_node = Node.new(value) + + if @head != nil # if linked list is not empty + new_node.next = @head + end + + @head = new_node end - + # returns the value in the first node # returns nil if the list is empty def get_first - raise NotImplementedError + return nil if !@head + return @head.data end - + # method to find if the linked list contains a node with specified value # returns true if found, false otherwise def search(value) - raise NotImplementedError + current = @head + while current != nil + if current.data == value + return true + end + current = current.next + end + + return false end - + # method to return the max value in the linked list # returns the data value and not the node def find_max - raise NotImplementedError + if @head == nil # empty list case + # puts "Error: The linked list is empty. Cannot compute max." + return nil + end + + current = @head + max = current.data + current = current.next + while current != nil + if current.data > max + max = current.data + end + current = current.next + end + return max end - + # method to return the min value in the linked list # returns the data value and not the node def find_min - raise NotImplementedError + if @head == nil # empty list case + # puts "Error: The linked list is empty. Cannot compute min." + return nil + end + + current = @head + min = current.data + current = current.next + while current != nil + if current.data < min + min = current.data + end + current = current.next + end + return min end - + # method that returns the length of the singly linked list def length - raise NotImplementedError + count = 0 + current = @head + while current != nil + count += 1 + current = current.next + end + + return count end - + # method that inserts a given value as a new last node in the linked list def add_last(value) - raise NotImplementedError + new_node = Node.new(value) + + if !@head + @head = new_node + return + end + + current = @head + while current.next + current = current.next + end + current.next = new_node + return end - + # method that returns the value of the last node in the linked list # returns nil if the linked list is empty def get_last - raise NotImplementedError + return nil if !@head + current = @head + while current.next + current = current.next + end + return current.data end - + # method that returns the value at a given index in the linked list # index count starts at 0 # returns nil if there are fewer nodes in the linked list than the index value def get_at_index(index) - raise NotImplementedError + i = 0 + current = @head + while current != nil + if i == index + return current.data + end + current = current.next + i += 1 + end + # puts "Error: #{index} exceeds the linked list length." + return nil end - - + + # method to insert a new node with specific data value, assuming the linked # list is sorted in ascending order def insert_ascending(value) - raise NotImplementedError + new_node = Node.new(value) + + # check for new_node being the new head case + if @head == nil || value <= @head.data + new_node.next = @head + @head = new_node + return + end + + current = @head + while current.next != nil && current.next.data < value + current = current.next + end + new_node.next = current.next + current.next = new_node end - + # method to print all the values in the linked list def visit - raise NotImplementedError + current = @head + while current != nil + print "#{current.data} " + current = current.next + end + puts end - + # method to delete the first node found with specified value def delete(value) - raise NotImplementedError + if @head == nil + return + end + + # account for case: node to delete is current head + if @head.data == value + @head = @head.next + return + end + + current = @head + while current.next != nil + if current.next.data == value + current.next = current.next.next + return + end + current = current.next + end + # value to be deleted was not found if the control flow reaches here end - + # method to reverse the singly linked list # note: the nodes should be moved and not just the values in the nodes def reverse - raise NotImplementedError + current = @head + previous = nil + while current != nil + temp = current.next # save state + current.next = previous # update link + + # move to next + previous = current + current = temp + end + @head = previous end - + ## Advanced Exercises # returns the value at the middle element in the singly linked list def find_middle_value - raise NotImplementedError + if @head == nil + return nil + end + + slow = @head + fast = @head.next + while fast != nil + slow = slow.next + fast = fast.next + if fast != nil + fast = fast.next + end + end + return slow.data end - + # find the nth node from the end and return its value # assume indexing starts at 0 while counting to n def find_nth_from_end(n) - raise NotImplementedError + # approach with going through the linked list just once + current = @head + index = 0 + # count to n from the beginning + while current != nil && index != n + current = current.next + index += 1 + end + + # check that we didn't reach the end + if current == nil + # puts "Error: The linked list has less than #{n} indexable nodes" + return nil + end + + # the previous while loop exited because of index == n condition + # start a new traverser at the beginning. + # when current reaches the end, new_current will be at index n from the end + new_current = @head + while current.next != nil + current = current.next + new_current = new_current.next + end + return new_current.data end - + # checks if the linked list has a cycle. A cycle exists if any node in the # linked list links to a node already visited. # returns true if a cycle is found, false otherwise. def has_cycle - raise NotImplementedError + if @head == nil || @head.next == nil + return false + end + slow = @head + fast = @head + while fast != nil + slow = slow.next + fast = fast.next + if fast != nil + fast = fast.next + end + if slow == fast + return true # cycle detected + end + end + return false # reached the end of the linked list - no cycle detected end - + # Helper method for tests # Creates a cycle in the linked list for testing purposes # Assumes the linked list has at least one node def create_cycle - return if @head == nil # don't do anything if the linked list is empty - - # navigate to last node - current = @head - while current.next != nil - current = current.next - end - - current.next = @head # make the last node link to first node + return if @head == nil # don't do anything if the linked list is empty + + # navigate to last node + current = @head + while current.next != nil + current = current.next + end + + current.next = @head # make the last node link to first node end -end + end + From 720e2bf50dbc40c6302ae15f2ee009fe9e48d13b Mon Sep 17 00:00:00 2001 From: CheezItMan Date: Thu, 13 Aug 2020 14:10:20 -0700 Subject: [PATCH 02/13] dockerize stuff --- Dockerfile | 25 +++++++++++++++++++++++++ Gemfile | 8 ++++++++ test.sh | 0 3 files changed, 33 insertions(+) create mode 100644 Dockerfile create mode 100644 Gemfile create mode 100644 test.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..f1ffa4fb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# Starting from a minimalist image +FROM ruby:2.7 +# Reference for help contact me +LABEL maintainer="chris@adadev.org" + +# Create a directory for the app +RUN mkdir /app + +# Set the working directory for RUN, ADD and COPY +WORKDIR /app + +# Add entire student fork (overwrites previously added files) +ARG SUBMISSION_SUBFOLDER +ADD $SUBMISSION_SUBFOLDER /app + + +COPY ./Gemfile . +RUN gem install bundler +RUN bundle install + +# Overwrite the script and test files +ADD test.sh /app +ADD test /app + +RUN chmod +x test.sh diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..0aab9c2c --- /dev/null +++ b/Gemfile @@ -0,0 +1,8 @@ +# frozen_string_literal: true +source "https://rubygems.org" + +gem 'rake' +gem 'minitest' +gem 'minitest-spec' +gem 'minitest-reporters' +gem "pry" \ No newline at end of file diff --git a/test.sh b/test.sh new file mode 100644 index 00000000..e69de29b From a3519cb7be459435ecdbb1cfaf7041a521dc94eb Mon Sep 17 00:00:00 2001 From: CheezItMan Date: Thu, 13 Aug 2020 14:11:14 -0700 Subject: [PATCH 03/13] update test.sh --- test.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test.sh b/test.sh index e69de29b..8509a009 100644 --- a/test.sh +++ b/test.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +rake From f83442dfd48aab2ed2b0e8900b548d531662b21b Mon Sep 17 00:00:00 2001 From: CheezItMan Date: Thu, 13 Aug 2020 14:11:52 -0700 Subject: [PATCH 04/13] dockerize stuff --- Dockerfile | 25 +++++++++++++++++++++++++ Gemfile | 8 ++++++++ Gemfile.lock | 33 +++++++++++++++++++++++++++++++++ test.sh | 3 +++ 4 files changed, 69 insertions(+) create mode 100644 Dockerfile create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 test.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..f1ffa4fb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# Starting from a minimalist image +FROM ruby:2.7 +# Reference for help contact me +LABEL maintainer="chris@adadev.org" + +# Create a directory for the app +RUN mkdir /app + +# Set the working directory for RUN, ADD and COPY +WORKDIR /app + +# Add entire student fork (overwrites previously added files) +ARG SUBMISSION_SUBFOLDER +ADD $SUBMISSION_SUBFOLDER /app + + +COPY ./Gemfile . +RUN gem install bundler +RUN bundle install + +# Overwrite the script and test files +ADD test.sh /app +ADD test /app + +RUN chmod +x test.sh diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..0aab9c2c --- /dev/null +++ b/Gemfile @@ -0,0 +1,8 @@ +# frozen_string_literal: true +source "https://rubygems.org" + +gem 'rake' +gem 'minitest' +gem 'minitest-spec' +gem 'minitest-reporters' +gem "pry" \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..116502cc --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,33 @@ +GEM + remote: https://rubygems.org/ + specs: + ansi (1.5.0) + builder (3.2.4) + coderay (1.1.3) + method_source (1.0.0) + minitest (5.14.1) + minitest-reporters (1.4.2) + ansi + builder + minitest (>= 5.0) + ruby-progressbar + minitest-spec (0.0.2.1) + minitest (>= 3.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + rake (13.0.1) + ruby-progressbar (1.10.1) + +PLATFORMS + ruby + +DEPENDENCIES + minitest + minitest-reporters + minitest-spec + pry + rake + +BUNDLED WITH + 2.1.4 diff --git a/test.sh b/test.sh new file mode 100644 index 00000000..8509a009 --- /dev/null +++ b/test.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +rake From 4a702b9633be176c2b075b1cb37ce53785fce7c8 Mon Sep 17 00:00:00 2001 From: CheezItMan Date: Thu, 13 Aug 2020 14:12:15 -0700 Subject: [PATCH 05/13] rakefile --- Rakefile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Rakefile diff --git a/Rakefile b/Rakefile new file mode 100644 index 00000000..ce1d5e9e --- /dev/null +++ b/Rakefile @@ -0,0 +1,11 @@ + +require 'rake/testtask' + +Rake::TestTask.new do |t| + t.libs = ["lib"] + t.warning = true + t.test_files = FileList['test/*_test.rb'] +end + +task default: :test + From a22edcdc3d4099ab1094f15d12423ea17f433ef6 Mon Sep 17 00:00:00 2001 From: CheezItMan Date: Thu, 13 Aug 2020 14:13:07 -0700 Subject: [PATCH 06/13] organize files --- linked_list.rb => lib/linked_list.rb | 0 linked_list_spec.rb => test/linked_list_test.rb | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename linked_list.rb => lib/linked_list.rb (100%) rename linked_list_spec.rb => test/linked_list_test.rb (100%) diff --git a/linked_list.rb b/lib/linked_list.rb similarity index 100% rename from linked_list.rb rename to lib/linked_list.rb diff --git a/linked_list_spec.rb b/test/linked_list_test.rb similarity index 100% rename from linked_list_spec.rb rename to test/linked_list_test.rb From 6d13814d1c93eda4ee144412cf507fd6cbc93c17 Mon Sep 17 00:00:00 2001 From: CheezItMan Date: Thu, 13 Aug 2020 14:14:04 -0700 Subject: [PATCH 07/13] fix path to linked_list file --- test/linked_list_test.rb | 2 +- test/test_helper.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test/test_helper.rb diff --git a/test/linked_list_test.rb b/test/linked_list_test.rb index d7302e9f..d6e1a0c1 100644 --- a/test/linked_list_test.rb +++ b/test/linked_list_test.rb @@ -2,7 +2,7 @@ require 'minitest/reporters' require 'minitest/skip_dsl' -require_relative 'linked_list' +require_relative '../lib/linked_list' Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 00000000..039f0234 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,8 @@ +require 'minitest' +require 'minitest/autorun' +require 'minitest/reporters' + +Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new + +require_relative '../lib/linked_list' + From 62988281a6d91576baa3943b95d9bd3bed3949a0 Mon Sep 17 00:00:00 2001 From: CheezItMan Date: Thu, 13 Aug 2020 14:34:16 -0700 Subject: [PATCH 08/13] add minitest-skip --- Gemfile | 4 +++- Gemfile.lock | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 0aab9c2c..04a9dcdd 100644 --- a/Gemfile +++ b/Gemfile @@ -5,4 +5,6 @@ gem 'rake' gem 'minitest' gem 'minitest-spec' gem 'minitest-reporters' -gem "pry" \ No newline at end of file +gem "pry" +gem 'minitest-skip' + diff --git a/Gemfile.lock b/Gemfile.lock index 116502cc..878af75d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,6 +11,8 @@ GEM builder minitest (>= 5.0) ruby-progressbar + minitest-skip (0.0.1) + minitest (~> 5.0) minitest-spec (0.0.2.1) minitest (>= 3.0) pry (0.13.1) @@ -25,6 +27,7 @@ PLATFORMS DEPENDENCIES minitest minitest-reporters + minitest-skip minitest-spec pry rake From 3cbac36b958eaac989d355694b0e971b76d829db Mon Sep 17 00:00:00 2001 From: Chris M Date: Thu, 20 Aug 2020 11:57:15 -0700 Subject: [PATCH 09/13] Update linked_list.rb --- lib/linked_list.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/linked_list.rb b/lib/linked_list.rb index 8dee5e8d..0de1ee00 100644 --- a/lib/linked_list.rb +++ b/lib/linked_list.rb @@ -18,12 +18,16 @@ def initialize # method to add a new node with the specific data value in the linked list # insert the new node at the beginning of the linked list + # Time Complexity: ? + # Space Complexity: ? def add_first(value) raise NotImplementedError end # method to find if the linked list contains a node with specified value # returns true if found, false otherwise + # Time Complexity: ? + # Space Complexity: ? def search(value) raise NotImplementedError end @@ -36,12 +40,16 @@ def find_max # method to return the min value in the linked list # returns the data value and not the node + # Time Complexity: ? + # Space Complexity: ? def find_min raise NotImplementedError end # method that returns the length of the singly linked list + # Time Complexity: ? + # Space Complexity: ? def length raise NotImplementedError end @@ -49,22 +57,30 @@ def length # method that returns the value at a given index in the linked list # index count starts at 0 # returns nil if there are fewer nodes in the linked list than the index value + # Time Complexity: ? + # Space Complexity: ? def get_at_index(index) raise NotImplementedError end # method to print all the values in the linked list + # Time Complexity: ? + # Space Complexity: ? def visit raise NotImplementedError end # method to delete the first node found with specified value + # Time Complexity: ? + # Space Complexity: ? def delete(value) raise NotImplementedError end # method to reverse the singly linked list # note: the nodes should be moved and not just the values in the nodes + # Time Complexity: ? + # Space Complexity: ? def reverse raise NotImplementedError end @@ -72,12 +88,16 @@ def reverse ## Advanced Exercises # returns the value at the middle element in the singly linked list + # Time Complexity: ? + # Space Complexity: ? def find_middle_value raise NotImplementedError end # find the nth node from the end and return its value # assume indexing starts at 0 while counting to n + # Time Complexity: ? + # Space Complexity: ? def find_nth_from_end(n) raise NotImplementedError end @@ -85,6 +105,8 @@ def find_nth_from_end(n) # checks if the linked list has a cycle. A cycle exists if any node in the # linked list links to a node already visited. # returns true if a cycle is found, false otherwise. + # Time Complexity: ? + # Space Complexity: ? def has_cycle raise NotImplementedError end @@ -93,23 +115,31 @@ def has_cycle # Additional Exercises # returns the value in the first node # returns nil if the list is empty + # Time Complexity: ? + # Space Complexity: ? def get_first raise NotImplementedError end # method that inserts a given value as a new last node in the linked list + # Time Complexity: ? + # Space Complexity: ? def add_last(value) raise NotImplementedError end # method that returns the value of the last node in the linked list # returns nil if the linked list is empty + # Time Complexity: ? + # Space Complexity: ? def get_last raise NotImplementedError end # method to insert a new node with specific data value, assuming the linked # list is sorted in ascending order + # Time Complexity: ? + # Space Complexity: ? def insert_ascending(value) raise NotImplementedError end From e444f3fde34134ea54d4903f778206e6d276b4b7 Mon Sep 17 00:00:00 2001 From: CheezItMan Date: Thu, 20 Aug 2020 18:51:25 -0700 Subject: [PATCH 10/13] modify tests for optionals --- test/linked_list_test.rb | 80 ++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/test/linked_list_test.rb b/test/linked_list_test.rb index d169c9a0..c1756935 100644 --- a/test/linked_list_test.rb +++ b/test/linked_list_test.rb @@ -27,7 +27,7 @@ @list.add_first(3) # Assert - expect(@list.get_first).must_equal 3 + expect(@list.get_at_index(0)).must_equal 3 end it 'will put the last added item to the front of the list' do @@ -36,18 +36,18 @@ @list.add_first(2) # Assert - expect(@list.get_first).must_equal 2 + expect(@list.get_at_index(0)).must_equal 2 # Act again @list.add_first(3) # Assert - expect(@list.get_first).must_equal 3 + expect(@list.get_at_index(0)).must_equal 3 end it 'will return `nil` for `getFirst` if the list is empty' do - expect(@list.get_first).must_be_nil + expect(@list.get_at_index(0)).must_be_nil end end @@ -89,10 +89,28 @@ end end - describe "addLast & getLast" do + describe 'get_at_index' do + it 'returns nil if the index is outside the bounds of the list' do + expect(@list.get_at_index(3)).must_be_nil + end + + it 'can retrieve an item at an index in the list' do + @list.add_first(1) + @list.add_first(2) + @list.add_first(3) + @list.add_first(4) + + expect(@list.get_at_index(0)).must_equal 4 + expect(@list.get_at_index(1)).must_equal 3 + expect(@list.get_at_index(2)).must_equal 2 + expect(@list.get_at_index(3)).must_equal 1 + end + end + + xdescribe "Optional addLast & getLast" do it "will add to the front if the list is empty" do @list.add_last(1) - expect(@list.get_first).must_equal 1 + expect(@list.get_at_index(0)).must_equal 1 end it "will put new items to the rear of the list" do @@ -101,35 +119,17 @@ expect(@list.get_last).must_equal 2 @list.add_last(3) - expect(@list.get_first).must_equal 2 + expect(@list.get_at_index(0)).must_equal 2 expect(@list.get_last).must_equal 3 expect(@list.length).must_equal 2 @list.add_last(4) - expect(@list.get_first).must_equal 2 + expect(@list.get_at_index(0)).must_equal 2 expect(@list.get_last).must_equal 4 expect(@list.length).must_equal 3 end end - describe 'get_at_index' do - it 'returns nil if the index is outside the bounds of the list' do - expect(@list.get_at_index(3)).must_be_nil - end - - it 'can retrieve an item at an index in the list' do - @list.add_first(1) - @list.add_first(2) - @list.add_first(3) - @list.add_first(4) - - expect(@list.get_at_index(0)).must_equal 4 - expect(@list.get_at_index(1)).must_equal 3 - expect(@list.get_at_index(2)).must_equal 2 - expect(@list.get_at_index(3)).must_equal 1 - end - end - describe 'max and min values' do it 'returns nil if the list is empty' do expect(@list.find_max()).must_be_nil @@ -145,7 +145,7 @@ count += 1 end - @list.add_last(100) + @list.add_first(100) @list.add_first(-12) expect(@list.find_max).must_equal 100 expect(@list.find_min).must_equal(-12) @@ -160,8 +160,8 @@ end it "can delete valid values from list" do - @list.add_last(9) - @list.add_last(10) + @list.add_first(9) + @list.add_first(10) @list.add_first(4) @list.add_first(3) @list.add_first(2) @@ -170,29 +170,29 @@ @list.delete(2) expect(@list.get_first).must_equal 3 expect(@list.length).must_equal 4 - expect(@list.get_last).must_equal 10 + expect(@list.get_at_index(@list.length - 1)).must_equal 9 expect(@list.find_max).must_equal 10 expect(@list.find_min).must_equal 3 # delete last node @list.delete(10) - expect(@list.get_first).must_equal 3 + expect(@list.get_at_index(0)).must_equal 3 expect(@list.length).must_equal 3 - expect(@list.get_last).must_equal 9 + expect(@list.get_at_index(@list.length - 1)).must_equal 9 expect(@list.find_max).must_equal 9 expect(@list.find_min).must_equal 3 - # delete fist node (requires updating head) + # delete first node (requires updating head) @list.delete(4) - expect(@list.get_first).must_equal 3 + expect(@list.get_at_index(0)).must_equal 3 expect(@list.length).must_equal 2 - expect(@list.get_last).must_equal 9 + expect(@list.get_at_index(@list.length - 1)).must_equal 9 expect(@list.find_max).must_equal 9 expect(@list.find_min).must_equal 3 end end - describe "nth_from_the_end" do + xdescribe "Optional: nth_from_the_end" do it 'returns nil if n is outside the bounds of the list' do expect(@list.find_nth_from_end(3)).must_be_nil end @@ -219,10 +219,10 @@ @list.add_first(1) @list.reverse - expect(@list.find_nth_from_end(0)).must_equal 1 - expect(@list.find_nth_from_end(1)).must_equal 2 - expect(@list.find_nth_from_end(2)).must_equal 3 - expect(@list.find_nth_from_end(3)).must_equal 4 + expect(@list.get_at_index(0)).must_equal 4 + expect(@list.get_at_index(1)).must_equal 3 + expect(@list.get_at_index(2)).must_equal 2 + expect(@list.get_at_index(3)).must_equal 1 end end end From 137cbdd62ec733ac1435078055d00c53ea3e898c Mon Sep 17 00:00:00 2001 From: Chris M Date: Sat, 22 Aug 2020 09:47:46 -0700 Subject: [PATCH 11/13] Update README.md --- README.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/README.md b/README.md index e38d64fc..a1f2d313 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,4 @@ Design and implement the classes and the methods. Implement the methods within t ### Going Further -Create a new class called `DoublyLinkedList` which implements a doubly linked list. Then implement the following methods: - -- `add_first` -- `add_last` -- `get_first` -- `get_at_index(index)` -- `reverse` -- `delete(value)` +There are a set of advanced methods you can choose to implement for additional practice. From 76d8327a268210278fcaffdc0d997f947cc9be33 Mon Sep 17 00:00:00 2001 From: Chris M Date: Mon, 24 Aug 2020 21:46:42 -0700 Subject: [PATCH 12/13] Update linked_list_test.rb --- test/linked_list_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/linked_list_test.rb b/test/linked_list_test.rb index c1756935..75df0d6e 100644 --- a/test/linked_list_test.rb +++ b/test/linked_list_test.rb @@ -168,7 +168,7 @@ # delete fist node (requires updating head) @list.delete(2) - expect(@list.get_first).must_equal 3 + expect(@list.get_at_index(0)).must_equal 3 expect(@list.length).must_equal 4 expect(@list.get_at_index(@list.length - 1)).must_equal 9 expect(@list.find_max).must_equal 10 From 75dd4376dd28130dd6de5b64ed7e715f09da642c Mon Sep 17 00:00:00 2001 From: Chris M Date: Sun, 14 Mar 2021 10:40:07 -0700 Subject: [PATCH 13/13] Update linked_list_test.rb --- test/linked_list_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/linked_list_test.rb b/test/linked_list_test.rb index 75df0d6e..7c695018 100644 --- a/test/linked_list_test.rb +++ b/test/linked_list_test.rb @@ -166,7 +166,7 @@ @list.add_first(3) @list.add_first(2) - # delete fist node (requires updating head) + # delete first node (requires updating head) @list.delete(2) expect(@list.get_at_index(0)).must_equal 3 expect(@list.length).must_equal 4