r/algorithms 3d ago

Help How to identify greedy intution in problem/ competition

Upvotes

I can identify patterns like sliding window, recursion, backtracking, DP, and two pointers. But I’m stuck when it comes to identifying the greedy intuition.

How do I recognize when a problem can be solved using a greedy approach? Are there any good resources—books, YouTube channels, blogs, or websites—that specifically teach how to develop greedy intuition?

Anything that can help me get better at recognizing greedy problems would be really helpful.annel, blog , website)

Anything that help me

r/algorithms 16d ago

Help Self Sort Algorithm

Upvotes

Is there an algorithm where you make each array element an object, provide it with private functions and actions, and then allow it do help with sorting if you broadcast the sort function to all arrays ahead of starting the sort?

For instance, the sort wrapper would just need neighbor information for the cells direct or two steps away and then they could switch in place while a master sorting algorithm verifies end to end sort by just stepping each element and having knowledge of next moves each element is making?

I may be thinking of this more as a Verilog problem than a C++ problem but it seems like it hasn't necessarily been defined or commonly used and I can't imagine why not if the function can be modified for any kind of sorting that is common to each element?​

r/algorithms Aug 07 '26

Help How do you actually learn and practice Algorithms & Analysis?

Upvotes

Hey everyone,

Not sure where to post this, so here i am.I'm new to computer science and currently taking an Algorithms & Analysis course in Python. Honestly, it's one of the hardest subjects in my degree, and I'm struggling to figure out the best way to actually learn these concepts instead of just memorizing them.

This is what we're covering this semester: Basic Data Structures & Algorithmic Analysis, Algorithmic Analysis, Brute Force, Decrease & Conquer, Divide & Conquer, Transform & Conquer, Greedy Techniques, Dynamic Programming, Time & Space Tradeoffs, and Iterative Improvement.

I know Abdul Bari the GOAT, and his videos have definitely helped me understand the theory. But my biggest issue is practice. Everyone recommends LeetCode, but even the Easy problems feel way above my level sometimes. Also, I can't seem to find problems that match the topics we're learning in class, especially things like Transform & Conquer or Iterative Improvement.

So I wanted to ask: how did you learn algorithms when you were just starting out? Where did you practice topic by topic? Are there any websites that organize problems by algorithm rather than difficulty? Should I be doing LeetCode, HackerRank, Codeforces, something else, or just implementing the algorithms from scratch? Any advice for someone who feels completely lost with algorithms?

I'd really appreciate any tips or resources that helped you when you were a beginner. Thanks!

r/algorithms Aug 07 '26

Help Is there an algorithm for optimally distributing sets of files across Blu-ray discs?

Upvotes

Hi, I want to back up my GOG games onto 25 GB Blu-ray discs. Is there an algorithm for optimally splitting the games so they take up as little space as possible?

Thanks for reading

r/algorithms 29d ago

Help Looking for standard Graph Problems with 2 Vertices (Shortest Path, Reachability, LCA in DAG, Max Flow) No variations/twists please!

Upvotes

I am looking for standard graph theory / algorithmic problems where the input is a graph and two target vertices (e.g., source and destination / pair of nodes).

Some specific examples are:

  • Shortest Path (standard unweighted/weighted shortest path between $u$ and $v$)
  • Reachability (checking if $v$ is reachable from $u$)
  • Lowest Common Ancestor (LCA) in a DAG (given two vertices $u$ and $v$ in a DAG)
  • Maximum Flow / Min-Cut (max flow specifically between a source $s$ and sink $t$)

Important constraint: I am strictly looking for pure problems without added variations or twists (no dynamic edge weights, no modified state spaces, no constraints like "at most k skips", etc.).

I would love any kind of response. Additionally, if you have links to the problem definition link or benchmark problem sets that fit this exact criteria, please drop them below!

Thanks in advance!

r/algorithms 17d ago

Help How to find the row echelon form of a stupid big matrix

Upvotes

How to find the row echelon form of a stupid big matrix

I am trying to find an equation that models a fruit in 2D, and I am using Global Polynomial Interpolation to do it, but I have like 2000 points. I am thinking of using Gaussian elimination to do it, but it is impractical by hand. Does anyone have any suggestions?

Also, does anyone have any suggestions for how to model the shape using other methods?

r/algorithms 7d ago

Help Anyone out there , explain me knapsack problem

Upvotes

I have my DAA exam tomorrow , explain asap , in a easy way😭😭🥹

Q: For the given set of items and knapsack capacity = 10 kg, find the optimal solution for

the 0/1 knapsack problem making use of dynamic programming approach

