Questions tagged [counting]

The term Counting in Computer Science is usually used to refer to counting objects in certain arrangements or with certain properties.

The term Counting in Computer Science is usually used to refer to counting objects in certain arrangements or with certain properties. Being an abstract concept, we count objects to solve many different types of problems. For example, counting can be used to determine the complexity of algorithms. It is also used to evaluate sufficient telephone number availability or compare the projected range of unassigned Internet protocol addresses to the estimated demand. Counting is also used in mathematical biology, especially DNA sequencing. Furthermore, counting techniques are used extensively when probabilities of events are computed.

205 questions
29
votes
5 answers

Boolean search explained

My mother is taking some online course in order to be a librarian of sorts, in this course they cover boolean searches, so they can search databases efficiently, however, she got a question sounding something like this: The search "x OR y" will…
sch
  • 393
  • 3
  • 5
14
votes
1 answer

Why is the counting variant of a hard decision problem not automatically hard?

It is well-known that 2-SAT is in P. However, it seems quite interesting that counting the number of solutions to a given 2-SAT formula, i.e., #2-SAT is #P-hard. That is, we have an example of a problem for which decision is easy, but counting is…
Gideon
  • 487
  • 2
  • 9
11
votes
2 answers

Does #$P$-Completeness imply approximation hardness?

Let $\Pi$ be some counting problem which is known to be #$P$-Complete. Does it imply that $\Pi$ is $APX$-hard (i.e. no PTAS for the problem exists unless $P=NP$)?
R B
  • 2,644
  • 17
  • 35
11
votes
2 answers

Counting the number of words accepted by an acyclic NFA

Let $M$ be an acyclic NFA. Since $M$ is acyclic, $L(M)$ is finite. Can we compute $|L(M)|$ in polynomial time? If not, can we approximate it? Note that the number of words is not the same as the number of accepting paths in $M$, which is easily…
R B
  • 2,644
  • 17
  • 35
10
votes
3 answers

Finding all solutions to an integer linear programming (ILP) problem

My problem is to find all integer solutions to an ILP. As an example, I'm using an ILP with two variables, but I may have more than two variables. I describe the method I currently use to solve this problem near the end, but I'm interested in…
resyst
  • 101
  • 1
  • 4
9
votes
2 answers

Count of distinct substrings in string inside range

Having string $S$ of length $n$, finding the count of distinct substrings can be done in linear time using LCP array. Instead of asking for unique substrings count in whole string $S$, query $q$ containing indexing $(i,j)$ where $0 \le i \le j < n$…
mechsoul
  • 91
  • 4
9
votes
2 answers

Counting islands in Boolean matrices

Given an $n \times m$ Boolean matrix $\mathrm X$, let $0$ entries represent the sea and $1$ entries represent land. Define an island as vertically or horizontally (but not diagonally) adjacent $1$ entries. The original question was to count the…
pgs
  • 215
  • 2
  • 12
9
votes
1 answer

Applications of model counting

I have been reading about model counting, a.k.a. the #SAT problem. What are the practical applications, if any, of this problem, and how exactly do they reduce to it? I have been unable to find any, though that's simply due to my own ignorance of…
8
votes
1 answer

Algorithm to find all acyclic orientations of a graph

I am working on acyclic orientations of undirected graphs and have the following questions: Given connected undirected simple graph $G$, how to find all possible acyclic orientations of $G$ ? What is the number of acyclic orientations? It is…
seteropere
  • 677
  • 1
  • 4
  • 12
7
votes
1 answer

Does $\#W$[1]-hardness imply approximation hardness?

Let $\Pi$ be a parametrized counting problem, where the parameter is the solution cost, e.g. counting the number of $k$-sized vertex cover in a graph, parametrized by $k$. Assume that $\Pi$ is $\#W$[1]-complete (a known problem for example would be…
7
votes
2 answers

numerical integral vs counting roots

I have a problem that can be viewed in two different ways: Compute an $n$-dimensional integral, numerical context. The domain of integration is an $n$-dimensional hyper-cube of side $L$. Count (just count) the roots of an $n$-dimensional function…
labotsirc
  • 383
  • 2
  • 9
6
votes
4 answers

Sum of unique elements in all sub-arrays of an array

Given an array $A$, sum the number of unique elements for each sub-array of $A$. If $A = \{1, 2, 1, 3\}$ the desired sum is $18$. Subarrays: {1} - 1 unique element {2} - 1 {1} - 1 {3} - 1 {1, 2} - 2 {2, 1} - 2 {1, 3} - 2 {1, 2, 1} - 2 {2, 1, 3} -…
6
votes
1 answer

How to calculate an accurate estimated reading time of text?

I suppose the calculation should not be done by only two factors (average reading speed/words per minute, and word count). But at least by a third parameter, that in my opinion should measure the difficulty of the used vocabulary with some kind of…
6
votes
2 answers

How can we count the number of pairs of coprime integers in an array of integers? (CSES)

For reference, I am trying to solve this CSES Problem. The problem basically states that given up to $10^5$ positive integers in the range $[1, 10^6]$, find the number of pairs of those positive integers that are coprime. After some thought, I've…
5
votes
0 answers

Count Wildcard Parenthesizations of a String

Let $\Sigma = \{ (, ), ? \}$ be an alphabet. For a given string $s \in \Sigma^*$, we denote by $f(s)$ the number of ways to replace each symbol $?$ either with $($ or with $)$ such that $s$ is correctly parenthesized. For example, for $s =…
neutron-byte
  • 389
  • 1
  • 8
1
2 3
13 14