algorithms 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,25 +0,0 @@
1
- class Graph
2
- def initialize(string=nil, &block)
3
- p block if block
4
- @nodes = []
5
- end
6
-
7
- def -(other)
8
- @nodes << other
9
- end
10
-
11
- def >(other)
12
- @nodes << other
13
- end
14
- end
15
- a = Graph.new
16
- b = []
17
- d = []
18
-
19
- a - b
20
- a > d
21
-
22
- Graph.new do
23
- d - c
24
- g - s
25
- end
@@ -1,31 +0,0 @@
1
- $: << File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib')
2
- require "algorithms"
3
-
4
- begin
5
- Containers::CBst
6
- describe "binary search tree" do
7
- it "should let user insert new elements with key" do
8
- @bst = Containers::CBst.new
9
- 100.times { |x| @bst.insert(x, "hello : #{x}") }
10
- @bst.size.should eql(100)
11
- end
12
-
13
- it "should allow users to delete elements" do
14
- @bst = Containers::CBst.new
15
- @bst.insert(10, "hello world")
16
- @bst.insert(11, "hello world")
17
- @bst.delete(11)
18
- @bst.size.should eql(1)
19
- @bst.delete(10)
20
- @bst.size.should eql(0)
21
- end
22
-
23
- it "should throw exception on invalid key delete" do
24
- @bst = Containers::CBst.new
25
- @bst.insert(10,"Hello world")
26
- lambda { @bst.delete(20) }.should raise_error(ArgumentError)
27
- @bst.size.should eql(1)
28
- end
29
- end
30
- rescue Exception
31
- end