This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node | |
attr_accessor :data, :next | |
def initialize(data, next_node = nil) | |
@data = data | |
@next = next_node | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#linked list is composed nodes, each node has a data, than it points to the next node | |
class LinkedList | |
#is_empty?: return true if the linked list is empty | |
def is_empty? | |
if @head == nil | |
return true | |
else | |
return false | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TreeNode | |
attr_accessor :value, :left, :right | |
def initialize(value) | |
@value = value | |
@left = nil | |
@right = nil | |
end | |
end |