Questions tagged [comparative-review]
This tag is used for questions which present a problem and multiple solutions, where the asker wishes to know which solution is best (and why).
948 questions
3
votes
2
answers
176
views
firstNonNull implementations
Between the two implementations, which one is better?
...
1
vote
1
answer
70
views
Solving maximum network flow problem in Java: Edmonds Karp algorithm vs. Relabel-to-front
Intro
This time, I present two maximum flow algorithms:
Edmonds Karp algorithm,
Relabel-to-front.
(The entire repository with unit tests and more may be found here.)
Code
...
3
votes
2
answers
236
views
Comparing determinant algorithms: Laplacian expansion vs. Gaussian elimination in Java
This post presents two algorithms for computing determinants in square matrices. My code follows.
Code
io.github.coderodde.determinant.LongSquareMatrix.java:
...
12
votes
5
answers
2k
views
Efficiency when converting camelCase to snake_case
I have just finished the 'camel' task of CS50 Introduction to Programming with Python where you have to convert camelCase to snake_case. After, I like to look online and compare my code to others to ...
5
votes
1
answer
55
views
Fast method to detect Stop Loss vs Take Profit hits in R trading backtest
I'm building a trading backtesting system in R where I need to determine whether a Stop Loss (SL) or Take Profit (TP) is hit first for each trade. If both are hit in the same bar, SL wins the tie.
I ...
7
votes
4
answers
523
views
MinMaxStack - tracks minimum and maximum values
I'm implementing a MinMaxStack<T> in C++20 that tracks minimum and maximum values. The class needs T to support ...
2
votes
2
answers
272
views
Benchmarking in Java some super linearithmic sorting algorithms
Intro
A sort is called super linearithmic if its running time is \$\omega(N \log N)\$. For example, \$f(N) = \omega(g(N))\$ means that \$f(N)\$ grows "faster" than \$g(N)\$. In this post, I ...
0
votes
1
answer
196
views
Does an indentation style which uniquely identifies a column position to its role in the construct it belongs to make Bash code more readable?
What I'm asking here is whether do you think the facts
there is no type enforcing;
there is no indentation enforcing
consoles do not syntax highlight
consoles do not emphasize multi-line input a-la ...
1
vote
0
answers
52
views
Pure and impure Implementations of CSV parser in Clojure
There are two versions of the CSV parser. The latter seems to be more performant than the former, although the former's code is easier to read.
Variant 1, which parses a string:
...
0
votes
1
answer
142
views
Staff Rostering Problem - Minimize max night-shift
I'm doing some mini projects for my club related to fundamental optimization and am having a bit of trouble with this issue.
There are N employees numbered 1, 2, ..., N who need to be scheduled for ...
1
vote
2
answers
158
views
Translating an image encoded as u32 to an array
I have a function in an embedded system which translates an image encoded in a 32-bit integer to 3x9 matrix (an array of arrays):
...
9
votes
2
answers
580
views
Simple LRU cache implementations in C++20
LRU cache is a classical design pattern frequently questioned in programming technical interviews. It is best illustrated with pictures. Here are two examples.
The following are two alternative ...
7
votes
5
answers
932
views
7
votes
2
answers
755
views
C vs. C++: comparing function pointer tables and switch-case for multiple types support
I have some API code that I need to rewrite. The original API is written in C++ and relies heavily on templates and modern C++ features like std::is_same_v. The ...
1
vote
0
answers
51
views
Making a shell around jointjs for react, wondering between two approaches
The React tutorial of joint js shows a way to use jointjs in react. The tutorial is quite limited: it is basically defining a special named div and putting all jointjs code inside.
The jointjs ...