Detailed Report on the Design of a Proposed Inventory System

Verified

Added on  2022/11/18

|7
|2306
|128
Report
AI Summary
This report provides a comprehensive overview of the design of an inventory system. It begins with an introduction outlining the scope of the design, which includes the static and dynamic structures of the system. The report then delves into the variables, keys, and ranges, utilizing a class diagram to model objects and their attributes. It explores the use of object-oriented programming concepts to define classes such as Product, Household, Food, and Inventory. Furthermore, the report details the various operations required to maintain the inventory, including adding, updating, deleting, and searching for items. The core of the report focuses on the algorithms and data structures used, specifically highlighting the binary tree as the most suitable data structure for inventory management. It discusses the advantages of binary trees and explains the implementation of algorithms for adding, searching, and deleting items. The report also addresses potential system changes in case of a merger, discussing the scalability of the binary tree structure. Finally, it concludes by emphasizing the improved performance and efficiency of the inventory system through the use of binary trees. The report references various sources to support its claims and findings.
Document Page
COVER PAGE
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Contents
1 Introduction..............................................................................................................................................3
2 Variables, keys and ranges........................................................................................................................3
3 Operations................................................................................................................................................4
4 Algorithms................................................................................................................................................4
5 Larger system changes.............................................................................................................................6
6 Conclusion................................................................................................................................................7
References...................................................................................................................................................7
Document Page
1 Introduction
This report presents a discussion on the design of the proposed inventory system. The design is
discussed in terms of the static and dynamic structure of the system from the variables , keys and ranges
and that will make up the inventory system, to the operations and algorithms that will be used in the
system with a justification as to why those algorithms are the best fit for the system as opposed to
similar algorithms that can be used in implementing the system. The design is also analyzed in terms of
elasticity in the amount of data its supposed to handle if the system is expanded to handle more data as
a result of a merger between two companies requiring the formed company to use the existing
inventory system.
2 Variables, keys and ranges
The variables that will make up the system can be discussed using a simple class diagram with objects
and attributes that define the objects. The attributes defining an object become the variables during
implementation of the system on the basis of the class diagram.
Figure 1: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . .. Class diagram
The class diagram shown in figure above models the objects modelled as classes that will be used to
implement the system. By following object-oriented programming concepts to implement the system,
we can design the system with the following classes;
Product- The product class will be used to model object with the following attributes: name,
price, type and quantity that is currently available for the product. A key OOP construct will be
implemented in the design of the class as all the variables will be declared as private and then
getter and setter methods will be used to access and mutate the variables respectively.
HouseHould- This class is a child class and inherits all the attributes and operations of the
product class. The relationship between the house hold class and the product class is that the
product class is the parent class while the household class is the child class as shown in the class
diagram. The house hold class has a manufacturer attribute that differentiates it from the food
child class. This class will also have a getter and setter method for the manufacturer attribute
which are used to access and mutate the variable respectively.
Food – this class will be used to model a food product which is a type of product thus the food
class inherits from the product class which is the superclass. The food class will have the expiry
Document Page
data attribute which makes it different from the house hold class. This attribute will have a
getter and setter operations for accessing and mutating the variable respectively.
Inventory class- The inventory class is a composition of the products objects. Its in this class that
the proposed data structure will be implemented to maintain the list of products which are
either house hold products or food products.
Declaration of the object variables will use parameterized constructors for objects with data and default
constructor for empty objects which can later be mutated using mutator methods.
3 Operations
The inventory system will have a range of different operations that will be required to maintain the
inventory. These operations are;
Maintaining inventory items- The system should support an operation that maintains an
inventory which is composed of a list of products. For this operation a data structure will have to
be used.
Adding new items to the inventory- This operation will be used to add a new item to the
inventory.
Updating inventory items- This operation will be used to access an inventory item and update its
details.
Deleting inventory items – The system should support an operation to delete inventory items.
Searching for an item- The system should support an operation to search for a specific item in
the inventory.
4 Algorithms
To maintain the inventory items, the most suitable data structure that can be used for this operation is a
binary tree. A binary tree is hierarchical type of data structure where each node has atleast two
children; left child and right child. Each node of the binary tree contains three components
(Tutorialspoint.com, n.d.);
A pointer pointing to the left subtree.
A pointer pointing to the right subtree.
Data
The first node which is the topmost in the tree is called the root node. In the case where the tree is
empty, its represented using a null pointer. Each node except the root node that a child node is called a
parent node. A node with no children is called a leaf node or an external node while a node with atleast
one children is called a internal node (Cs.cmu.edu, n.d.). The depth of the node is the number of edges
from the root node to the specific node while the height of a node is the number of edges from the
node to the lead that is the deepest thus the height of a binary tree is usually the height of the root
node (Baeldung, 2019).
Binary trees present a number of advantages when used as data structures, these advantages are;
Binary trees represent the relationship of the data stored in the tree in a structural manner.
Data in a binary tree is stored in a hierarchical order thus making it very efficient to insert and
search through the data.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Binary trees present a high degree of flexibility when it comes to moving subtrees in the tree.
There are many types of binary trees based on the structure including rooted binary trees, full binary
trees, perfect binary trees, complete binary trees, balanced binary trees and degenerate binary trees
(Studytonight.com, n.d.). For the proposed inventory system, the data structure to be used is binary
search tree.
The following algorithms will be implemented on the data structure based on the operations defined for
the system;
Adding an item to the inventory- For this operation, the corresponding binary tree algorithm
used is inserting of an element; For this algorithm, the following rules have to be followed;
o If the node being inserted is lower than the current node’s value, go to the left child
vice-versa go to the right child.
o If current node is null i.e. current node is a leaf node then a new node can be inserted in
that position
Insertion of the nodes will be based on the name of the product thus the hierarchical structure
maintained by the tree will be based on the alphabetical order of the names of the various
products in the inventory. The following algorithm will be used for inserting or adding of a new
element in the binary tree (GeeksforGeeks, n.d.);
o Step 1: Define a function taking two parameters; root node and the data being inserted
as the insert function.
o Step 2; Define a temporary node to be used to store the nodes that are popped out
from the queue for searching purposes.
o Step 3: Define a queue data structure that will be used to store the nodes of the binary
tree.
o Step 4: push the root node in the queue.
o Step 5: Initialize a while loop to check if queue is empty or not. If empty go to step 6 else
jump to step 9.
o Step 6: Pop the first node from the queue and store it in the temporary node.
o Step 7: Check the current popped out node in the tree, inside the loop, if the left child in
the tree is null then allocate memory location for the new node, with its right and left
child being null, insert the new node to its position else push its left child in the queue.
o Step 8: repeat step 7 for the right child of the current node in the tree.
o Step 9: end loop
o Step 10: End
This algorithm will be used for adding a new inventory product in the inventory.
Searching and updating an item- These operations will require the traversal of the binary tree.
There are a number of algorithms that can be used to search the binary tree;
o Depth-first search – This method has three types of traversals;
Preorder traversal- This type of traversal involves visiting the parent first then
left children and then right children.
Inorder traversal- This type of traversal involves visiting the left child, then the
parent child and finally the right child.
Document Page
Postorder traversal- This type of traversal involves visiting the left child, then
right child and finally the parent
o Breadth-first search- This type of traversal has only one type of traversal called level
order traversal which involves visiting the nodes by levels stating from to top to bottom
and from left to right.
An type of traversal can be followed to traverse the tree. This algorithm demonstrates searching
of a node using preorder traversal;
o Step 1: Start at the root node and compare the key being searched for with the root.
o Step 2: If the node does not contain the key proceed to either the left child or the right
child based on the comparison.
o Step 3: If the comparison result is negative, go to the left child but if positive go to the
right child
The time complexity for searching for an item in a binary tree is 0(h) where h is the height of the
tree. This is the case where the whole tree has to be traversed to find a node.
Deleting an item- This operation will be implemented using the deletion algorithm. There are
three different cases for deletion of a node;
o Case 1: the node being removed has no children
This case is simple because all that is required to be done is set the corresponding link to
the parent to null and then deleting the node.
o Case 2: The node being removed has one child
For this case, the node has to be cut from the tree and then the algorithm links the
single child directly to the removed node’s parent.
o Case 3: Node being removed has 2 children
This case is the most complex of the three. To remove a node with children, the
following steps are followed;
Separate the node being removed into an independent tree from the main tree.
Find the least value in the right subtree.
Replace the value of the node being removed with the least value found such
that the right tree contains a duplicate.
Apply remove operation to the right subtree to remove the duplicate.
5 Larger system changes
In the case the current company merges with another company and the number of products increase
significantly, there is need to do some changes in the system for some operations and algorithms to
maintain a high level of efficiency with the new sets of data. Since the proposed data structure used is a
binary search tree which is very efficient in insertion and searching no proposed changes would be
recommended for these operations. However, in the case where the sets of data were to grow
exponentially the binary tree can be degenerated to a linked list which reduce the time complexity of
the searching the tree to 0(n) where n is the number of nodes.
Document Page
6 Conclusion
Implementing the inventory system using binary trees instead of primitive data structures like arrays
improves the performance and efficiency of different operations of the system.
References
GeeksforGeeks. (n.d.). Binary Search Tree | Set 1 (Search and Insertion) - GeeksforGeeks. [online]
Available at: https://www.geeksforgeeks.org/binary-search-tree-set-1-search-and-insertion/ [Accessed
18 Sep. 2019].
Studytonight.com. (n.d.). Binary Tree and its Types | Data Structure Tutorial | Studytonight. [online]
Available at: https://www.studytonight.com/data-structures/introduction-to-binary-trees [Accessed 18
Sep. 2019].
Cs.cmu.edu. (n.d.). Binary Trees. [online] Available at:
https://www.cs.cmu.edu/~adamchik/15-121/lectures/Trees/trees.html [Accessed 18 Sep. 2019].
Tutorialspoint.com. (n.d.). Data Structure - Binary Search Tree - Tutorialspoint. [online] Available at:
https://www.tutorialspoint.com/data_structures_algorithms/binary_search_tree.htm [Accessed 18 Sep.
2019].
Baeldung. (2019). Implementing a Binary Tree in Java | Baeldung. [online] Available at:
https://www.baeldung.com/java-binary-tree [Accessed 18 Sep. 2019].
chevron_up_icon
1 out of 7
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]