AA tree
Create an empty tree
Given a file named “main.scm” with:
When I run the following script:
Then the exit status should be 0.
Check if a value is a tree
Given a file named “main.scm” with:
When I run the following script:
Then the exit status should be 0
And the stdout should contain exactly “A”.
Find no value
Given a file named “main.scm” with:
When I run the following script:
Then the exit status should be 0
And the stdout should contain exactly “B”.
Insert a value into a tree
Given a file named “main.scm” with:
When I run the following script:
Then the exit status should be 0
And the stdout should contain exactly “A”.
Insert a value into a left of a tree
Given a file named “main.scm” with:
When I run the following script:
Then the exit status should be 0
And the stdout should contain exactly “AAB”.
Insert a value into a right of a tree
Given a file named “main.scm” with:
When I run the following script:
Then the exit status should be 0
And the stdout should contain exactly “AAB”.
Insert a value into the same node of a tree
Given a file named “main.scm” with:
When I run the following script:
Then the exit status should be 0
And the stdout should contain exactly “A”.
Insert values into a tree
Given a file named “main.scm” with:
When I run the following script:
Then the exit status should be 0
And the stdout should contain exactly “<output>”.
Examples
values | output |
---|---|
1 2 3 | BABABAAAA |
1 3 2 | BABABAAAA |
2 1 3 | BABABAAAA |
2 3 1 | BABABAAAA |
3 1 2 | BABABAAAA |
3 2 1 | BABABAAAA |
1 2 3 4 | BABABABAAAAA |
1 2 4 3 | BABABABAAAAA |
1 3 2 4 | BABABABAAAAA |
1 3 4 2 | BABABABAAAAA |
1 4 2 3 | BABABABAAAAA |
1 4 3 2 | BABABABAAAAA |
2 1 3 4 | BABABABAAAAA |
2 1 4 3 | BABABABAAAAA |
2 3 1 4 | BABABABAAAAA |
2 3 4 1 | BABABABAAAAA |
2 4 1 3 | BABABABAAAAA |
2 4 3 1 | BABABABAAAAA |
Convert a list into a tree
Given a file named “main.scm” with:
When I run the following script:
Then the exit status should be 0
And the stdout should contain exactly “A”.
Examples
values | output |
---|---|
1 | 1 |
1 2 | 1 2 |
2 1 | 1 2 |
1 2 3 | 1 2 3 |
1 3 2 | 1 2 3 |
2 1 3 | 1 2 3 |
2 3 1 | 1 2 3 |
3 1 2 | 1 2 3 |
3 2 1 | 1 2 3 |
1 2 3 4 | 1 2 3 4 |
1 2 4 3 | 1 2 3 4 |
1 3 2 4 | 1 2 3 4 |
1 3 4 2 | 1 2 3 4 |
1 4 2 3 | 1 2 3 4 |
1 4 3 2 | 1 2 3 4 |
2 1 3 4 | 1 2 3 4 |
2 1 4 3 | 1 2 3 4 |
2 3 1 4 | 1 2 3 4 |
2 3 4 1 | 1 2 3 4 |
2 4 1 3 | 1 2 3 4 |
2 4 3 1 | 1 2 3 4 |