121,449 questions
Best practices
0
votes
15
replies
304
views
Best practice for "is value in list" macro in C without relying on sentinel values?
I'm looking for a clean and robust way to implement a membership check for a list of integers in C.
I currently use a variadic macro that creates a temporary array on the stack and uses a sentinel ...
Advice
0
votes
5
replies
169
views
Smoothly animating real-time GPS vehicle position with only 1 update/second, without adding lag
I'm building a real-time dashboard that displays moving vehicles (cars) on screen, based on GPS data. The GPS itself is accurate (no significant noise), but I only receive one position update per ...
Advice
1
vote
6
replies
105
views
Music shuffle: adapt to physical state (heart rate, cycle) or stick to genre-consistent history-based?
This idea is about a music shuffle algorithm.
It's not meant to replace traditional algorithms, but rather for people who don't enjoy shuffling within a single genre and prefer a playlist that changes ...
Best practices
0
votes
3
replies
136
views
Best way to start DSA for placements
I am a Computer Science student preparing for technical interviews and placements. I want to build a strong foundation in Data Structures and Algorithms (DSA), but I am unsure about the most effective ...
Tooling
0
votes
3
replies
114
views
Library for convex polygon intersection
I am seeking a fast implementation of convex polygon intersection. CGAL and boost has algorithms for the intersection of general polygons, but they are not specialized for convex polygons, hence they ...
Best practices
0
votes
3
replies
96
views
How to suggest movies that the user didn't see already in real time?
I am building a simple school project, and the idea is that users form a group together, then an activity (for example movie activity), and then in that activity the app suggests movies for every ...
Best practices
1
vote
9
replies
218
views
How to use better OOP for a Huffman Compressor
So I refactored my Huffman program for better OOP practices. Now, I need to make an array of coded objects that represent a character and its
// C++ program to implement huffman coding
#include <...
Advice
0
votes
3
replies
106
views
Can a transformation pattern be inferred from example input/output pairs?
I'm experimenting with a small tool that receives:
an input string A
an expected output string B
Example:
Input:
{'name':'John','email':'john@email'}
Output:
insert into users (name,email)
values ('...
Best practices
0
votes
3
replies
198
views
How to actually compress a .txt file after obtaining a Huffman encoding
So I have this program that takes an unordered map of chars and integers as a frequency counter and returns the Huffman encoding as a map.
#include <iostream>
#include <queue>
#include <...
Advice
0
votes
3
replies
182
views
How to determine if a point is inside a triangle?
How to determine if a point is inside a triangle? I need to create a method bool inTriangle(Point p, Point tr1, Point tr2, Point tr3) that returns 1 (true) if point p is inside or on the boundary of ...
Advice
0
votes
4
replies
166
views
The fastest algorithm for the problem "Cheapest flight within k stops"?
I am doing a coursework on algorithms and complexity. The problem is just what is stated in the title, that is to find the fastest algorithm for the problem "Cheapest flight within k stops".
...
Advice
0
votes
5
replies
94
views
The number of edges present in the forest generated by the DFS traversal of an undirected graph G with N vertices is K. No of connected component
I am learned algorithm of dfs and everything but still I have a doubt when this question came up. Even I know how to do it. But I didn't able to solve.
I know the solution but I need someone to teach ...
Advice
0
votes
4
replies
130
views
Could the L1 Cache Save Computation Time?
The CPU cache unit is used to store the next few instructions so that the (expensive) process of reading and writing the RAM is bypassed to save execution time. Has anyone thought about using the L1 ...
Advice
2
votes
7
replies
125
views
Spatial decomposition on non-uniform grid
I am not sure Stack Overflow is the right place for this question but I'm shooting my shot.
I have a 2D field sampled on a global longitude-latitude structured curvilinear grid and I would like to ...
Advice
2
votes
11
replies
310
views
Modulus of Very large Number
You are given a very large number N (which goes upto 1e10000)
and a 64 bit integer P.
How do i find N % P?
for example:
N= 8290826691135830692772803 , P = 95972011
modulus (N % P) = 60316167
obviously ...