Coder Social home page Coder Social logo

Comments (2)

davidsonbrsilva avatar davidsonbrsilva commented on July 24, 2024 2

Good afternoon! So, I've tested the BinaryMaxHeap class according the steps above and here the execution was perfect. For testing, I've created a execution project with a Main Class program with the follow code:

BinaryMaxHeap<long> maxHeap = new MaxHeap<long>(Comparer<long>.Default);
Random rand = new Random();

/* Adding the elements to heap. */
for (int i = 0; i < 80000; ++i)
{
    maxHeap.Add(rand.Next());
}

/* Removing the elements from heap. */
while (!maxHeap.IsEmpty)
{
    var element = maxHeap.ExtractMax();

    /* Showing part of heap. */
    if (maxHeap.Count % 2000 == 0)
    {
        Console.WriteLine(element);
    }
}

Maybe the found problem is related to execution time to generate random numbers, it's my guess. If a random object is created each time a random number is generated, putting the instantiation line inside loop affects performance.

Hope this helps!

from c-sharp-algorithms.

aalhour avatar aalhour commented on July 24, 2024

@crucialize - would you like to submit a PR for this?

from c-sharp-algorithms.

Related Issues (20)

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.