Skip to main content

Questions tagged [algorithms]

An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem. Use this tag when your issue is related to design and analysis of algorithms.

Filter by
Sorted by
Tagged with
2 votes
1 answer
80 views

I am failing to find the flaw in logic to a “partial” solution to the two generals problem and would appreciate help seeing where I went wrong (knowing it’s unsolvable) There are two generals A and B, ...
Colin Hicks's user avatar
0 votes
0 answers
33 views

I’m interested in knowing how the complexity of outputs relates to the programs that generate them. For example, in cellular automata like Conway’s Game of Life (a grid-based system where simple rules ...
Syed's user avatar
  • 213
-2 votes
1 answer
53 views

I'm trying to solve the following Leetcode problem: https://leetcode.com/problems/path-sum-ii/description/ This solution I came up with is working: https://pastebin.com/ma3DtU5b However, I was not ...
Platus's user avatar
  • 97
0 votes
1 answer
44 views

One of the problems that has Pseudo-polynomial time algorithm is $0/1$ Knapsack problem. The $0/1$ Knapsack problem is a follow. Given a set of $n$ elements with weights and prices, and a positive ...
Rma's user avatar
  • 163
1 vote
0 answers
28 views

I would like to solve the equation $Ax=b$ where $A$ is an $N\times N$ "cyclic" banded matrix (there might be a better term, but I wasn't able to find it), i.e. a matrix that look like $$\...
FusRoDah's user avatar
  • 111
2 votes
0 answers
53 views

I have a long array of size $n>10^6$, call it $X$. I would like to find all ranges $[a, b)$ satisfying the following conditions $\sum_{i=a}^{b-1}X[i] \leq 0$, $b-a \geq K$, $\sum_{i=a-1}^{b-1} X[i]...
cebir latis's user avatar
1 vote
0 answers
46 views

The degree of an $n$-variate polynomial is defined as the maximum degree of the monomials that composes it. Now, given a polynomial $P$ (or rather, a list of monomials, since the coefficients don't ...
Tristan Nemoz's user avatar
0 votes
1 answer
52 views

Let's say we have a term (eg an integer, but interested in symbolic polynomial as well) $t$ that can be factored as $t=p^k \cdot m$. Note: $p$ need not be necessarily prime or otherwise irreducible ...
Nikos M.'s user avatar
  • 1,038
0 votes
1 answer
44 views

Background The algorithm to calculate the n-th Fibonacci number using recursion is as follows: ...
Jianxun Zhou's user avatar
1 vote
0 answers
57 views

I'm getting stuck at choosing a fast polynomial multiplication algorithm for the last step of the AKS primality test: ...
minh quý lê's user avatar
-2 votes
0 answers
27 views

I have this request: "Design an algorithm that sums all node values within a tree and compares the result to a target value. If the sum is equal to the target, return 1; otherwise, return 0."...
Gabriele's user avatar
1 vote
0 answers
62 views

I have been trying to solve the following problem from ericksons algorithms: 20)c) Let P be a set of n points evenly distributed on the unit circle, and let S be a set of m line segments with ...
finder's user avatar
  • 11
5 votes
2 answers
161 views

First of all, I do know that it is not known whether or not $\overline{SAT}$ is in NP. But to me, it clearly looks like it is in NP. Given a Boolean formula φ with n variables, we nondeterministically ...
Aland Ameer's user avatar
-1 votes
1 answer
42 views

$$T(n) = T\big(\frac{ n}{2}\big) + \Theta(1)$$ Hi, I'm resolving this recurrence relation through Master Theorem. I would like to know my solution is correct. $\alpha = 1$ $\beta =2$, $f(n) = \Theta(...
Gabriele's user avatar
0 votes
1 answer
115 views

To compute the $n$th Fibonacci number, a recursive algorithm is as follows: ...
Rma's user avatar
  • 163
0 votes
1 answer
43 views

You are a dog trainer tasked with training two dogs, Peter and Markley, for train1 days and train2 days, respectively. You can ...
Erebius's user avatar
  • 11
1 vote
1 answer
22 views

I am trying to implement the Optimal In-Place Suffix Sorting algorithm (Section 5.5 of “Optimal In-Place Suffix Sorting” by Bingmann, Fischer, and Kurpicz, 2019), specifically the read-only general ...
Fabrizio Apuzzo's user avatar
1 vote
0 answers
23 views

I have a $k-$uniform hypergraph $H=(V,E)$ with $n$ vertices. I need to partition $H$ into two partitions of sizes $r$ and $n-r$. Is there an approximating algorithm that can do this while minimizing ...
slhulk's user avatar
  • 111
2 votes
1 answer
130 views

I want to study advance topics of algorithms such as backtracking and branch and bound algorithms. I tried to find out the content in following books Dasgupta, S., Papadimitriou, C. H., & ...
Rma's user avatar
  • 163
1 vote
1 answer
31 views

I am reading a paper in which it says: ... adhering to the most resricive memory regime, in which the local memory per machine is strongly sublinear in the number of vertices and the total memory is ...
Shahryar Saljoughi's user avatar
0 votes
0 answers
23 views

I understand the basic division hash function h(k)=k mod m, and the use of this function but I don’t understand why the universal hash function introduces the parameters a and b and uses a prime ...
user31227868's user avatar
0 votes
0 answers
37 views

I'm exploring data structures suitable for persistent applications. A key use case I have is splitting a subsegment from a tree, copying it, and then merging these copies into other data structures. ​...
吴松原's user avatar
0 votes
0 answers
19 views

I am trying to implement the algorithm to find the largest triangle in a convex polygon as described in section 6.1 at the end of ...
Mathias Sven's user avatar
4 votes
1 answer
105 views

I would like to find all the maximal rectangles contained in a rectilinear shape on a discrete grid. That is, every rectangle such that, if it were to grow by one cell in any direction, it would no ...
some guy's user avatar
1 vote
1 answer
66 views

So I understand that O is an upper bound and omega is a lower bound. I also understand that case is different than bounds, i.e worst case can have O/Theta/Omega different from best case. My question: ...
user1497350's user avatar
0 votes
1 answer
82 views

Given a list of $n$ jobs to be executed on $m$ identical machines, the load balancing problem is to distribute the $n$ jobs over the $m$ machines, such that the makespan is minimised. The makespan is ...
dkm's user avatar
  • 71
3 votes
1 answer
129 views

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 ...
pew's user avatar
  • 33
0 votes
0 answers
29 views

Suppose you have elements (a,b,c,d), and you want to use bubble sort to sort them(either ascending or descending,doesnt really matter), but you can only use a single memory stack (with infinite ...
Root Groves's user avatar
1 vote
1 answer
109 views

I'm working on proving a greedy solution to the problem in Codeforces 205B, which states: Given an array of integers a of length ...
adult_learner's user avatar
1 vote
2 answers
90 views

I’m working on an algorithm for graph coloring, and I want to test how close its results are to the actual chromatic number. For this, I’m looking for graphs whose chromatic numbers are already known. ...
Gadget's user avatar
  • 47
1 vote
0 answers
22 views

In the paper "Optimal Speedup of Las Vegas Algorithms" Luby, M., Sinclair, A. and Zuckerman, D. give an asymptotically optimal sequences for how many time to run an Las Vegas algorithm ...
worldsmithhelper's user avatar
2 votes
1 answer
51 views

Given segment $\left[L, R\right]$ check if there is an inversion in the segment. If $a_i > a_j$ and $j> i$ then it is an inversion. Can this done faster than a linear check given that we can ...
Itoshi Sae's user avatar
0 votes
0 answers
118 views

A lexicographical swap is defined as: At each step, pick the earliest possible inversion (i, j) (smallest i, then smallest j > i with a[i] > a[j]) and swap them.Repeat until the array is sorted. ...
ISG's user avatar
  • 11
1 vote
2 answers
473 views

I started thinking about this problem while trying to find the best way to divide a book reading into $4$ roughly equal sections. I ended up brute-forcing every possible combination, but now I'm ...
Jacob Hungerford's user avatar
8 votes
1 answer
1k views

Yamada-kun can switch bodies with anyone he kisses. So first he kisses A, and switches into their body. Then, as A, he kisses B and switches into their body (and now B is in A's body). Then, as B, he ...
chausies's user avatar
  • 652
1 vote
0 answers
82 views

Suppose you have an array $a$ of $n$ elements in an set $X$, and a associative binary operation $\circ \ \colon X \times X \rightarrow X$, that can be evaluated in constant time, but is costly (e.g. $...
Fam's user avatar
  • 13
0 votes
1 answer
92 views

It is already known that you can use two BITs (aka Fenwick Trees) to do RMQ in $O(logn)$ and point update in amortized $O(logn)$ time (Described in this paper.) However, I want a step further, doing ...
Fam's user avatar
  • 13
3 votes
1 answer
101 views

I have an undirected, unweighted graph with N vertices. I want to find a 2D embedding of the vertices on a k × n grid (where <...
Tom's user avatar
  • 31
0 votes
0 answers
51 views

I am hashing a bunch of strings made up of a finite number of known keyword strings (n many keyword strings). Here I want to generate a perfect hash s.t. each ...
yosmo78's user avatar
  • 187
1 vote
0 answers
41 views

Context Dijkstra’s algorithm with a comparison-based heap runs in Θ(m + n log n) time on a directed graph with non-negative real edge weights. The freshest bound I’m aware of for real weights is <...
Lukas's user avatar
  • 21
1 vote
1 answer
160 views

How fast can cyclic shift of size $n$ be implemented? Lets say the input is a string of length $n+ \log_2 n$ where the last $\log_2 n$ tell the function how much to shift the first n digits. I know ...
Hao S's user avatar
  • 155
1 vote
1 answer
167 views

Given an array of unique elements of size $n$, the goal is to find the second maximum element using tournament tree method. The model of computation is RAM model. Algorithm: The idea to pair the ...
Rma's user avatar
  • 163
1 vote
1 answer
129 views

Consider the following problem: Let $G=(V, E)$ be a weighted undirected graph with nonnegative weights. Let $S_1, S_2, \ldots, S_k\subseteq V$ be disjoint subsets representing vertices where you can ...
A R's user avatar
  • 63
0 votes
0 answers
56 views

I'm looking at translations to and from APL, which has right-to-left evaluation and no operator precedence. Is there a known algorithm to minimize parentheses usage when keeping the same operators for ...
Gabi's user avatar
  • 123
0 votes
0 answers
161 views

this is the problem statement (3-Partition Problem): Partition a set of integers into three subsets with equal sums. Input: a sequence of integers $v_1, v_2, ..., v_n$ Output: check if it is possible ...
DanxAG's user avatar
  • 1
1 vote
0 answers
32 views

Given a simple unlabeled graph $G = (V,E)$ with vertices $V=\{1,\ldots,n\}$, let $L(G)$ a labeled graph obtained by labeling (with distinct labels) the vertices of $G$ through any $l: V \rightarrow V$ ...
Fabius Wiesner's user avatar
1 vote
0 answers
47 views

This specific convergence rate with dominant logarithmic factors is indeed highly desirable for large-scale systems. While there's a rich body of work on stochastic approximation and equilibrium ...
netanel shteren's user avatar
0 votes
1 answer
127 views

I'm trying to solve the following graph problem and am struggling to meet the required time complexity. The Problem: Given an unweighted, connected, undirected graph G=(V, E) and a source vertex s in ...
Johann Carl Friedrich Gauß's user avatar
0 votes
0 answers
36 views

This is an algorithmic challenge from the factory game Shapez2, essential for building what's known as a TMAM (True Make Anything Machine). I’ve been researching this problem over the past month. ...
rone D's user avatar
  • 1
1 vote
0 answers
66 views

I'm working on a problem where I have an array arr of size n, and I need to collect the maximum number of coins by jumping ...
netanel shteren's user avatar

1
2 3 4 5
236