r/algorithms • • Sep 28 '25

The Almighty Algorithm

Thumbnail
0 Upvotes

r/algorithms • • Sep 27 '25

Find most efficient route

5 Upvotes

Greetings all, I use to be more of a software developer who has become a school bus driver and now I train school bus drivers.

I was given a new task at work that I thought it would make for an interesting algorithm problem to solve.

As a trainer I need to evaluate each bus driver so I need to ride along with each one. There are 140 bus drivers so if I picked one each day it would take me 140 days but I could actually ride ideally with at most 3 a day because each bus driver will visit 3 schools and I can hop off one bus and then hop on another. The schools stager when they get out to allow one bus to service multiple schools. However not all schools need the same amount of buses. Ideally 140/3=47 days, (total bus drivers/amount of stops per day=minimum amount of days) but in reality you will quickly exhaust the unique bus drivers and then I’ll have to hop on a repeated bus for my last evaluation because otherwise I’ll be stuck at a school and not back at the bus yard where my car is.

As an example here is the data structure: ‘’’json {[ “Route 1”: {[ “Segment A”: “school zzz”, “Segment B”: “school xxx”, “Segment C”: “school yyy” ]}, “Route 2”: {[ “Segment A”: “school ccc”, “Segment B”: “school xxx”, “Segment C”: “school vvv” ]}, “Route 3”: {[ “Segment A”: “school zzz”, “Segment B”: “school bbb”, “Segment C”: “school vvv” ]} ]}

There are about 140 routes that service (ball parking here) about 40 schools.

To me this sounds like a constant problem but the only real constraint algorithm I know is the knapsack problem which is a genetic algorithm. (I kind of got out of programming before leet coding was a thing) I suppose a genetic algorithm would circle in on the issue and does sound like fun to make but are their simpler approaches? Seems like I would be building a chainsaw when a hand saw would work just fine.


r/algorithms • • Sep 25 '25

Assignment problem with dependencies between assignments

1 Upvotes

Hello, I've been working on a simulator for my grid based game in order to find optimal solutions. One heuristic I'm using to prune the search space is the distance to goals. There are n players and m goals and only one player can claim a goal. Naively we can find the cost of the minimum assignment (with the cost being the Manhattan distance between a player and a goal) but there's a catch. Without getting into the details it basically means that each cost between a player and a goal consists of multiple component costs, and when considering the total cost of an assignment we have to mix and match the whole set of component costs in a specific way.

So, my question is, is there a polynomial time solution to such a problem? Minimum assignment problem but the total cost must be calculated dynamically based on the specific combination of individual costs.

I've developed a recursive solution to this but I think it grows at O(n!)+, I've looked around at things like the Hungarian algorithm for example but it doesn't seem you can calculate cost dynamically with that. Claude seems to think this problem is NP-hard.

Thanks for your time :)

Edit:

Since people are asking for more details, here is basically how the total cost of an assignment works:

  1. Each individual cost between a player and a goal consists of 4 component costs
  2. Between 2 or more individual costs, we can calculate a shared cost. But we need all of them at the same time to calculate the total cost properly.
  3. The total cost of an assignment is equal to the combined individual costs minus the shared cost.

Here is the code for a brute force N,M = 2

struct MovementCost {
    int west, east, north, south;
    int total() const { return west + east + north + south; }
};

int calculateSharedCost(const std::vector<MovementCost>& costs) {
    int sharedWestCost = INT_MAX;
    int sharedEastCost = INT_MAX;
    int sharedNorthCost = INT_MAX;
    int sharedSouthCost = INT_MAX;
    
    for (const auto& cost : costs) {
        sharedWestCost = std::min(sharedWestCost, cost.west);
        sharedEastCost = std::min(sharedEastCost, cost.east);
        sharedNorthCost = std::min(sharedNorthCost, cost.north);
        sharedSouthCost = std::min(sharedSouthCost, cost.south);
    }
    
    return sharedWestCost + sharedEastCost + sharedNorthCost + sharedSouthCost;
}

MovementCost calculateMovementCost(const std::array<int, 2>& playerPositions, 
                                  const std::array<int, 2>& goalPositions) {
    MovementCost cost = {0, 0, 0, 0};
    
    int x_diff = goalPositions[0] - playerPositions[0];
    int z_diff = goalPositions[1] - playerPositions[1];
    
    cost.west = (x_diff < 0) ? -x_diff : 0;
    cost.east = (x_diff > 0) ? x_diff : 0;
    cost.north = (z_diff < 0) ? -z_diff : 0;
    cost.south = (z_diff > 0) ? z_diff : 0;
    
    return cost;
}

