Backtracking Algorithms for Combinatorial Generation
Generating the complete power set of a collection involves binary decisions at each element. The recursive approach branches twice: once including the current element and once excluding it.
public void enumerateSubsets(int[] data, List<Integer> buffer, int idx) {
if (idx == data.length) {
System.out.println(buffer);
re ...
Posted on Fri, 14 Aug 2026 16:51:09 +0000 by TheHyipSite
Generating Permutations and Combinations Using Depth-First Search
Permutations This article demonstrates a method for generating all permutations of a set of numbers using depth-first search (DFS).
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX_SIZE = 100010;
int size, sequence[MAX_SIZE];
bool visited[MAX_SIZE];
void generatePermutations(int ...
Posted on Tue, 04 Aug 2026 17:03:36 +0000 by nominator
Mastering Backtracking: Generating Increasing Subsequences and Permutations
This article delves into advanced backtracking techniques for solving common algorithmic problems, specifically focusing on generating increasing subsequences and permutations, including handling duplicates.
Generating Increasing Subsequences (Problem 491)
Given an integer array, the task is to find all increasing subsequences with a length of ...
Posted on Tue, 14 Jul 2026 17:10:59 +0000 by Dominator69
Unbounded Knapsack Dynamic Programming: Combinations vs Permutations
Unbounded Knapsack ProblemIn the classic 0/1 Knapsack problem, each item can be selected at most once. The Unbounded Knapsack problem modifies this constraint: each item can be chosen an unlimited number of times. Consider a knapsack with a maximum capacity of 4, and the following items:ItemWeightValueA115B320C430The core difference in implemen ...
Posted on Sun, 17 May 2026 17:18:17 +0000 by bbristow
Determining Feasibility of Safe Aircraft Landing Sequence with Single Runway
Problem Description
N aircraft are preparing to land at an airport with only one runway. The i-th aircraft arrives above the airport at time Ti and has enough remaining fuel to continue circling for Di units of time. This means it can begin landing at the earleist at time Ti, and at the latest at time Ti + Di. The landing process itself require ...
Posted on Sun, 17 May 2026 06:05:57 +0000 by inkfish