Skip to content

Commit 771eab1

Browse files
committed
Trees: input options, extra info etc
1 parent cb52e6b commit 771eab1

File tree

9 files changed

+379
-232
lines changed

9 files changed

+379
-232
lines changed

src/algorithms/controllers/TTFTreeInsertion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default {
1010
initVisualisers() {
1111
return {
1212
tree: {
13-
instance: new NTreeTracer('n-tree', null, 'Tree View'),
13+
instance: new NTreeTracer('n-tree', null, '2-3-4 Tree'),
1414
order: 0,
1515
},
1616
};

src/algorithms/controllers/TTFTreeSearch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,4 @@ export default {
286286
this.search(chunker, root, target);
287287
},
288288

289-
};
289+
};

src/algorithms/controllers/binaryTreeInsertion.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export default {
3636
(vis, elements) => {
3737
vis.array.set(elements);
3838
// vis.array.select(0); // the index of root element is 0
39+
// make a bit more room for tree
40+
vis.graph.setSize(2.5);
41+
vis.graph.setZoom(0.8);
42+
vis.array.setZoom(0.9);
3943
},
4044
[nodes],
4145
);

src/algorithms/extra-info/AVLInfo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ W3Schools Link: [**AVL Trees**][G4GLink]
2121
With insertion of three distinct keys there are six orders in which the
2222
keys may appear. How many different AVL trees are there with three
2323
given distinct keys? Explore how insertion takes place for the six
24-
different orders.
24+
different orders and compare this with simple binary search trees.
2525

2626
In the background it says that unbalance can only be caused by insertion
2727
into a grandchild of a node. Why can't it be caused by just adding a

src/algorithms/extra-info/BSTInfo.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@ a:hover{
1818
Geeks for Geeks Link: [**Binary Search Tree**][G4GLink]
1919

2020

21-
[G4GLink]: https://www.geeksforgeeks.org/binary-search-tree-data-structure/
21+
[G4GLink]: https://www.geeksforgeeks.org/binary-search-tree-data-structure/
22+
23+
## Exercises/Exploration
24+
25+
The "balanced" input option is designed to produce a best possible
26+
ordering for building a binary search tree. Can you figure out how it
27+
works? Can you design an algorithm to produce this ordering?
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,32 @@
1-
# 2-3-4 Trees
1+
<style>
2+
a:link {
3+
color: #1e28f0;
4+
}
5+
a:visited{
6+
color: #3c1478;
7+
}
8+
a:hover{
9+
color: #1e288c;
10+
}
11+
</style>
12+
13+
## Extra Info
14+
15+
-----
16+
17+
Geeks for Geeks Link: [**2-3-4 Tree**][G4GLink]
18+
19+
20+
[G4GLink]: https://www.geeksforgeeks.org/dsa/2-3-4-tree/
21+
22+
23+
## Exercises/Exploration
24+
25+
The "balanced" input option produces optimal ordering for simple binary
26+
search trees, not for 2-3-4 trees. For the keys 1-11, both sorted and
27+
"balanced" orderings result in a 2-3-4 tree of height three. Can you
28+
find an ordering that results in a 2-3-4 tree of height two?
29+
30+
Compare and contrast how 2-3-4 trees, AVL trees and simple binary search
31+
trees behave for sorted input and "balanced" input.
32+

0 commit comments

Comments
 (0)