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
31
votes
6 answers

The milk sharing problem

I found a book with math quizzes. It was my father's when he was young. I encountered a problem with the following quiz. I solved it, but I wonder, is there a faster way to do it? If so, how can I compute the time (polynomial time) that is needed to…
Haha
  • 5,476
  • 15
  • 16
31
votes
3 answers

Algorithm to get the maximum size of n squares that fit into a rectangle with a given width and height

I am looking for an algorithm that can return the number of size of n squares that fit into a a rectangle of a given width and height, maximizing the use of space (thus, leaving the least amount of leftover space for squares that do not fit).…
Anton
  • 413
  • 1
  • 4
  • 7
31
votes
1 answer

How can we turn any number into a prime number by simply adding more digits?

How can we turn any number (where the number is > 2) into a prime number by simply appending more digits? I'm referring to the right side of the number. So 4 is not a prime number But If I append 1 or 3 or 7 it can become a prime number 41, 43, 47…
CoffeDeveloper
  • 963
  • 6
  • 16
30
votes
2 answers

Using Limits to Determine Big-O, Big-Omega, and Big-Theta

I am trying to get a concrete answer on using limits to determine if two functions, $f(n)$ and $g(n)$, are Big-$O$, Big-$\Omega$, or Big-$\Theta$. I have looked at my book, my lecture notes, and have even done some online research but I still…
Stephen Clark
  • 301
  • 1
  • 4
  • 3
29
votes
2 answers

A constrained topological sort?

Suppose that one has a directed, acyclic graph G, and each vertex $v$ contains a (positive) value $a_v$. Additionally, let $r$ be a constant. For my purposes, $r>1$, but this might not matter. Let $n$ be the number of vertices in G and let…
Aaron
  • 21,774
  • 2
  • 39
  • 67
29
votes
4 answers

Is there a branch of Mathematics which connects Calculus and Discrete Math / Number Theory?

I am asking this question out of both curiosity and frustration. There are many problems in computer science which require you to perform operations on a finite set of numbers. It always bothers me that there is no way of mapping this discrete…
SilverSlash
  • 1,448
  • 13
  • 21
28
votes
3 answers

How to integrate $ \int \frac{x}{\sqrt{x^4+10x^2-96x-71}}dx$?

I read about $ \int \dfrac{x}{\sqrt{x^4+10x^2-96x-71}}dx$ on the Wikipedia Risch algorithm page. They gave an answer but I don't understand how they got it.
Hashir Omer
  • 1,648
  • 1
  • 15
  • 27
28
votes
5 answers

Are some real numbers "uncomputable"?

Is there an algorithm to calculate any real number. I mean given $a \in \mathbb{R}$ is there an algorithm to calculate $a$ at any degree of accuracy ? I read somewhere (I cannot find the paper) that the answer is no, because $\mathbb{R}$ is not a…
Ricky Bobby
  • 713
  • 8
  • 15
28
votes
5 answers

Split $n$ into nontrivial factors via a nontrivial square-root of $1\!\pmod{\!n}$

Coming from an understanding of Fermat's primality test, I'm looking for a clear explanation of the Miller-Rabin primality test. Specifically: I understand that for some reason, having non-trivial square roots of 1 mod p means that p is definitely…
Smashery
  • 455
  • 1
  • 5
  • 8
28
votes
5 answers

Find taxicab numbers in $O(n)$ time

This is a final exam question in my algorithms class: $k$ is a taxicab number if $k = a^3+b^3=c^3+d^3$, and $a,b,c,d$ are distinct positive integers. Find all taxicab numbers $k$ such that $a,b,c,d < n$ in $O(n)$ time. I don't know if the problem…
Chao Xu
  • 5,528
  • 3
  • 33
  • 47
28
votes
2 answers

When does a Square Matrix have an LU Decomposition?

When can we split a square matrix (rows = columns) into it’s LU decomposition? The LUP (LU Decomposition with pivoting) always exists; however, a true LU decomposition does not always exist. How do we tell if it does/doesn't exist? (Note:…
Highrule
  • 381
  • 1
  • 3
  • 5
28
votes
3 answers

Height of all skyscraper

There is a bunch of skyscapers, each have a height, which is a positive integer. You are given at the start the total sum of their height. Now everyday you can make one measurement, which will tell you how many skyscapers there are which have height…
nescio
  • 281
  • 2
  • 3
27
votes
2 answers

Concrete FFT polynomial multiplication example

I have read a number of explanations of the steps involved in multiplying two polynomials using fast fourier transform and am not quite getting it in practice. I was wondering if I could get some help with a concrete example such as: $$ p(x) = a_0 +…
alh
  • 441
  • 1
  • 4
  • 7
27
votes
1 answer

Can algebraic numbers be compared using only rational arithmetic?

I was working on a program to carry out some computations, and ran into an issue of needing to compare some algebraic numbers, but not having enough precision to do it without exact arithmetic, and not knowing how to do it with exact arithmetic. A…
Milo Brandt
  • 58,703
  • 5
  • 98
  • 184
27
votes
4 answers

Each person has at most 3 enemies in a group. Show that we can separate them into two groups where a person will have at most one enemy in the group.

The question that I saw is as follows: In the Parliament of Sikinia, each member has at most three enemies. Prove that the house can be separated into two houses, so that each member has at most one enemy in his own house. I built a graph where…