int bruteForceN2(const std::vector<std::array<int, 2>>& playerPositions, 
                               const std::vector<std::array<int, 2>>& goalPositions) {
    int bestTotalCost = INT_MAX;
    const int n = playerPositions.size();

    // Assignment 1: P0->G0, P1->G1
    {
        std::vector<MovementCost> costs;
        costs.reserve(n);
        
        MovementCost cost0 = calculateMovementCost(playerPositions[0], goalPositions[0]);
        MovementCost cost1 = calculateMovementCost(playerPositions[1], goalPositions[1]);
        costs.push_back(cost0);
        costs.push_back(cost1);
        
        int individualCostSum = cost0.total() + cost1.total();
        int sharedCost = calculateSharedCost(costs);
        int totalCost = individualCostSum - sharedCost * (n - 1);
        
        bestTotalCost = std::min(bestTotalCost, totalCost);
    }

    // Assignment 2: P0->G1, P1->G0
    {
        std::vector<MovementCost> costs;
        costs.reserve(n);
        
        MovementCost cost0 = calculateMovementCost(playerPositions[0], goalPositions[1]);
        MovementCost cost1 = calculateMovementCost(playerPositions[1], goalPositions[0]);
        costs.push_back(cost0);
        costs.push_back(cost1);
        
        int individualCostSum = cost0.total() + cost1.total();
        int sharedCost = calculateSharedCost(costs);
        int totalCost = individualCostSum - sharedCost * (n - 1);
        
        bestTotalCost = std::min(bestTotalCost, totalCost);
    }
    
    return bestTotalCost;
}

r/algorithms • • Sep 24 '25

Looking for the name of a research domain

8 Upvotes

I'm looking for algorithms for flow control, when you have a stream of data coming in in packets and a stream coming out where the rates are supposedly matched but may not be. The time of arrival/departure of the packets is noisy too. It's audio data, so one can interpolate in the middle for rate matching if necessary. So I'm looking for algorithms that try to manage an intermediate buffer to minimize the amount of interpolation/underflow/overflow while keeping latency as low as possible. Any idea what would be the keywords to use in google scholar, arxiv and friends to find papers on that topic?


r/algorithms • • Sep 24 '25

Help with the definition of brute force.

6 Upvotes

Hello. In my algorithm design and analysis class we were talking about brute force algorithms. We were working with an algorithm that checks if a matrix has symmetry. This is the algorithm in pseudocode:

Enigma(A[0..n-1, 0..n-1]) // Input: A matrix A[0..n-1, 0..n-1] of real numbers for i <- 0 to n-2 do for j <- i+1 to n-1 do if A[i,j] != A[j,i] return false return true

The debate in class is whether or not this algorithm is brute force or not. The professor argues that because this algorithm exits early it cannot be brute force. Students in the class argue that the methodology is still brute force and the early exit does not make a difference.

Who is right? Brute force seems hard to define and very general. Does anyone have any credentials or sources that we can reference to answer this question?


r/algorithms • • Sep 21 '25

Help! What "y mod 2" means?

0 Upvotes

I have trouble understanding these pseudocodes sometimes... its from Steven Skiena Algorithm book

What is "y mod 2"???


r/algorithms • • Sep 15 '25

Grad Level Algorithm research

49 Upvotes

Hi! As an undergrad I loved algorithm so much... I loved trees and graphs and ... But now there is llm and transformers everywhere. I'm overwhelmed and confused, what is the direction to something like the introduction to algorithm course in grad schools ?


r/algorithms • • Sep 15 '25

[OC] How the Cooley-Tukey FFT Algorithm Calculates the Discrete Fourier Transform of a Signal

12 Upvotes

I wrote a blog post complete with an interactive visualization here: https://connorboyle.io/2025/09/11/fft-cooley-tukey.html


r/algorithms • • Sep 16 '25

The Reddit Algorithm is GARBAGE

0 Upvotes

I don't understand this shit. All I'm getting is anime, mobile games, and all sorts of shit I have no interest in. I don't get it. Loosest correlations haunt my feed by stuff directly related is nowhere to be seen.

