Questions tagged [algorithms]

Mathematical questions about Algorithms, including the analysis of algorithms, combinatorial algorithms, proofs of correctness, invariants, and semantic analyses. See also (computational-mathematics) and (computational-complexity).

An algorithm is an unambiguous specification of how to solve a class of problems. The study of algorithms is the branch of mathematics that specializes in finding efficient (mostly in the terms of time and space complexity) for various computational problems. It often involves combinatorics, number theory and geometry.

The field also includes data structures, computational models and proofs of lower bounds for certain algorithms.

See also and .

10691 questions
114
votes
5 answers

A multiplication algorithm found in a book by Paul Erdős: how does it work?

I am trying to understand the following problem from Erdős and Surányi's Topics in the theory of numbers (Springer), chapter 1 ("Divisibility, the Fundamental Theorem of Number Theory"): We can multiply two (positive integer) numbers together in…
iadvd
  • 8,645
  • 11
  • 31
  • 68
95
votes
3 answers

Complexity class of comparison of power towers

Consider the following decision problem: given two lists of positive integers $a_1, a_2, \dots, a_n$ and $b_1, b_2, \dots, b_m$ the task is to decide if $a_1^{a_2^{\cdot^{\cdot^{\cdot^{a_n}}}}} < b_1^{b_2^{\cdot^{\cdot^{\cdot^{b_m}}}}}$. Is this…
85
votes
5 answers

How to use the Extended Euclidean Algorithm manually?

I've only found a recursive algorithm of the extended Euclidean algorithm. I'd like to know how to use it by hand. Any idea?
81
votes
3 answers

Fastest way to check if $x^y > y^x$?

What is the fastest way to check if $x^y > y^x$ if I were writing a computer program to do that? The issue is that $x$ and $y$ can be very large.
learner
  • 857
  • 2
  • 8
  • 10
78
votes
3 answers

What algorithm is used by computers to calculate logarithms?

I would like to know how logarithms are calculated by computers. The GNU C library, for example, uses a call to the fyl2x() assembler instruction, which means that logarithms are calculated directly from the hardware. So the question is: what…
zar
  • 4,158
  • 4
  • 26
  • 42
73
votes
8 answers

incremental computation of standard deviation

How can I compute the standard deviation in an incremental way (using the new value and the last computed mean and/or std deviation) ? for the non incremental way, I just do something…
71
votes
4 answers

Why does multiplying a number on a clock face by 10 and then halving, give the minutes? ${}{}$

My daughter in grade 3 is learning about telling time at her school. She eagerly showed me this method she has discovered on her own to tell the minutes part of the time on an analogue clock. I wasn't sure at first because I have never heard about…
Sabeen Malik
  • 665
  • 1
  • 5
  • 7
69
votes
3 answers

Explanation on arg min

Would someone be so kind to explain this to me: $$\pi_nk=\left\{\begin{array}{cl}1&\textrm{if }k=\arg\min_j\left\Vert\mathbf x_n-\mu_j\right\Vert^2\\0&\textrm{otherwise}\end{array}\right..$$ Especially the $\arg\min$ part. (It's from the $k$-means…
Olivier_s_j
  • 855
  • 2
  • 8
  • 8
55
votes
2 answers

How do the Catalan numbers turn up here?

The Catalan numbers have a reputation for turning up everywhere, but the occurrence described below, in the analysis of an (incorrect) algorithm, is still mysterious to me, and I'm curious to find an explanation. For situations where a…
ShreevatsaR
  • 39,794
  • 7
  • 90
  • 125
51
votes
5 answers

Are there dictionaries in math?

Consider the following dictionary in the programming language Python: D = {'A': 1, 'B': 2, 'C': 3} It is saying that the value of A is 1, the value of B is 2, and the value of C is 3. It also has the property that D['A'] = 1 etc. How would I write…
user356363
  • 529
  • 4
  • 5
49
votes
6 answers

Finding the largest equilateral triangle inside a given triangle

My wife came up with the following problem while we were making some decorations for our baby: given a triangle, what is the largest equilateral triangle that can be inscribed in it? (In other words: given a triangular piece of cardboard, what is…
ShreevatsaR
  • 39,794
  • 7
  • 90
  • 125
47
votes
2 answers

A natural number multiplied by some integer results in a number with only ones and zeros

I recently solved a problem, which says that, A positive integer can be multiplied with another integer resulting in a positive integer that is composed only of one and zero as digits. How can I prove that this is true(currently I assume that it…
47
votes
1 answer

Sums of prime powers

You are given positive integers N, m, and k. Is there a way to check if $$\sum_{\stackrel{p\le N}{p\text{ prime}}}p^k\equiv0\pmod m$$ faster than computing the (modular) sum? For concreteness, you can assume $e^k
Charles
  • 30,888
  • 4
  • 58
  • 139
45
votes
7 answers

How does one compute the sign of a permutation?

The sign of a permutation $\sigma\in \mathfrak{S}_n$, written ${\rm sgn}(\sigma)$, is defined to be +1 if the permutation is even and -1 if it is odd, and is given by the formula $${\rm sgn}(\sigma) = (-1)^m$$ where $m$ is the number of…
Chris Taylor
  • 27,485
  • 5
  • 79
  • 121
45
votes
22 answers

What does Big O actually tell you?

Two days ago I felt very uncomfortable with Big O notation. I've already asked two questions: Why to calculate "Big O" if we can just calculate number of steps? The main idea behind Big O notation And now almost everything has become clear. But…
1
2 3
99 100