W=(5,4,6,3) and Profits=(10,40,30,50)

r/algorithms 28d ago

Help [Academic] How does your social media feed affect what feels 'real' to you? (4-5 mins, anonymous)

Upvotes

Hi! I'm an Msc student, researching how algorithmic personalisation on social media shapes perceptions of authenticity and decision-making.

The survey takes 4-5 minutes, is completely anonymous, and includes a short mock Instagram post to react to.

Would really appreciate your help — every response counts! 🙏

https://qualtricsxmt49bm7j6z.qualtrics.com/jfe/form/SV_248ntuA314RvLKK

Thank you!

r/algorithms 17d ago

Help Day of Week Calculation

Upvotes

I'm aware of Hakamoto's method, Zeller's congruence and the like. But (with the help of AI), I've developed a faster way (literally optimised for speed, nothing else). It's such a niche piece of maths tho, but it feels elegant. I then asked Claude to write it up. It did, as a paper, in LaTeX.

Now I don't know what do with this. It's SUCH a niche example. But it is faster.

I presume this should and could also be applied to other examples. What....what are people doing? Do we just contact maths/CS journals with this? Or go 'meh, our AI overlords will take over soon anyway'.

r/algorithms 28d ago

Help sorting problem

Upvotes

background: i work for a company as a maintenance technician and recently took over the operations of our warehouse from someone that left it a wreck.

i have to get rid of old equipment given to the warehouse to dispose of. there is an unknown quantity of equipment. ~enough to fill a warehouse. each piece needs to be tagged with a type of barcoded document with information about it in order to be received by the disposal facility. a portion of these forms have been made but have not been attached. i will need to make and attach the rest of these documents but do not know how many.

how can i most efficiently sort these items? the goal is that i can tell my boss how much time it will take and then fill enough trucks to have all the materials disposed of.

this is actually the bane of my existence and costing my warehouse greatly. i would greatly appreciate, as the problem could make or break the operation.

r/algorithms 14d ago

Help Building a constraint-based 2D layout generator for urban plots with an AI agent loop. Looking for libraries/approaches!

Upvotes

Hi everyone,

I’m working on a PropTech tool that procedurally generates building layouts for real estate feasibility studies, with the goal of maximizing buildable area.

The Workflow:

  1. The user selects a land plot on a map.
  2. They set high-level parameters (e.g., apartment blocks vs. single-family homes, surface vs. underground parking).
  3. The Engine: Generates multiple 2D site plans (placing roads, footprints, and parking lots) that strictly adhere to the geometric constraints (setbacks, footprint limits, alignments).
  4. The user can manually tweak the layout by dragging polygons around.
  5. The Agentic Loop: An integrated LLM/VLM chatbot that allows the user to iteratively adjust the layout via natural language (e.g., "group the buildings closer to the north edge"). The AI needs to "understand" the current 2D layout and update the constraints to regenerate a new compliant layout.

I already have something 'working', but it is, in my opinion, too static and dependent on the test parcel I'm using. The coming issues are the varying sizes and shapes of the parcels, which can have infinite variations. Given that I am constrained to work within a fixed boundary, I can't use approaches such as Voronoi cells or similar methods.

Where I need your insights: Assuming the rules are already parsed into raw constraints, I’m looking for the state of the art to build the final composition engine:

  • Constraint-based 2D Generation: What are the go-to algorithms or libraries (preferably web-friendly) for 2D packing and layout generation under strict geometric rules?
  • Spatial AI / LLM Integration: Are there any papers, open-source projects, or specific approaches for feeding a 2D spatial topology to a model so it can meaningfully tweak procedural generation parameters?
  • Interactive Frameworks: Any recommended engines or existing tools that handle both procedural layout generation and interactive 2D editing smoothly?

I'm highly open to academic literature, specific algorithms, or existing open-source solvers I could draw inspiration from.

Thanks in advance!

r/algorithms 26d ago

Help Built a combinations algorithm to classify data

Upvotes

Does anyone have any advice on where to go from here? The algorithm simply goes through all feature-attribute combinations in a dataset and scores it on purity of the target column. It's very slow, as the number of combinations increases exponentially with the number of input features, and so can only work with 3-4 features at a time. But my goal is to identify <=5 important features with a linear model (statsmodels or PyGam), and then plug in those features to this algorithm to see which subset of the market might be smart to target.

Here's an example with some charts, on the iris dataset.

https://colab.research.google.com/drive/1w3VpDlDATdHwtSk-RmQPMj36cgOfthz1#scrollTo=ZOqeYiMRalj7&uniqifier=1

New to algorithms, so any advice would be welcome. Thanks in advance.