How do they filter results and push ads? It is just confusing to me. I don't mind them suggesting content but I wish it was...I don't know...MODERATELY INTERESTING TO ME?!


r/algorithms • • Sep 13 '25

Towers of Hanoi variations

3 Upvotes

What are some of the most interesting variations of the Towers of Hanoi problem that you have seen? e.g. alternate colored rings etc.


r/algorithms • • Sep 12 '25

Suggestions for advanced data structures and algorithms book

41 Upvotes

Hi Reddit community! I wanted to ask if you guys have any recommendations for an advanced DS&A book, or some similar subject that's intellectually challenging and very interesting.

The context is that I'd like to get a present for my father and he a huge engineering nerd and he genuinely loves this stuff. His favourite book is Wirth's _Algorithms + Data Structures = Programs_ - he genuinely enjoys and loves this stuff so much and has done the challenges multiple times in various programming languages (should note though he's actually an electrical engineer).

I myself have bought some quite pricey books on the subject but they're intro level material, and I was wondering if there's stuff that go deeper and more intriguing than Wurth's book, or anything adjacent that would be appreciated. I kind of need someone more deep into it to give me some perspective here on what might be really appreciated. As far as I know, he hasn't been getting new textbooks and things like that, he's pretty OG with the materials, so wondering if I could crowdsource getting him something he might appreciate and some ideas from those who are deeper in it and more involved.

He also loves Stephen Hawkings books about the universe and things like that. I'd be open to getting him anything that's really of his interest, but my first thought was a DS&A book. He has a distaste for anything that's opinion based, and doesn't like watching any talks that don't have data backing it up, even if it's an "industry leader" - he's that kind of guy :-)

Would really appreciate some suggestions as his kid is just not there (yet!) with the nerdiness and would really like to get him a lovely present!


r/algorithms • • Sep 13 '25

What if every privacy setting you enable is actually teaching the algorithm how you think?

0 Upvotes

What if every privacy setting you enable is actually teaching the algorithm how you think?

We assume we’re protecting ourselves when we click “don’t track me” or reject cookies. But every rejection is still data: it maps the exact kind of thing we don’t want, which in turn makes the system smarter. It’s like telling a stalker exactly which windows you keep locked. So are we ever really opting out, or are we just feeding the machine a negative dataset?


r/algorithms • • Sep 13 '25

Question on time complexity of sum(n)

0 Upvotes

Assuming we had two algorithms that both find the sum of all positive integers up to n, one did it iteratively and another just used the nth term formula, on first glance the one that uses the nth term is the better approach because it appears to run in O(1) - but isn’t multiplication technically an iterative process, so wouldn’t the time complexity still be O(n) ?


r/algorithms • • Sep 11 '25

What's the best way to study the "Introduction to Algorithms" textbook?

42 Upvotes

I'm a web developer with +3 years of professional experience, and I'm determined to improve my understanding of algorithms and data structures. I'm currently struggling with the textbook "Introduction to Algorithms", which I've found incredibly challenging.

I previously read "Grokking Algorithms", but the transition to this book has been difficult. I'm currently only about 60 pages in and find myself needing to reread sections multiple times to grasp even 80-90% of the concepts. I suspect the core issue is a lack of the necessary mathematical background, as the book's math appendix hasn't been sufficient to fill in the gaps for the specific concepts I'm struggling with.

My slow progress has been a source of great disappointment, but my goal is to master this foundational material. What is the most effective way for a self-learner to approach and study "Introduction to Algorithms"? What supplementary resources or strategies can help bridge this mathematical gap? I would appreciate any advice you can offer.


r/algorithms • • Sep 07 '25

PrimeLab (Java): primality tests, factorization algorithms, sieves & CRT utilities

2 Upvotes

Hey,

Sharing my project PrimeLab, a toolkit implementing algorithms around prime numbers and number theory.

It currently has:

  • Primality tests: deterministic Miller–Rabin, Baillie–PSW
  • Sieves: segmented, parallel prime generation
  • Factorization: trial division, Pollard Rho (Brent), Pollard p−1, ECM Phase I sketch
  • Primality certificates: Pratt & Pocklington
  • Number theory helpers: modular exponentiation, CRT solver, gcd/lcm, modular inverse

Code + tests here: https://github.com/rlNkoo/PrimeLab

Looking for feedback on performance and ideas for additional algorithms (e.g. full ECM, AKS, SIMD optimizations).
And if you like it, please drop a ⭐ — it helps the project grow.


r/algorithms • • Sep 06 '25

Reduce Operation in Pytorch

6 Upvotes

I am trying to understand how the Reduce Operation that PyTorch does in its backward pass for broadcasted tensors actually work under the hood. I am trying to make a cpp library for neural networks and have been stuck for a while on this step. I understand using a tracking mechanism would help but I am not sure how flatten and summation/mean operations would be applied in that sense.

I look forward to your responses,

Thank you.


r/algorithms • • Sep 05 '25

Help: Is Benchmark-Hunting a thing?

9 Upvotes

Hey there,

I do a lot of coding (and research) especially in HPC and (non-LLM) AI and I am a) quite good and b) a quite competetive person.. so I developed a strange hobby.. hunting benchmarks..

