This file contains 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 LRUCache | |
attr_reader :dll, :hash, :count, :capacity | |
def initialize(capacity) | |
@dll = DLL.new | |
@hash = Hash.new | |
@count = 0 | |
@capacity = capacity | |
end | |
def read(key) |
This file contains 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 BinaryTree | |
attr_reader :root | |
def initialize(root) | |
@root = root | |
end | |
def level_order_traversal | |
if root.nil? | |
puts "Queue is empty" |
This file contains 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 BinaryTree | |
attr_reader :root | |
def initialize(root) | |
@root = root | |
end | |
def print_inorder_with_recursion(current) | |
return if current.nil? |