Giter VIP home page Giter VIP logo

c-order-statistic-reb-black-tree-implementation's Introduction

Bank-account-management-with-OS-RB-TREE

Description

The goal of this C project is managing a dynamic set of in-memory bank accounts ๐Ÿ’ฐ proficiently as possible (by run-time means, as a factor of set size, i.e., the amount of bank accounts in the set). Managment of the dynamic set includes supporting the basic dictionary CRUD operations and additional custom queries, such as finding maximum account in the set & finding all accounts which contain a negative balance.

Considering the tradeoffs of different data-structures for the problem in hand, those which were found as most appropriate were Red-Black ๐Ÿ”ดโšซ and Order-Statistic ๐Ÿ“Š balanced โš–๏ธ binary-search trees ๐ŸŒด. These data-structures are fully implemented in this project from scratch, based on the pseudo-code of CLRS. With these data-structures all basic dictonary operations & queries take O(lgN) at most (where N is size of the dynamic set), while some (such as querying the max key record) take only constant time O(1). Besides these, the query which enumerates all M records with a negtive balance requires O(M+lgN).

Inorder to enable these optimized run times for queries both by Account id and Account balance, the program maintains two red-black trees: one manages all records in the set by balance as the primary key of the records, and other serves as an index and manages a light-weight version of the records by accout id as a primary key. Both are pointing towards each-other between parallel nodes inorder to keep in sync and bind the data regardless the index (tree) used.

For further details of the considerations taken, runtime analysis and so forth, see: detailed documentation ๐Ÿ“‘

Naming Convention

The following two conventions are used throughout in this project:

  • OS-Tree: Order-Statistic Tree (which is an extended red-black balanced binary search tree).
  • RB-Tree: Red-Black Tree balanced binary search tree.

Modules

Module Files Content & Responsibility
IO_UTILS io_utils.c, io_utils.h I/O Interaction, Validations & Global Configurations
OS_TREE os_tree.c, os_tree.h Index Records by Account Balance, Support RB & OS Operations (CRUD, Queries, Rotations, Rank,..., Including Enumerating Ranges
RB_TREE rb_tree.c, rb_tree.h Index Records by Account Id, Support RB Operations & Bind to OS Tree for Staying in Sync
MAIN main.c Initialization, Memory Management, Controller of Program Flow, Output Log

Input/Output Examples

Schematic Diagram Of The Trees Used in This Project & The Way They Bond to Each Other

Schematic Diagram of the two red-black trees binding

A Standard Red-Black Tree

A standard red-black binary search tree: Red-Black Standard Tree

c-order-statistic-reb-black-tree-implementation's People

Contributors

cwelt avatar

Stargazers

 avatar

Forkers

nequesmith

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.