New answers tagged

1

General Review Make all instance fields that are never reassigned final. private final PriorityNode<T>[] items; private final Set<T> itemSet; Make constants static and readonly, and use underscores for readability. private static readonly int INITIAL_CAPACITY = 4; private int capacity = INITIAL_CAPACITY; Don't introduce unnecessary new ...


2

Nice implementation. Don't be alarmed by this list of thoughts/opinions/observations: In __init__, it might make more sense to make both parameters optional with default values. You wouldn't normally expect a library to interactively ask for missing parameters. Python code typically isn't written to check types at runtime. def __init__(self, heap: list=...


3

It's always worth tidying up indentation and removing random blank lines (e.g. after {). Naming: in C# it's conventional that method names are in UpperCamelCase, but even if you choose not to follow the convention it's important to be consistent. Here Heapify follows the convention but insert doesn't. The name Heapify usually refers to taking an ...


Top 50 recent answers are included