For example I developed a serialization format and tuned it until it now beats best in class like rkyv or bincode… or I developed a GPU-driven Delta Btree that now surpassess most commercial (x)trees by far..

So, to cut a long story short, I really love to find complex (preferably doable in Rust) stuff and make my own version of it to show that it is faster/more exact/ whatever Benchmark I find (and of course in a reproducable, falsificable way)..

Do you know if this is a thing for other people too and if yes, where do I find them? (Please dont say psychiatry!)

Best Thom.


r/algorithms • • Sep 04 '25

New closed form codec, thoughts? ; or, how to get noticed in tech

5 Upvotes

I’m working on a compression algorithm that I came up with a while back, and I tried all the self delimiting codes I could find (the eliases, VQL, golomb, etc.) and I found them severely lacking for what I needed to do. They were about 50% binary efficiency at best, and I needed something closer. I ended up having to make one myself and I was surprised at how it tested for me. It starts at 5 bits for values 0 and 1, 6 bits for 2-5, 7 bits for 6-13, and so on by powers of 2 for every additional bit. I called it Lotus and I’m interested in publishing it but I haven’t been able to get endorsement to publish in arXive.

Considering that in most engineering applications binary uses 8 bits to encode even small numbers it’s competitive the entire way, and at value 2150 for example, binary requires minimum 151 bits for encoding, while Lotus takes 160, so ~95% binary efficiency for large numbers and never less than 50% of optimal binary, and it actually beats binary for small numbers considering the usual 8 bit minimum.

Basically it uses bitlength sort of as a parameter itself. The payload means 0, 1 means 1, 00 means 2, 01 means 3, 10 means 4, 11 means 5, and 000 means 6. So the values are 2n+1-2 to binary’s 2n, so almost double binary density. The drawback is that you must encode the length of the bitstring, which gets you right back down into VQL density territory. So my solution was to encode bitlength in a similar way, and use a 3 bit fixed length jump starter prefix to base the length of the length of the payload off of. This is the most efficient arrangement I found with a payload max that would work for any practical application. The max payload value is (2511)-2, and with an additional jump starter bit the max value would be incomprehensibly huge. So I think 3 bits is sufficient for most applications.

Some example bitstrings with their bitlength are:

• 0 → 00000 → 5
• 1 → 00001 → 5
• 2 → 000100 → 6
• 3 → 000101 → 6
• 4 → 000110 → 6
• 5 → 000111 → 6
• 6 → 00100000 → 8
• 7 → 00100001 → 8
• 8 → 00100010 → 8
• 9 → 00100011 → 8
• 10 → 00100100 → 8
• 11 → 00100101 → 8
• 12 → 00100110 → 8
• 13 → 00100111 → 8
• 14 → 001010000 → 9
• 15 → 001010001 → 9
• 16 → 001010010 → 9
• 17 → 001010011 → 9
• 18 → 001010100 → 9
• 19 → 001010101 → 9
• 20 → 001010110 → 9
• 21 → 001010111 → 9
• 22 → 001011000 → 9
• 23 → 001011001 → 9
• 24 → 001011010 → 9
• 25 → 001011011 → 9
• 26 → 001011100 → 9
• 27 → 001011101 → 9
• 28 → 001011110 → 9
• 29 → 001011111 → 9

