Skip to content

Commit 51a054b

Browse files
committed
Organized the classes in Algorithms and Data Structures projects into sub-categories.
1 parent 5ff4ba0 commit 51a054b

38 files changed

+116
-94
lines changed

Algorithms/Algorithms.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
<Compile Include="Sorting\InsertionSorter.cs" />
3838
<Compile Include="Sorting\QuickSorter.cs" />
3939
<Compile Include="Sorting\MergeSorter.cs" />
40-
<Compile Include="Helpers\Comparers.cs" />
41-
<Compile Include="Helpers\Helpers.cs" />
40+
<Compile Include="Common\Comparers.cs" />
41+
<Compile Include="Common\Helpers.cs" />
4242
</ItemGroup>
4343
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
4444
<ItemGroup>

Algorithms/Helpers/Comparers.cs renamed to Algorithms/Common/Comparers.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22

3-
namespace Algorithms.Helpers
3+
namespace Algorithms.Common
44
{
55
public static class Comparers
66
{

Algorithms/Helpers/Helpers.cs renamed to Algorithms/Common/Helpers.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System;
22
using System.Collections.Generic;
33

4-
using DataStructures;
4+
using DataStructures.Lists;
55

6-
namespace Algorithms.Helpers
6+
namespace Algorithms.Common
77
{
88
public static class Helpers
99
{

Algorithms/Sorting/BinarySearchTreeSorter.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33

4-
using DataStructures;
5-
using Algorithms.Helpers;
4+
using Algorithms.Common;
65

76
namespace Algorithms.Sorting
87
{

Algorithms/Sorting/HeapSorter.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33

4-
using DataStructures;
5-
using Algorithms.Helpers;
4+
using Algorithms.Common;
65

76
namespace Algorithms.Sorting
87
{

Algorithms/Sorting/InsertionSorter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33

4-
using DataStructures;
4+
using DataStructures.Lists;
55

66
namespace Algorithms.Sorting
77
{

Algorithms/Sorting/MergeSorter.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33

4-
using DataStructures;
5-
using Algorithms.Helpers;
4+
using Algorithms.Common;
65

76
namespace Algorithms.Sorting
87
{

Algorithms/Sorting/QuickSorter.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33

4-
using DataStructures;
5-
using Algorithms.Helpers;
4+
using Algorithms.Common;
65

76
namespace Algorithms.Sorting
87
{

DataStructures/Helpers/Comparers.cs renamed to DataStructures/Common/Comparers.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
using System;
22

3-
using DataStructures;
3+
using DataStructures.Lists;
4+
using DataStructures.Trees;
45

5-
namespace DataStructures.Helpers
6+
namespace DataStructures.Common
67
{
78
public static class Comparers
89
{

DataStructures/Helpers/Helpers.cs renamed to DataStructures/Common/Helpers.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System;
22
using System.Collections.Generic;
33

4-
namespace DataStructures.Helpers
4+
using DataStructures.Lists;
5+
6+
namespace DataStructures.Common
57
{
68
public static class Helpers
79
{

DataStructures/DataStructures.csproj

+19-19
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,26 @@
3939
<Reference Include="System.Xml" />
4040
</ItemGroup>
4141
<ItemGroup>
42-
<Compile Include="AVLTree.cs" />
43-
<Compile Include="BinarySearchTree.cs" />
44-
<Compile Include="Interfaces\IAVLTree.cs" />
45-
<Compile Include="Interfaces\IBinarySearchTree.cs" />
46-
<Compile Include="Interfaces\IMaxHeap.cs" />
47-
<Compile Include="Interfaces\IMinHeap.cs" />
42+
<Compile Include="Trees\AVLTree.cs" />
43+
<Compile Include="Trees\BinarySearchTree.cs" />
44+
<Compile Include="Trees\IAVLTree.cs" />
45+
<Compile Include="Trees\IBinarySearchTree.cs" />
46+
<Compile Include="Heaps\IMaxHeap.cs" />
47+
<Compile Include="Heaps\IMinHeap.cs" />
4848
<Compile Include="Properties\AssemblyInfo.cs" />
49-
<Compile Include="Stack.cs" />
50-
<Compile Include="ArrayList.cs" />
51-
<Compile Include="DLinkedList.cs" />
52-
<Compile Include="SLinkedList.cs" />
53-
<Compile Include="Queue.cs" />
54-
<Compile Include="MinHeap.cs" />
55-
<Compile Include="MaxHeap.cs" />
56-
<Compile Include="Helpers\Helpers.cs" />
57-
<Compile Include="KeyedPriorityQueue.cs" />
58-
<Compile Include="PriorityQueue.cs" />
59-
<Compile Include="Helpers\Comparers.cs" />
60-
<Compile Include="BinaryTree.cs" />
61-
<Compile Include="Interfaces\IBinaryTree.cs" />
49+
<Compile Include="Lists\Stack.cs" />
50+
<Compile Include="Lists\ArrayList.cs" />
51+
<Compile Include="Lists\DLinkedList.cs" />
52+
<Compile Include="Lists\SLinkedList.cs" />
53+
<Compile Include="Lists\Queue.cs" />
54+
<Compile Include="Heaps\MinHeap.cs" />
55+
<Compile Include="Heaps\MaxHeap.cs" />
56+
<Compile Include="Common\Helpers.cs" />
57+
<Compile Include="Heaps\KeyedPriorityQueue.cs" />
58+
<Compile Include="Heaps\PriorityQueue.cs" />
59+
<Compile Include="Common\Comparers.cs" />
60+
<Compile Include="Trees\BinaryTree.cs" />
61+
<Compile Include="Trees\IBinaryTree.cs" />
6262
</ItemGroup>
6363
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6464
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

DataStructures/Interfaces/IMaxHeap.cs renamed to DataStructures/Heaps/IMaxHeap.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
namespace DataStructures.Interfaces
2+
namespace DataStructures.Heaps
33
{
44
public interface IMaxHeap<T> where T : System.IComparable<T>
55
{

DataStructures/Interfaces/IMinHeap.cs renamed to DataStructures/Heaps/IMinHeap.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
namespace DataStructures.Interfaces
2+
namespace DataStructures.Heaps
33
{
44
public interface IMinHeap<T> where T : System.IComparable<T>
55
{

DataStructures/KeyedPriorityQueue.cs renamed to DataStructures/Heaps/KeyedPriorityQueue.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33

4-
namespace DataStructures
4+
namespace DataStructures.Heaps
55
{
66
/// <summary>
77
/// Implements the Keyed Priority Queue Data Structure.

DataStructures/MaxHeap.cs renamed to DataStructures/Heaps/MaxHeap.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using System;
22
using System.Collections.Generic;
33

4-
using DataStructures.Interfaces;
5-
using DataStructures.Helpers;
4+
using DataStructures.Common;
5+
using DataStructures.Lists;
66

7-
namespace DataStructures
7+
namespace DataStructures.Heaps
88
{
99
/// <summary>
1010
/// Maximum Heap Data Structure.

DataStructures/MinHeap.cs renamed to DataStructures/Heaps/MinHeap.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using System;
22
using System.Collections.Generic;
33

4-
using DataStructures.Interfaces;
5-
using DataStructures.Helpers;
4+
using DataStructures.Common;
5+
using DataStructures.Lists;
66

7-
namespace DataStructures
7+
namespace DataStructures.Heaps
88
{
99
/// <summary>
1010
/// Minimum Heap Data Structure.

DataStructures/PriorityQueue.cs renamed to DataStructures/Heaps/PriorityQueue.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33

4-
namespace DataStructures
4+
namespace DataStructures.Heaps
55
{
66
/// <summary>
77
/// Implements the Priority Queue Data Structure.

DataStructures/ArrayList.cs renamed to DataStructures/Lists/ArrayList.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33

4-
namespace DataStructures
4+
namespace DataStructures.Lists
55
{
66
/// <summary>
77
/// The Array-Based List Data Structure.

DataStructures/DLinkedList.cs renamed to DataStructures/Lists/DLinkedList.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System;
22
using System.Collections.Generic;
33

4-
using DataStructures.Helpers;
4+
using DataStructures.Common;
55

6-
namespace DataStructures
6+
namespace DataStructures.Lists
77
{
88
/// <summary>
99
/// The Doubly-Linked List Node class.

DataStructures/Queue.cs renamed to DataStructures/Lists/Queue.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33

4-
namespace DataStructures
4+
namespace DataStructures.Lists
55
{
66
/// <summary>
77
/// The Queue (FIFO) Data Structure.

DataStructures/SLinkedList.cs renamed to DataStructures/Lists/SLinkedList.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33

4-
namespace DataStructures
4+
namespace DataStructures.Lists
55
{
66
/// <summary>
77
/// Singly Linked List Data Structure

DataStructures/Stack.cs renamed to DataStructures/Lists/Stack.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33

4-
namespace DataStructures
4+
namespace DataStructures.Lists
55
{
66
/// <summary>
77
/// The Stack (LIFO) Data Structure.

DataStructures/AVLTree.cs renamed to DataStructures/Trees/AVLTree.cs

+34-17
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
using System;
22
using System.Collections.Generic;
33

4-
using DataStructures.Interfaces;
5-
using DataStructures.Helpers;
4+
using DataStructures;
65

7-
namespace DataStructures
6+
namespace DataStructures.Trees
87
{
98
/// <summary>
109
/// AVL Tree Node.
@@ -74,37 +73,54 @@ public AVLTree()
7473
}
7574

7675

77-
public int Count()
76+
private void _leftRotate(AVLTreeNode<T> currentNode)
7877
{
79-
throw new NotImplementedException();
78+
8079
}
8180

82-
public bool IsEmpty()
81+
private void _rightRotate(AVLTreeNode<T> currentNode)
8382
{
84-
throw new NotImplementedException();
83+
8584
}
8685

87-
public void Insert(T value)
86+
private void _rebalance(AVLTreeNode<T> currentNode)
8887
{
89-
throw new NotImplementedException();
88+
9089
}
9190

92-
public void Delete(T value)
91+
public new int Count()
9392
{
94-
throw new NotImplementedException();
93+
return _count;
9594
}
9695

97-
public T Find(T value)
96+
public new bool IsEmpty()
97+
{
98+
return (_count == 0);
99+
}
100+
101+
public override void Insert(T value)
102+
{
103+
var newNode = new AVLTreeNode<T>() { Value = value };
104+
base._insertNode(Root, newNode);
105+
}
106+
107+
public override void Remove(T value)
108+
{
109+
var node = (AVLTreeNode<T>) base._findNode(Root, value);
110+
base._remove(node);
111+
}
112+
113+
public override T Find(T value)
98114
{
99115
throw new NotImplementedException();
100116
}
101117

102-
public T FindMin()
118+
public override T FindMin()
103119
{
104120
throw new NotImplementedException();
105121
}
106122

107-
public T FindMax()
123+
public override T FindMax()
108124
{
109125
throw new NotImplementedException();
110126
}
@@ -119,14 +135,15 @@ public T FindPredecessor(T value)
119135
throw new NotImplementedException();
120136
}
121137

122-
public T[] FindAll(Predicate<T> searchPredicate)
138+
public override List<T> FindAll(Predicate<T> searchPredicate)
123139
{
124140
throw new NotImplementedException();
125141
}
126142

127-
public void Clear()
143+
public override void Clear()
128144
{
129-
throw new NotImplementedException();
145+
this._count = 0;
146+
this._root = null;
130147
}
131148
}
132149

DataStructures/BinarySearchTree.cs renamed to DataStructures/Trees/BinarySearchTree.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
using System.Collections;
33
using System.Collections.Generic;
44

5-
using DataStructures.Interfaces;
6-
using DataStructures.Helpers;
5+
using DataStructures.Common;
76

8-
namespace DataStructures
7+
namespace DataStructures.Trees
98
{
109
/// <summary>
1110
/// The binary search tree node.
@@ -221,20 +220,20 @@ protected virtual bool _remove(BSTNode<T> node)
221220
else if (node.HasLeftChild) // if the node has only a LEFT child
222221
{
223222
_replaceNodeInParent(node, node.LeftChild);
224-
_updateSubtreeSize(parent);
223+
//_updateSubtreeSize(parent);
225224
_count--;
226225

227226
}
228227
else if (node.HasRightChild) // if the node has only a RIGHT child
229228
{
230229
_replaceNodeInParent(node, node.RightChild);
231-
_updateSubtreeSize(parent);
230+
//_updateSubtreeSize(parent);
232231
_count--;
233232
}
234233
else //this node has no children
235234
{
236235
_replaceNodeInParent(node, null);
237-
_updateSubtreeSize(parent);
236+
//_updateSubtreeSize(parent);
238237
_count--;
239238
}
240239

@@ -528,6 +527,7 @@ public virtual void Remove(T item)
528527

529528
var node = _findNode(_root, item);
530529
bool status = _remove(node);
530+
_updateSubtreeSize(node.Parent);
531531

532532
// If the element was found, remove it.
533533
if (status == false)

0 commit comments

Comments
 (0)