Code Monkey home page Code Monkey logo

min-heap's Introduction

CLASS MIN-HEAP

  • A min-heap is a heap in which the root has the smallest value in the heap.
  • In our min-heap each node has a value and 0, 1 or 2 children heaps. The root node of a min-heap contains the smallest value in the heap. If you pick any node in the heap it has a value that is equal to or less than all the nodes in either the left or right sub-heaps of the node.

Node Insertion Logic In Min-Heap

  • To add a new value to the heap add it to the top of the heap.
  • If the heap is empty the new value becomes the root.
  • If heap is not empty then the smaller of the two values (current value in heap and the new value) is kept in the root.
  • The larger of the two values is added the sub-heap with the smallest height.
  • If both sub-heaps have the same height then the larger of the two values is added to the left heap.
  • The process is repeated until a value is added to a new node at the bottom of the heap.

CONSTRUCTOR DETAILS

  • private MinHeapNode(String data)

    • Constructs a Min-Heap Node with the specified value.
  • public MinHeapNode()

    • Default Constructor.

METHOD DETAILS

  • addElement(String data)

    • This function add Node in Min Heap.
  • int getHeapDepth(MinHeapNode currentNode)

    • This function calculates the depth of heap from current node.
  • ArrayList getHeapValuesList()

    • This functions returns values in the heap in pre-order (root, the left sub-heap, right sub-heap).
  • ArrayList getValuesWithINGList()

    • This functions returns strings that end in "ing" in the heap in pre-order.

min-heap's People

Contributors

hs0490 avatar

Watchers

James Cloos avatar  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.