121,489 questions
0
votes
0
answers
31
views
deleting a node from a red black tree
I have been following the Cormen algorithm for RB trees, but I have a question regarding deletion, specially in this case:
38
31 41
all the nodes are black and I want to delete 38. After ...
0
votes
0
answers
57
views
How to calculate the points on the "perimeter" on a bitmask?
I am making a drawing application and i have to show the borders of the pencil. To know where to place the pixels I use a list of integer offsets from the cursor that make up a shape, so the cursor is ...
-4
votes
1
answer
142
views
Why doesn’t my insertion sort implementation work? [closed]
I understand the idea of the insertion sorting algorithm, and I know how it works after watching many videos and doing research. However, I had never seen any code for it, so I tried to code it myself....
Tooling
0
votes
12
replies
98
views
Filtering an inconsistent string
I'm working on a project in which I need to filter out specific strings from an inconsistent API, where the strings are not always what I want. I need to filter out eligibility for different education ...
Advice
2
votes
3
replies
47
views
How does DP provide optimization over backtracking in 0-1 Knapsack problem
0-1 Knapsack problem is often used as a starting problem to understand dynamic programming. This problem can also be solved using backtracking. Now, backtracking explores all possible subsets and uses ...
Best practices
2
votes
15
replies
141
views
Is there a concept in Python 3 which integrates with the while-statement like an iterator does with the for-statement?
General question
I wonder how to express any code of the form
while True:
state_before = some_function(my_object)
# algorithmic code goes here
state_after = some_function(...
Advice
0
votes
2
replies
37
views
Big O Notation - data structures
i am learning about big o notation and need a little bit of clarity before i diverge into the wrong path. my understanding is o() is suppose to represent the time it takes for a program to do a task ...
Advice
0
votes
5
replies
53
views
Converting latitude and longitude from degrees to meters
As the title says, how can i convert a value that i have from a longitude or latitude from degrees to meters ? The task is basically to calculate MAE errors for x,y,z of trajectory prediction, MAE Z ...
Advice
2
votes
10
replies
55
views
How to fit a circle onto a weathered pipe?
I have a 3d scan of a metal pipe and I can slice it at different heights. When looking at a cross-section of a new pipe, the data should match the shape of a perfect circle, but due to erosion the ...
Advice
6
votes
12
replies
123
views
Best algorithm for doing fixed-point euclidean difference?
I need a fast algorithm to compute fixed-point euclidean distance in 3D. I'm really struggling to find a fast solution.
I am working on a 32-bit RISC-V processor where I have fast multiply, but no ...
1
vote
1
answer
130
views
How flash 8 brush worked?
I'll be questioning about a drawing program - flash 8 and how its brush worked.
The question is about math, bezier curves, vectors, algoritms, geometry.
i'm trying to recreate how Flash 8's brush tool ...
Best practices
4
votes
5
replies
98
views
Implementing a special case of combination
I have an array of arrays which are not necessary of the same size which I want to combine in the following way.
Each nested array is scanned in the order they appear in the main array. The scanned ...
Best practices
2
votes
2
replies
46
views
Python/GenAI/LLM: Best practices for asking follow‑up questions to clarify user intent in a chatbot
I’m building a chatbot using Python, pydantic_ai, google_genai, and the gemini‑2.0‑flash‑lite model. The bot includes a module responsible for retrieving context from a knowledge base (RAG). The ...
3
votes
1
answer
465
views
Optimize, or correct, a code for interpolation and parameter estimation
This is a simple question, but will be a little long so I can give all the context to what is happening. Essentially, this is a code question/issue and the physical context behind is just to ...
Advice
0
votes
7
replies
99
views
Brute force vs optimal approach to find the second largest number in a slice (Go)
I’m looking to understand both:
A brute force solution
An optimal solution (in terms of time and space complexity)
The input is a slice of integers, for example:
nums := []int{10, 5, 20, 8, 15}
...