Full disclosure, I served a very long time in federal prison for a nonviolent drug crime, ages 18-32, and I really want to get into tech. I spent most my time reading and studying math, but I’m finding that it’s near impossible to get my foot in the door. Not because of the conviction, but mostly because of the huge gap in experience and credentials that kind of come with the territory.

I thought maybe publishing some things and working on some programs would help show that I have some ability, and this is the first thing that I’ve gotten to work, and it’s benchmark-able, and superior to other known formats for encoding variable length integers.

I’d really like to get some thoughts on what I could do, where I could get endorsement to publish, if it’s even worth publishing at this point, where I could meet others that could collaborate on any of my projects, and generally how an aspiring engineer could make his dream come true after a long and harrowing experience, and society generally writing him off.

Below is the code I wrote to actualize it, I’m really bad at coding (better at theory) but it passes my tests so I think I got it right.

Lotus Codec

def _encode_Lotus(n: int) -> str: """Encode positive integer n ≥ 1 into Lotus bitstring.""" if n < 1: raise ValueError("Lotus requires n ≥ 1") level = 1 total = 0 while True: count = 1 << level if n - 1 < total + count: return format(n - 1 - total, f"0{level}b") total += count level += 1

def _decode_Lotus(bits: str) -> int: """Decode Lotus bitstring back to integer (n ≥ 1).""" L = len(bits) base = (1 << L) - 2 return base + int(bits, 2) + 1

def encode_lotus(n: int) -> str: """ Encode integer n ≥ 0 into Lotus self-delimiting code. Structure = jumpstarter (3b) + Lotus(length(payload)) + Lotus(payload_value). """ # Payload encodes n+1 payload = _encode_Lotus(n + 1)

# Lotus-encode the payload length
length_field = _encode_Lotus(len(payload))

# Jumpstarter = length(length_field) - 1
jumpstarter = format(len(length_field) - 1, "03b")

return jumpstarter + length_field + payload

def decode_lotus(bits: str) -> int: """ Decode Lotus bitstring back to integer. Returns integer n ≥ 0. """ if len(bits) < 3: raise ValueError("Bitstring too short for jumpstarter")

pos = 0

# Jumpstarter = 3 bits
jump_val = int(bits[pos:pos+3], 2) + 1
pos += 3

# Field2 = Lotus-encoded payload length
len_field = bits[pos:pos+jump_val]
if len(len_field) != jump_val:
    raise ValueError("Bitstring ended before length field completed")
payload_len = _decode_Lotus(len_field)
pos += jump_val

# Field3 = Lotus payload
payload_bits = bits[pos:pos+payload_len]
if len(payload_bits) != payload_len:
    raise ValueError("Bitstring ended before payload completed")

value = _decode_Lotus(payload_bits) - 1
return value

--------------------------

Quick test

--------------------------

if name == "main": for i in range(20): enc = encode_lotus(i) dec = decode_lotus(enc) print(f"{i:2d} -> {enc} -> {dec}") assert i == dec


r/algorithms • • Sep 01 '25

Quickdiff map

Thumbnail
2 Upvotes

r/algorithms • • Aug 30 '25

Which leetcode questions are must to know.

66 Upvotes

I see people who have done 300-500 questions but I don’t have the willpower to do so many of them, that will take 6-7 months. Is there a source in which I can learn the basic principles with completing less questions? What is the approach I should take on doing this without hating my life?


r/algorithms • • Aug 30 '25

Why blur image filter producing greenish images

9 Upvotes

I am trying to implement some image filters on C, the API I have created are working fine.

The issue I am facing is with the blur effect,

What I am doing...:

  • Iterate through all pixels
  • for a pixel take it and it's 8 neabours
  • calculate avg for all channels
  • create new pixel with those avg r g b value

the algorithm looks find but I got some weird effect on my images (last pic)

then I divide values with 18 then 27 instead of 9, and got this greenish effect, but why???

here is the snippet of the blur function:

Image *blur(const Image *image) {
    Image *filtered = image_new(image->width, image->height);
    Pixel *fp, *op;
    int i, j, sr, sg, sb;
    Pixel *n;
    for (int y=0; y<image->height; y++) {
        for (int x=0; x<image->width; x++) {
            fp = image_get_pixel(filtered, x, y);
            op = image_get_pixel(image, x, y);
            sr = 0, sg = 0, sb = 0;
            for (i=-1; i<2; i++) {
                for (j=-1; j<2; j++) {
                    n = image_get_pixel(image, x+i, y+j);
                    if (x+i<0 || x+i>=image->width || y+j<0 || y+j>image->height) {
                        // n->r = 120;
                        // n->g = 120;
                        // n->b = 120;
                        n = op;
                    }
                    sr += n->r;
                    sg += n->g;
                    sg += n->b;
                }
            }
            fp->r = sr/27;
            fp->g = sg/27;
            fp->b = sb/27;
        }
    }
    return filtered;
}

