Skip to content

Commit 3b42f0c

Browse files
committed
Add documentation
1 parent 21e8dd4 commit 3b42f0c

File tree

7 files changed

+63
-3
lines changed

7 files changed

+63
-3
lines changed

Algorithms/BinTree.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public async Task SwapValues(Node<T> one, Node<T> other)
381381
/// Delete specified node from the tree.<para/>
382382
/// You can find the node first with <see cref="Find(T)"/>
383383
/// </summary>
384-
/// <param name="currNode">Node to delete</param>
384+
/// <param name="victim">Node to delete</param>
385385
/// <returns></returns>
386386
public async Task Delete(Node<T> victim)
387387
{

Docs/Documentation.pdf

656 KB
Binary file not shown.

Docs/Notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Operations to support:
77
- Find min
88
- Find max
99

10+
Should ship with documentation that focuses on the properties of binary trees and used data structured, with documentation of the UI implementation being a secondary target.
11+
1012
# Roadmap
1113
Project requirements:
1214
- [ X ] Initial UI setup

Docs/ProjectOverview.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Project overview
2+
## Base BST
3+
The binary search tree is build out of nodes - starting by root, each of the subsequent children can have two children of their own.
4+
The base property of the binary tree which allows for O(log n) search is the way the children nodes are placed - nodes smaller than their parent are placed on the left, and nodes bigger than their parent - on the right. Thanks to this, the area of tree which needs to be searched is effectively halved with each recursive iterations (assuming the tree is balanced well enough).
5+
### Insertion
6+
- Proceed like with normal search, then if a spot is found where the search would continue but the spot is empty - insert a new node into it.
7+
### Search
8+
- Follow the tree with the principle of going left if the searched value is smaller than the current node, and right if the searched value is bigger.
9+
- Check if the current is the searched node if neither of those paths can be taken.
10+
### Deletion
11+
- Find an item to delete.
12+
- Next, try to find its successor - the next element which is minimally smaller than the current one (that can be obtained by going one to right and then max to left, thanks to binary tree properties).
13+
- Once a successor is found, swap the victim with the succesor, and then remove the victim whose been moved out of the original location.
14+
- If the victim is not placed in a leaf position (i.e. having no children), repeat finding a successor and swapping until a leaf node is reached which can then be removed safely.
15+
16+
## AVL
17+
AVL tree is a type of a binary search tree. It operates on the same base princinple regarding to the location of nodes, but with an additional mechanic - rotations.
18+
Whenever a subtree becomes unbalances - i.e. one of its sides is at least two nodes taller than the other one - a node with the middle value is picked out of the long branch, and then the other nodes from this branch are balanced around it.
19+
Thanks to this, a normally successive chain (eg. 1 -> 2 -> 3) becomes a neatly balanced, smaller tree (with node {2} pointing to {1} to the left and to {3} to the right).
20+
21+
Operations on AVL trees start exactly the same way as on base BSTs, but then after a node is either inserted or removed, all parents of the affected node are visitied to make sure the tree is kept in balance, and rotations are performed if they are not.
22+
23+
## App structure
24+
The application is written utilizing C# 13 preview language, .NET 9.0 framework, as well as WPF framework for the UI.
25+
The tree is layouted using a modified Wetherell and Shannon algorithm.
26+
It uses Material Design (http://materialdesigninxaml.net/) NuGet package for the interface theme, as well as ScottPlot library (https://scottplot.net/) for rendering the collected performance data into graphs.
27+
The tree's logical data structures are partially separated from the WPF elements and use a composite model.
28+
- `BinTree<T>` and `Node<T>` are the main data logical structures that hold the info about the binary tree and can perform operations on it.
29+
- `TreeLayout` is a helper class that can auto-layout the tree.
30+
- `BinTreeMan` is a WPF page which holds the main user interface and delegates operations requested by user to the binary tree.
31+
- `BinTreeControl` is a WPF UserControl that holds Canvas where the nodes are physically placed into
32+
- `NodeControl` is a WPF UserControl that represents a visual node - each `NodeControl` is directly managed by a `Node<T>` it is associated with, and physically placed upon `BinTreeControl`'s Canvas
33+
- `NodeArrow` is a WPF UserControl that represents and arrow that can point from one point into another. Each `Node<T>` manages an arrow pointing towards it.
34+
- `ProgressLabel` is a WPF Control that is used for displaying descriptions.
35+
- `TreeStats` and `StatsWindow.xaml` are classes used for gathering and displaying the statistics respectively.
36+
37+
Documentation PDF is generated with Doxygen.
38+
Detailed descriptions of each of the classes, methods, and properties used in the program are contained in the following chapters of the documentation PDF.

Docs/TimeSpent.ini

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,20 @@ Total so far: 29 hours 20 minutes
6060
29-12 => 23h00 - 23h30 - fill in more documentation
6161
29-12 => 00h30 - 01h00 - check for tree being empty
6262

63+
Time spent today: 1 hours 40 minutes
64+
Total so far: 31 hours 00 minutes
65+
66+
====================================
67+
=============== 2025 ===============
68+
====================================
69+
70+
02-12 => 10h00 - 10h10 - auto rescale tree on window resize
71+
72+
Time spent today: 0 hours 10 minutes
73+
Total so far: 31 hours 10 minutes
74+
75+
03-12 => 15h00 - 16h00 - add overview article as highlighted by requirements
76+
03-12 => 16h00 - 16h30 - generate documentation
77+
6378
Time spent today: 1 hours 40 minutes
6479
Total so far: 31 hours 00 minutes

Readme.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Supports:
88
- Deletion
99
- Search
1010

11-
All steps performed during an algorithm's execution are described in the log, and all nodes associated with the particular sub-operation are highlighted - what enables clear and easy following of an algorithm.
11+
All steps performed during an algorithm's execution are described in the log, and all the nodes associated with the particular sub-operation are highlighted - which enables clear and easy following of an algorithm.
1212

1313
![Rotation screenshot](https://i.imgur.com/lVTFZxL.png)
1414

@@ -26,4 +26,6 @@ This allows one to verify the algorithms' time complexity with real-world data.
2626
- The tree is auto-layouted using a modified Wetherell and Shannon algorithm for visually pleasant and efficient use of space
2727

2828
# Build
29-
Uses .NET 9.0 and C# 13 preview with WPF UI. To build with Visual Studio 2022.
29+
Uses .NET 9.0 and C# 13 preview with WPF UI. To build with Visual Studio 2022.
30+
Utilizes [Material Design](http://materialdesigninxaml.net/) NuGet package for the interface theme, as well as [ScottPlot library](https://scottplot.net/) for rendering the collected performance data into graphs.
31+
The interface is connected to the logical binary tree with a composite model, where `BinTree<T>` and `Node<T>` manage their respective `BinTreeControl` and `BinTreeNode` WPF controls, respectively.

UI/BinTreeMan.xaml.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
217217
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
218218
}
219219

220+
/// <summary>
221+
/// The last operation that was performed. It will be exeucted when pressing the Enter key.
222+
/// </summary>
220223
Action<object, RoutedEventArgs> lastOperation;
221224

222225
/// <summary>

0 commit comments

Comments
 (0)