Skip to content

Commit 141c8df

Browse files
committed
Merge pull request kodecocodes#46 from barbaramartina/test/unit-tests-for-array2D-and-AVLTree
Unit tests for Array2D and AVLTree data structures
2 parents 7711637 + 3aee5c4 commit 141c8df

File tree

22 files changed

+1661
-1
lines changed

22 files changed

+1661
-1
lines changed

AVL Tree/AVLTree.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ public class TreeNode<Key: Comparable, Payload> {
2828
private var key: Key
2929
private var leftChild: Node?
3030
private var rightChild: Node?
31-
private var parent: Node?
31+
weak private var parent: Node?
3232
private var balance = 0
3333

3434
public init(key: Key, payload: Payload?, leftChild: Node?, rightChild: Node?, parent: Node?) {
3535
self.key = key
3636
self.payload = payload
3737
self.leftChild = leftChild
38+
self.leftChild?.parent = self
3839
self.rightChild = rightChild
40+
self.rightChild?.parent = self
3941
self.parent = parent
4042
}
4143

0 commit comments

Comments
 (0)