Coder Social home page Coder Social logo

ml_utils's Introduction

Description

This module includes a java implementation of a dynamic heap. With a dynamic heap, the ordering value of an element in the heap can be changed, and the position of the respective element in the dynamic heap will be automatically adjusted to maintain the heap property.

Constructors

The implementation provides two constructors:

  1. One constructor DynamicHeap(ArrayList, Comparator) takes a ArrayList of Nodes, and builds a heap in O(N) time complexity using the ArrayList without copying it. This constructor is provided for applications where space/memory complexity requires an in-place heap. The resulting DynamicHeap will utilize the ArrayList passed to the constructor, and the heap property and function are not guaranteed if the ArrayList is modified externally.

  2. The second constructor DynamicHeap(Collection, Comparator) takes a Collection of Nodes, and builds a heap in O(N) time complexity using a copy of the Collection. This constructor is provided for multi-threaded applications where maintaining the heap property and function are critical, and memory complexity of O(N) can be tolerated. The resulting DynamicHeap will utilize its own shallow copy of the Collection passed to the constructor, and the heap property and function are guaranteed since external code can't access the copied collection.

Both of the constructors described above require an instance of a comparator Comparator which is used to define the order of the heap (max heap or min heap). The implementation of the comparator must satisfy the condition and requirements described in the documentation of the java.util.comparator.

Nodes passed to the constructor, and ones added later, can be updated (their ordering values changed), and the the heap will dynamically re-order the nodes when the method updateNode(T aNode) is called.

ml_utils's People

Watchers

James Cloos avatar Ali Ismael avatar

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.