Project Finia Design Doc 1

Some keen readers may notice the iconic logo “F” and “i” in the graphics

Unbalanced Tree Data Structure

In-memory data structures have started to gain popularity these days due to its flexibility. It helps to store data in the form of cache on the frontend. Frontend in-memory data structures can also be dangerous as unrecycled cache can significantly impact the efficiency of the app. Another challenge for in-memory data structures is its mapping from database and data fetching. My design aims to address these issues in this project.

A visual Representation of the unbalanced tree (presented as a list in java)

An Innovative List Representation of the tree structure

Each individual leaf is the fundamental element of the AssetsTypeTree expressed as a list in java. The idea behind a list representation of the tree is to use each leaf node to store the address of the leaf node in the tree by documenting the name of its parent and its parent’s parent.

  • A list representation of the tree is the best way to store the results from deserialization of database query results
  • A list is easier to manipulate in a java setting with the Tree processor objects.

Net Worth Type Tree

A tree structure that stored the item name and address.

  • The data structure for net worth type defines the structure of hierarchy of data. In other words, they provide information about the location of each node in the structure. The address of each node exhaustively outlines the structure itself.
  • The tree structure can be obtained through a deserialization of the database entity AssetsType.
A visual representation of Structure

Net Worth Value Tree

A tree structure that is mostly used to store the value of each net worth item. Note that the data structure for net worth values is highly dependent on the data structure for net worth types. Intuitively, each value node is attached to the corresponding type node via the id. These nodes contain the data and its metadata.

  • The relationship of the Value trees’ nodes are mapped from the Type trees’ nodes as it stored the relationship between nodes.
  • Each node is an AssetsValue object which contains the id, name, value, time.
A visual representation of Data

Type Tree Processor

A data processor is designed to retrieve data of a particular node or a collection of nodes.

  • Used by the adapter of the Expandable List to retrieve the sub group of net worth items in order to format the data stored in AssetsTypeTree so that they are compatible with the Expandable List widgets.
  • Used in the Breadth-First Search algorithm to retrieve the child nodes of a particular node.

Value Tree Processor

The Value Tree Processor is used to manipulate the data stored in the Value tree structure.

  • This processor contains methods to perform READ, EDIT, GROUP, DELETE on the data structure.
  • This data source of the processor also stores all the data including the values and the Type tree.

Leaf Node of Type Tree

Each leaf node contains the name of the leaf node, and the address of the node. A simple example below demonstrates the structure of a leaf node.

Node Container

A node container is essentially a data carrier that contains the essential data of a node as well as its level in the tree structure. It enables a more efficient access of the level as well as essential data when constructing the Multi-Expandable list.

  • Constructing the Expandable Lists: When the data of a certain level is needed, the Type Tree Processor will prepare the node container by putting each node of the particular level into a node container and recording its level. After the preparation is done, the group of node containers will be injected into the Expandable List Adapter. The mechanism in the adapter will assign the group to the corresponding level and retrieve the data in the node container and deliver them to the right widget on the UI.
  • Retrieve the data from the input box and inject into the Tree Processor: Each node container will be “paired” with a Input box (EditText), and a TextListener will be added to the Input Box. Once change is detected, the value will be injected into an AssetsValue object and stored in the data source (list of AssetsValue objects) Value Tree Processor. The id from the node container will also be injected and used as an identifier of the node.

DFS Algorithm

Another highlight in Finia is the algorithm to calculate net worth. A DFS (Depth-First Search) algorithm operates on the unbalanced tree at O(n) running time which gives users a speedy calculation. When the calculation starts, the algorithm will traverse the in-memory unbalanced tree and calculate the sum of leaf nodes and return a value to be assigned to their parent node. A value will be returned when the calculation is complete.

  • It allows the value of each sub parent node to be calculated individually and inserted to the database.
  • The value of each sub parent node will also be used to calculate the parent.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store