Code Monkey home page Code Monkey logo

c-data-structures's People

Contributors

objectdisorientedprogrammer avatar

Watchers

 avatar  avatar

c-data-structures's Issues

Update readme

Add dependencies and build instructions to the readme along with better documentation or each data structure,

Implement heap data structure

Basic

  • find-max or find-min: find a maximum item of a max-heap, or a minimum item of a min-heap, respectively (a.k.a. peek)
  • insert: adding a new key to the heap (a.k.a., push[3])
  • extract-max [or extract-min]: returns the node of maximum value from a max heap [or minimum value from a min heap] after removing it from the heap (a.k.a., pop[4])
  • delete-max [or delete-min]: removing the root node of a max heap [or min heap], respectively
  • replace: pop root and push a new key. More efficient than pop followed by push, since only need to balance once, not twice, and appropriate for fixed-size heaps.[5]

Creation

  • create-heap: create an empty heap
  • heapify: create a heap out of given array of elements
  • merge (union): joining two heaps to form a valid new heap containing all the elements of both, preserving the original heaps.
  • meld: joining two heaps to form a valid new heap containing all the elements of both, destroying the original heaps.

Inspection

  • size: return the number of items in the heap.
  • is-empty: return true if the heap is empty, false otherwise.

Internal

  • increase-key or decrease-key: updating a key within a max- or min-heap, respectively
  • delete: delete an arbitrary node (followed by moving last node and sifting to maintain heap)
  • sift-up: move a node up in the tree, as long as needed; used to restore heap condition after insertion. Called "sift" because node moves up the tree until it reaches the correct level, as in a sieve.
  • sift-down: move a node down in the tree, similar to sift-up; used to restore heap condition after deletion or replacement.

(from https://en.wikipedia.org/wiki/Heap_(data_structure))

Create unit tests

Write tests for basic functionally of all data structures. Use assert.h or similar.

restructure codebase

Organized the code better so that each data structure is in its own folder with all dependencies.

Heap missing extract function

The max heap has no function to remove the max value and return the max value at the same time.
Implement a new function that does this:

int extractMax(); // similar to pop()

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.