Skip to main content

Questions tagged [algorithm-analysis]

Questions about the science and art of determining properties of algorithms, often including correctness, runtime and space usage. Use the [runtime-analysis] tag for questions about the runtime of algorithms.

Filter by
Sorted by
Tagged with
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
94 views

I understand the definitions of Big-O (upper bound), Big-Ω (lower bound), and Big-Θ (tight bound), particularly when it comes to its use to finding the complexity of given growth function such as f(n) ...
bilal's user avatar
  • 3
3 votes
1 answer
152 views

I was playing around with $k$-ary searches, and found something interesting: This is the $\log(\frac{\text{time}}{\text{binary time}})$ to find an element in an array of length $100$ averaged over ...
DatBoi's user avatar
  • 81
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
0 votes
1 answer
64 views

Reversing the post-order traversal (DFS) of a directed acyclic graph (DAG) results in a valid topological sort. However, if we first reverse the graph (where every directed edge from ( u ) to ( v ) ...
user173729's user avatar
2 votes
1 answer
72 views

This is how I understand Prim's algorithm: Initialization: When Prim's algorithm starts, it initializes the priority queue with all vertices, setting their keys (distances) to infinity, except for the ...
user173729's user avatar
4 votes
0 answers
75 views

Given a list of characters in $\{a,b\}$, for example $abababababa$, what is the most efficient way to remove all 5th powers in a way that makes the string as short as possible? (This example would ...
Learner of math's user avatar
1 vote
1 answer
64 views

I'm watching CS50AI's week 3 video, particularly the part describing the AC-3 algorithm, which starts at around 1h 10m. I'll paraphrase the algorithm ...
James's user avatar
  • 111
1 vote
2 answers
170 views

Let us say that $\text{Bool}$ is the set of possible boolean values; that is, $\text{Bool}=\{\text{True}, \text{False}\}$. Assume we have two functions $f$ and $g$ that are both $\text{Bool}^n\...
Heisenberg2010's user avatar
1 vote
0 answers
40 views

This question refers to Peterson’s improved election algorithm for unidirectional ring: ...
algorithm-cracker's user avatar
1 vote
2 answers
154 views

I know how to prove for $O(n\log n)$, but I'm hitting a roadblock with this one. Here's what I've tried: The hypothesis is that there exists some $c > 0$ so that $T(n) \geq cn \log n $, by assuming ...
jojusuar's user avatar
0 votes
1 answer
93 views

I'm currently working on a project that partially involves graphs. One of the problems I'm tackling is determining whether two given matrices represent the same graph. So given two different adjacency ...
Gadget's user avatar
  • 47
2 votes
1 answer
164 views

I followed this helpful blog "Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby, ...)" by Russ Cox. This link is got from Russ Cox, ...
An5Drama's user avatar
  • 233
3 votes
1 answer
121 views

Suppose there are $n$ players $N = \{p_1, \cdots, p_n\}$ and a set $M$ of $m \geq n$ items that are to be claimed. Suppose further that players have strict, additive, ordinal rankings $\succ_{p_j}$ ...
cstheorist's user avatar
2 votes
0 answers
53 views

In the knapsack problem, we consider numbers ∈ Z+ which gives us a run time of $O(nW)$. To my understanding, this is pseudo-polynomial and the worse case runtime is $O(n*2^{log(w)})$ My question is, ...
user491234's user avatar
-3 votes
1 answer
94 views

I gave this prompt to ChatGPT o3-mini-high: Give me a novel algorithm not discovered yet that reduces the complexity of matrix multiplication. Do you think this algorithm is correct and truly novel? ...
MP123's user avatar
  • 9
1 vote
1 answer
77 views

Let $v = (a_1, a_2, …, a_k)$ be a vector of length $k$, such that $0 \leq a_i < n$. Also let $|v| = a_1 + a_2 + \dots + a_k$ be a total degree of $v$. There is finite number of such vectors. We can ...
user2078693's user avatar
2 votes
1 answer
113 views

This's exercise $7$ of chp $11$ from the popular book algorithm design by Jon and Eva. It's about designing a $2$-approximation algorithm for a problem similar to Load balancing on parallel machine. ...
C.C.'s user avatar
  • 225
2 votes
1 answer
122 views

Assuming a model of like multitape TM, (meaning do not assume O(1) time for operations or anything). Informally, what is the best known algorithm worstcase-wise (as a function of the input) for ...
John Kall's user avatar
  • 123
1 vote
0 answers
47 views

I am trying to estimate the theoretical time complexity of the Local Search algorithm presented in the paper "Virtual Resource Allocation for Mobile Edge Computing: A Hypergraph Matching Approach&...
Katrina Vodov's user avatar
0 votes
1 answer
74 views

I'm a bit stuck with this problem? So far all I could do is write out and expand $n!$ as well as $n^n$. Move both to the same side and see that $n^n$ gives a limit (as n goes towards infinity) that ...
Joseph Carvalho's user avatar
2 votes
1 answer
73 views

I would like some help with proving the correctness of the following algorithm that solves LeetCode problem 84 of finding the largest rectangle enclosed by the bars of a histogram. For simplicity, we ...
user1446642's user avatar
0 votes
1 answer
120 views

I have this piece of code and I have to find the recurrence relation in function of n. The problem states that the algorithm is initially called with ALGO(A, 1, n). A is an array of size n. The ...
pepper's user avatar
  • 11
0 votes
1 answer
159 views

Pell equation : x^2 - ny^2 = 1 Solving it with continuous fractions is well known, such as following code: ...
shen lixing's user avatar
-1 votes
4 answers
267 views

What is the specific space complexity of the Merge Sort algorithm, as partially implemented below? ...
Amir's user avatar
  • 13
1 vote
1 answer
101 views

Not long ago I requested an algorithm that can find the word minimizing the sum of squared Hamming distance of all words in a data set. The answer to this question is that the minimization problem is ...
cgmil's user avatar
  • 143
0 votes
0 answers
96 views

I came across this interesting theoretical CS problem regarding max-flow networks in Algorithm Design (Kleinberg Tardos 2005): The Forward-Edge-Only algorithm, which finds $s-t$ paths using only ...
Aike's user avatar
  • 1
0 votes
0 answers
64 views

I have a simple question of how would you measure the logicality of a programming language? EDIT: I was asked to specify the term "logicality". Hence I will try and provide a stipulation. By ...
Shawn W.'s user avatar
0 votes
1 answer
111 views

I am totally new in this area. Lets say we have a list of random numbers and we have to find one peak value (only one is fine), and a peak is if $a \geq$ than its both neighbours (or one if it is in ...
User198's user avatar
  • 103
0 votes
1 answer
79 views

The following is a Leetcode problem: 473. Matchsticks to Square (https://leetcode.com/problems/matchsticks-to-square/description/) Problem Statement You have an array, matchsticks, of size n, with ...
monre's user avatar
  • 1
3 votes
1 answer
233 views

I've been reading Brent's original paper and struggling with his worst-case bounds derivation. (I won't even bother with the expected behavior analysis.) I get the Floyd's algorithm analysis as that's ...
qwr's user avatar
  • 630
0 votes
1 answer
69 views

I would like help understanding this slide from my class, especially the inner loop part. I do not understand how he is getting at n - (n - 1 - 1) = 2 I do understand that when j = n - 1 we get n - (n ...
user avatar
3 votes
1 answer
147 views

I have two algorithms $P, Q$ for solving the same problem (a decision problem on sequences in $R^n$) and I want to decide if they differ in any meaningful way. The following describes the constraints: ...
NotAGroupTheorist's user avatar
3 votes
1 answer
228 views

I participated in an algorithms contest recently, and couldn't find an answer to this problem. The contest is over now, and am looking to see if someone might know how to solve this. Question: "...
Minko_Minkov's user avatar
3 votes
3 answers
521 views

I have been solving the problem of two sum with a sorted array, which can described as follows: Given a sorted array arr sorted in non-decreasing order and a ...
Arnav Borborah's user avatar
2 votes
1 answer
122 views

The circular route gas station problem asks: If given a car with an unlimited gas tank, find the gas station on a circular road that if started from would allow you to travel station to station ...
user171958's user avatar
1 vote
2 answers
99 views

My algorithms textbook defines $T(n)$ as "the number of computer steps needed to compute fib1(n)" (where fib1(n) ...
Princess Mia's user avatar
0 votes
1 answer
53 views

In an algorithm, given a natural number $n$, i have to calculate all integer entries of a function $f_n:R_n\to\mathbb{R}$ within an interval $R_n=[a,b]$ in the real line. Clearly, this amounts to ...
Simón Flavio Ibañez's user avatar
0 votes
0 answers
132 views

Consider a sorted list of $n$ elements $x_1, \ldots, x_n$. Using binary search to find $x_k$ in this list takes $f(n, k)$ iterations, where $f : \mathbb{N}^2 \to \mathbb{N}$ is a function such that, ...
Electro's user avatar
  • 103
0 votes
2 answers
1k views

I've been struggling with counting primitive operations. I know that you do not have to outline every operation that happens in your pseudocode but this is never the less a bit complicated for me. ...
lennuuu's user avatar
1 vote
1 answer
99 views

We will see in Chapter 1 that the addition of two n-bit numbers takes time roughly proportional to n; this is not too hard to understand if you think back to the gradeschool procedure for addition, ...
Bob Marley's user avatar
0 votes
1 answer
59 views

I propose by doing a base-n expansion of the numbers, we have that since there are $n^{3}$ values and $n$ digits in this expansion, there are a total of $\log_{n} n^{3} = 3$ digits. Note in this base-...
cdknight's user avatar
  • 103
0 votes
1 answer
60 views

Consider an algorithm that takes the input a finite set $X$ and an integer partition $\sum_{i=1}^k n_i=|X|$ and gives output all the set partitions $\left(S_1,\ldots, S_k\right)$ of $S$ satisfying $|...
rr314's user avatar
  • 101
0 votes
1 answer
113 views

It's obvious that we cannot find min (or max) in an array of length n in strictly less than n "steps". It's also well-...
e.gryaznov's user avatar
0 votes
1 answer
60 views

Shouldn't we actually continue with C after A, thought a depth search, follows the LIFO principle, isn't C the last node added in this case and shouldn't we expand C before B?
test's user avatar
  • 1
-2 votes
1 answer
68 views

I need help with this question. If it’s possible to do this without limits, please show. Thanks. Q: If f(n) is Ω(n) and g(n) is O(n), then prove or disprove the following statement: f(n) is O(n)
anaya's user avatar
  • 1
7 votes
1 answer
652 views

In Skiena's book Algorithm Design Manual, 3rd Edition, it is claimed on page 45 that $$ mn - m^2 + m \in \Omega(mn) $$ where $m,n \geq 0$ and $m \leq n$. I claim that this is in fact false, with the ...
Joshua's user avatar
  • 173
2 votes
0 answers
161 views

Given a set $Z$ of $n$ points $(p_1,p_2,p_3, \ldots,p_n)$. The coordinates of these points are arbitrary numbers and are unsorted. If they give me $s$ and $t$ to be two points in $Z$. A northeast path ...
coding's user avatar
  • 121
1 vote
1 answer
248 views

I was thinking about quicksort with multiple pivots and I came across this question. How can we efficiently implement a version of Quicksort where we choose $k−1$ pivots to partition an array of ...
Haaziq Jamal's user avatar

1
2 3 4 5
42