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.
5,128 questions
5
votes
1
answer
417
views
A Java program for compressing/decompressing files via Huffman algorithms (version 1.0.0)
Intro
(See the version A Java program for compressing/decompressing files via Huffman algorithms (version 1.1.1).)
(The full repository is here. It contains also some unit tests that do not fit in ...
4
votes
2
answers
347
views
HuffmannEncoder.java - computing prefix codes for arbitrary (generic) alphabets
(See the continuation of this post at HuffmanEncoder.java - computing prefix codes for arbitrary (generic) alphabets - Take II.)
I have this Java implementation of the Huffmann encoding. It looks like ...
4
votes
3
answers
474
views
A simple method for compressing white space in text (Java) - Take II
Intro
In this post, I will elaborate on A simple method for compressing white space in text (Java). Here, I have incorporated some advice offered by Chris. Also, this version preserves a single new ...
5
votes
1
answer
529
views
A simple method for compressing white space in text (Java)
(The story continues in A simple method for compressing white space in text (Java) - Take II.)
Intro
Now I have that text space compressor. For example,
...
1
vote
1
answer
110
views
Jump point search in Java for faster pathfinding in grid mazes
(Refer to the entire repository in GitHub.)
How it looks like
Intro
This time, I present my take on Jump point search that I translated from Javascript (PathFinding.js/src/finders/JumpPointFinderBase....
5
votes
2
answers
364
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 ...
7
votes
4
answers
679
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 ...
4
votes
2
answers
142
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)\$...
8
votes
2
answers
301
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 ...
0
votes
0
answers
62
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\$ ...
1
vote
0
answers
64
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 ...
7
votes
1
answer
878
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 ...
3
votes
1
answer
138
views
Calculate optimal game upgrades, v3
This is the third iteration of the code from Calculate optimal game upgrades, v2 and Calculate optimal game upgrades. I'm looking for suggestions to further optimize this code. A brief summary of the ...
5
votes
3
answers
569
views
Strength of a Pyramid Top
I need to solve the following competitive programming problem from coderun.ru:
Strength of a Pyramid Top
The pyramid consists of n horizontal layers of blocks: the first layer contains n blocks, the ...
2
votes
1
answer
128
views
Swift: Find neighbor-elements within an array
I need a function which finds the left and right neighbor-element within an integer-array, based upon a given index. If the given element is 0, then it shall return largest index as left neighbor. ...
1
vote
0
answers
65
views
Lock free Leaky Bucket Rate Limiter
I want to validate my solution for a lock-free leaky bucket rate limiter. Given a queuing capacity and rate limit per second, it should queue requests till capacity is reached and it should allow only ...
6
votes
3
answers
762
views
N queen problem-like (+rooks and a different goal)
The problem is:
You have Q queens and R rooks on a board with sides of length (R+Q) ≤ 8, and you have to place all the pieces so that none attack any other piece. Each square on the board has a score ...
2
votes
0
answers
56
views
Use Mathematica to calculate Treewidth
The treewidth is a measure of the count of original graph vertices mapped onto any tree vertex in an optimal tree decomposition.
I wrote Mathematica code to calculate Treewidth
based on the Python ...
5
votes
3
answers
1k
views
Project Euler Problem #1: Multiples of 3 or 5
Project Euler Problem #1
Multiples of 3 or 5 states:
If we list all the natural numbers below 10 that are multiples of 3 or
5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of ...
4
votes
0
answers
85
views
SHA1 Algorithm Implementation in Zig
I have implemented the SHA1 algorithm in Zig, as a learning exercise, to teach myself both Zig and the actual algorithm behind SHA1. Now the second part I think I understood well enough. The ...
5
votes
2
answers
102
views
Calculate distance score for local alignments (ex. Gotoh local)
Is there a better way to calculate distance scores for local alignment than this? Or is the method that I'm currently using robust enough? The full code is here with the actual alignment ...
7
votes
3
answers
580
views
Team picker command line application
I've made a program for randomly splitting game participants into different teams. The code works and solves the problem. I'm interested in advice on what you'd do differently or better.
...
2
votes
1
answer
217
views
Attempt at a Different Variation of the strstr(...) Function
I decided to work on an idea I had to 'optimize' the classic C function strstr.
Most of the implementations I had seen that did not make use of advanced ...
3
votes
1
answer
86
views
More shortest unrestricted paths to touch every square in an n by n grid
This is a part two.
The problem originates from here,
it is solved for \$n<11\$. A GitHub repository for this code, printing paths, and a collection of all proven best paths, it is open to ...
4
votes
3
answers
570
views
Finding Special Parts in a Word
Task description:
Imagine you have a long word made up of small letters like "a", "b", "c", ancd so on. Let’s call this word a puzzle word.
We want to look at all the ...