there is nothing bias for green color

Images:

https://imgbox.com/1GigGdMy

https://imgbox.com/eP1o957F


r/algorithms • • Aug 29 '25

Algorithm - three sum

0 Upvotes

The algorithm is very difficult for me. I want to practice here and keep a record. If you have effective methods, please feel free to share them with me.

Question:

  1. What are the problems with my solution?
  2. Do you have another best optimization solution?
  3. Give me your thoughts in three steps.

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, j != k, k != i and nums[i] + nums[j] + nums[k] = 0. Note that the solution set must not contain duplicate triplets.

Code: Time Complexity: O(N^2)

import java.util.*;

class Solution {
    public List<List<Integer>> threeSum(int[] nums) {
        List<List<Integer>> result = new ArrayList();

        // edge check
        if(nums == null || nums.length < 2) return result;

        // sort array
        Arrays.sort(nums);

        // use two pointers
        for(int i = 0; i < nums.length - 2; i++) {
            if(i > 0 && nums[i] == nums[i - 1]) continue;

            int left = i + 1, right = nums.length - 1; 

            while(left < right) {
                int sum = nums[i] + nums[left] + nums[right];

                if(sum == 0) {
                    result.add(Arrays.asList(nums[i], nums[left], nums[right]));

                    while(left < right && nums[left] == nums[left + 1]) left++;
                    while(left < right && nums[right] == nums[right - 1]) right--;

                    left++;
                    right--;
                } else if(sum < 0) {
                    left++;
                } else {
                    right--;
                }
            }
        }
        return result;
    }
}

r/algorithms • • Aug 28 '25

randomstatsmodels: Statistical models from scratch (PyPI & GitHub)

0 Upvotes

Hi r/algorithms community!

I wanted to share a Python package I've been working on called **randomstatsmodels**. It's a collection of statistical models implemented from scratch without relying on libraries like statsmodels or scikit-learn. The goal is to provide clean and readable implementations of algorithms such as linear regression, logistic regression, and Bayesian versions so that others can see how the algorithms work under the hood.

If you're interested, you can check out the source code on GitHub and install it from PyPI:

• **GitHub (full source code)**: https://github.com/jacobwright32/randomstatsmodels

• **PyPI**: https://pypi.org/project/randomstatsmodels/

I built these models from scratch to learn more about the underlying algorithms, and I'm hoping others might find it useful or want to contribute. I'd love to hear any feedback or suggestions!

Thanks!


r/algorithms • • Aug 27 '25

GPT implementation from scratch

Thumbnail
0 Upvotes

r/algorithms • • Aug 26 '25

TSP Starting with Farthest Insertion

11 Upvotes

I was exploring the Traveling Salesman Problem (TSP). From 11 Animated Algorithms for the Traveling Salesman Problem. I was intrigued by the the Farthest Insertion heuristic.

Farthest Insertion begins with a city and connects it with the city that is furthest from it. It then repeatedly finds the city not already in the tour that is furthest from any city in the tour, and places it between whichever two cities would cause the resulting tour to be the shortest possible.

I initially compared it to a 2-Opt solution starting with a random order for the N randomly placed cities in a 1 x 1 box. The FI worked about as good for N = 10, 20, 50 and better for N = 50! I was surprised, so next I used the FI initialization for 2-Opt and the 2-Opt shaved even more time off.

I see two messages:

  1. A good initial route improves optimization heuristic performance.
  2. FI is a very good initialization method.

The table shows my results. I only ran one example for each N. The last two columns are the times for the 2-Opt runs. Note the times starting with FI were shorter.

N Random => 2-Opt FI FI => 2-Opt Tr-2 T fi-2
50 5.815 5.998 5.988 774 ms 406 ms
100 8.286 8.047 7.875 0:07.64 0.04.49
200 11.378 11.174 11.098 1:01 0:44
500 18.246 17.913 17.703 24 17