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.

1 vote
3 answers
22 views

How can I optimize this solution to avoid TLE in LeetCode?

I am working on this LeetCode problem where I have to count the minimum number of operations to make all elements in an array equal to zero 3542. Minimum Operations to Convert All Elements to Zero ...
Jared McCarthy's user avatar
4 votes
3 answers
449 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 ...
coderodde's user avatar
  • 32.1k
2 votes
2 answers
246 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 ...
coderodde's user avatar
  • 32.1k
5 votes
1 answer
516 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, ...
coderodde's user avatar
  • 32.1k
2 votes
1 answer
133 views

ShannonFanoEncoder.java - computing prefix codes in Java

Intro This time, I have implemented the Shannon-Fano coding. Code io.github.coderodde.compression.ShannonFanoEncoder.java ...
coderodde's user avatar
  • 32.1k
1 vote
1 answer
98 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....
coderodde's user avatar
  • 32.1k
4 votes
2 answers
504 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
5 votes
2 answers
362 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
89 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
  • 32.1k
7 votes
4 answers
669 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
1 answer
80 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
  • 32.1k
4 votes
2 answers
140 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
  • 32.1k
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
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 ...
Pangi's user avatar
  • 370
5 votes
2 answers
418 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
  • 32.1k

15 30 50 per page
1
2 3 4 5
342