Skip to main content

Questions tagged [algorithm]

An algorithm is a sequence of well-defined steps that define an abstract solution to a problem. Use this tag when your issue is related to algorithm design.

3 votes
2 answers
472 views

Finding a sequence of xors to change a to b

I'm resolving a problem from CodeForces: C. Beautiful XOR. This is what the code is supposed to do: You have two numbers a and b. You must transform a into b using XOR operations (...
Jared McCarthy's user avatar
4 votes
2 answers
345 views

BRESort - Bitwise Relationship Extraction - Intelligent Adaptive Sorting Engine for 32/64-bit & Floating-Point Data

I want to begin by sincerely thanking the community for the invaluable feedback on my previous BRESort byte-sorting research. Your insights about enums, named constants, loop optimizations, and test ...
LazyCauchPotato's user avatar
4 votes
1 answer
84 views

Dijkstra's algorithm for non-uniform undirected hypergraphs: Take II - bidirectional Dijkstra's algorithm with excellent performance

Intro (See the full repository here.) A non-uniform undirected hypergraph is a generalization of an undirected graph. It is defined as \$H = (X, E)\$, where \$X\$ is the set of vertices and \$E \...
coderodde's user avatar
  • 31.9k
7 votes
4 answers
621 views

My BRESort adaptive sorting engine in C

I've created BRESort - an adaptive sorting engine that dynamically selects optimal algorithms based on data patterns. It achieves 3.6-4.2x speedup over stdlib qsort ...
LazyCauchPotato's user avatar
0 votes
0 answers
63 views

Computing loan cuts leading to a global zero equity in a financial graph (Java)

Intro I won't specify the problem here, but instead, provide the link to the blog post discussing the problem and the full implementation. Code ...
coderodde's user avatar
  • 31.9k
4 votes
2 answers
133 views

Dijkstra's algorithm for non-uniform undirected hypergraphs

Intro (Repo here.) A non-uniform undirected hypergraph is a generalization of an undirected graph. It is defined as \$H = (X, E)\$, where \$X\$ is the set of vertices and \$E \subseteq \mathcal{P}(X)\$...
coderodde's user avatar
  • 31.9k
5 votes
5 answers
1k views

Check whether a binary tree is symmetric

I implemented a recursive solution that compares the left and right subtree in mirrored fashion. It works for my test cases, but I would like to know if there are any best practices that would make ...
Jared McCarthy's user avatar
8 votes
2 answers
293 views

Implementation of a kd-tree header-only library

I've took inspiration from https://www.geeksforgeeks.org/cpp/kd-trees-in-cpp/ and implemented a kdtree library and I would like to get a review of it. The main target was to have a kd-tree ...
Pangi's user avatar
  • 370
4 votes
2 answers
411 views

Ordinary insertion sort vs. straight insertion sort in Java (benchmark)

Intro So this time I wanted to find out which of the two insertion sort flavours are faster: Code io.github.coderodde.util.StraightInsertionSort.java: ...
coderodde's user avatar
  • 31.9k
0 votes
0 answers
57 views

Computing \$k\$ most reliable paths in undirected probabilistic graphs in Java

Intro (See MostProbablePath.java.) This time, I elaborate on Computing most probable (reliable) path in a probabilistic graph (take II): instead of computing the most reliable path I now return \$k\$ ...
coderodde's user avatar
  • 31.9k
4 votes
1 answer
282 views

Computing most probable (reliable) path in a probabilistic graph (take II)

Intro A probabilistic graph \$G = (V, E)\$ is an undirected graph with weight function \$w \colon E \rightarrow [0, 1]\$. In the most reliable path problem we -- given two terminal nodes \$s \in V\$ ...
coderodde's user avatar
  • 31.9k
1 vote
0 answers
62 views

PathFinding.java: Drawing a random perfect maze via randomized DFS

Intro Still working on PathFinding.java. This time I concentrate on three private methods of GridModel that are responsible for generating random perfect mazes. A maze is perfect if for each two cells ...
coderodde's user avatar
  • 31.9k
2 votes
2 answers
103 views

Checking for weak string isomorphism in Java

Intro I call two \$n\$-strings \$s\$ and \$z\$ over the alphabet \$\Sigma\$ weakly isomorphic if their character frequency multisets are equal. In other words, for an input strings \$s\$, we derive a ...
coderodde's user avatar
  • 31.9k
7 votes
1 answer
875 views

Move generation in my C++ chess engine [closed]

I am building a chess engine in C++ and currently working on the move generation. To measure performance I use perft, but my main goal is to make the move generator itself faster. I already use ...
Viliam Holly's user avatar
4 votes
1 answer
133 views

PathFinding.java: Beam search in Java

Intro I am currently working on this project (PathFinding.java). This time, I need to get the following class reviewed: Code ...
coderodde's user avatar
  • 31.9k

15 30 50 per page
1
2 3 4 5
342