Skip to content

itayG98/Box-Data-Structure-app

Repository files navigation

Purpose of the app

The app should manage storage in the most efficient way

My project demonstrate using two linked generics data structures ,BST and Doubly linked list. The app manage a boxes store storage and can add remove and give best offer for squared bottomed box represented by X as width and length and Y as height. It stores the data for the boxes in doubly dimensional BST with key and value and Date descending order linked list.

Binary search tree

My generic BST can search and find element with Complexity of Log(h) where h is the height. using generic key and value i can store complex data in efficient get add and delete operation. i also added Searching with minimum and maximum value in efficient search.

  • Main tree has Double type key and BST type value
  • Each inner BST has Double type key and Box type value

The order of searching item with (16,10) keys with 33% percentage accuracy.

Doubly linked list

My list implement addition like a queue and handle delete items in descending Order the time complexity of add and remove is by O(1) thanks to the Prev and Next pointer in each node.

Remove node from the doubly linked list.

Getting Ienumerable BST of the ranged valid values

public IEnumerable GetNextTreeByRange(K min, K max)
{
if (max.CompareTo(min) >= 0)
{
TreeNode commonFather = Root;
while (commonFather != null)
{
if (commonFather.CompareTo(min) < 0)
commonFather = commonFather.Right;
else if (commonFather.CompareTo(max) > 0)
commonFather = commonFather.Left;
else
break;
}
foreach (TreeNode node in Inorder(commonFather))
{
if (node.CompareTo(min) >= 0 && node.CompareTo(max) <= 0)
yield return node.Value;
else if (node.CompareTo(max) > 0)
break;
}
}
}

Method returns best offer as an enumerable using the previos Ienumerable method

public IEnumerable<Box> GetBestOffer(double width, double height, int quantity)
{
int temp;
if (width > 0 && height > 0 && quantity > 0)
{
foreach (BST<double, Box> Ytree in MainTree.GetNextTreeByRange(width, width * (1 + LIMIT_PERCENTAGE / 100)))
{
foreach (Box b in Ytree.GetNextTreeByRange(height, height * (1 + LIMIT_PERCENTAGE / 100)))
{
temp = quantity < b.Count ? quantity : b.Count;
quantity -= temp;
yield return (b);
if (quantity < 1)
break;
}
if (quantity < 1)
break;
}
}
}

The Boxes store UI in UWP.

Releases

No releases published

Packages

No packages published

Languages