Skip to main content
5 votes

A Java program for compressing/decompressing files via Huffman algorithms (version 1.0.0)

Multiple aspects of this implementation of a Huffman encoder and decoder are inefficient. At the top level, a bit-by-bit tree-walking decoder is inherently slow. Almost every practical decoder uses ...
user555045's user avatar
  • 12.6k
4 votes

Shortest Cell Path In a given grid

Style Let's look at this conditional in shortestCellPathHelper. ...
Chris's user avatar
  • 6,546
3 votes

Huffman code builder in Java - computing prefix codes for arbitrary (generic) alphabets - Take II

The HuffmanEncoder is not an encoder. It's a builder that constructs the code table for the symbols based on the weights. An encoder would take input and encode it ...
TorbenPutkonen's user avatar
3 votes

HuffmannEncoder.java - computing prefix codes for arbitrary (generic) alphabets

Minor but, Huffman only has a single n in the name. But let's move on to how the code words are built, the meat of the algorithm after all. ...
user555045's user avatar
  • 12.6k
3 votes

HuffmannEncoder.java - computing prefix codes for arbitrary (generic) alphabets

Style When I look at your formatting in the following snippet, for some reason you have a newline after the first argument to Double.compare, but this line would be ...
Chris's user avatar
  • 6,546
3 votes

Hackerearth: Counting numbers in an array that are divisible by any 2 numbers

Always assume that coding challenge websites will give you worst case scenarios to test your code. They won't test your code with small arrays of small numbers. They'll give you large arrays with huge ...
Chris's user avatar
  • 6,546
3 votes

Sanitize and standardize street addresses using Google Maps lookups

Exception handling ...
Chris's user avatar
  • 6,546
3 votes

Parse path string

Movement conflates at least three different things: tokenising/scanning (part of lexing), evaluating, and application of the path to start coordinates. In other ...
Reinderien's user avatar
  • 71.2k
2 votes

Finding strings in a matrix

I think one of the biggest opportunities here is to make this more generic with the use of templates. We should be able to look for a sequence of values of any type in a vector of vectors. A ...
Chris's user avatar
  • 6,546
2 votes

Parse path string

Portability I realize this question was posted many years ago when Python version 2.x was prevalent, but now that it is deprecated, consider porting to 3.x. To do so, it is necessary to add ...
toolic's user avatar
  • 16.6k
2 votes

Sanitize and standardize street addresses using Google Maps lookups

Layout Move all the functions to the top after the import lines. Having them in the middle of the code interrupts the natural flow of the code (from a human ...
toolic's user avatar
  • 16.6k
2 votes

Binary Search Tree implementation in C [1]

Style You mix braces and not using braces freely throughout your code. While this works, it leaves open the possibility of adding to branches of conditionals or to loops and forgetting to add braces, ...
Chris's user avatar
  • 6,546
2 votes

Inserting into a linked list

If we're assuming that head is not NULL, so let's split up the responsibilities: writing a separate function that finds the tail ...
Chris's user avatar
  • 6,546
1 vote

Create a snail matrix

DRY Let's look at your testing code. ...
Chris's user avatar
  • 6,546
1 vote

Hackerearth: Counting numbers in an array that are divisible by any 2 numbers

Portability I realize this question was posted many years ago when Python version 2.x was prevalent, but now that it is deprecated, consider porting to 3.x. To do so, it is necessary to add ...
toolic's user avatar
  • 16.6k

Only top scored, non community-wiki answers of a minimum length are eligible