File tree 1 file changed +45
-0
lines changed
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ import 'adt/binary_tree_adt.dart' ;
2
+ import 'binary_tree.dart' ;
3
+
4
+ /// Data structure similar to [BinaryNode] , differs in having two boolean values
5
+ /// [leftIsThread] and [rightIsThread] to determine whether [left] and [right]
6
+ /// are threads or point to a child instead.
7
+ class ThreadedBinaryNode <V extends Comparable >
8
+ extends BinaryNodeADT <ThreadedBinaryNode , V > {
9
+ V value;
10
+
11
+ /// Stores if [left] is a thread.
12
+ bool leftIsThread;
13
+
14
+ /// Stores if [right] is a thread.
15
+ bool rightIsThread;
16
+ }
17
+
18
+ /// A [BinaryTree] is threaded by making all [right] pointers that would
19
+ /// normally be null point to the in-order successor of the node
20
+ /// (if it exists), and all [left] pointers that would normally be null point
21
+ /// to the in-order predecessor of the node.
22
+ class ThreadedBinaryTree <V extends Comparable >
23
+ extends BinaryTreeADT <ThreadedBinaryNode , V > {
24
+ ThreadedBinaryNode root;
25
+
26
+ @override
27
+ void add (V value) {
28
+ throw UnimplementedError ();
29
+ }
30
+
31
+ @override
32
+ void delete (V value) {
33
+ throw UnimplementedError ();
34
+ }
35
+
36
+ @override
37
+ List <V > inOrder () {
38
+ throw UnimplementedError ();
39
+ }
40
+
41
+ @override
42
+ List <V > preOrder () {
43
+ throw UnimplementedError ();
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments