Questions tagged [computer-science-theory]

Theoretical computer science (TCS) is a division or subset of general computer science and mathematics which focuses on more abstract or mathematical aspects of computing and includes the theory of computation.

87 questions
13
votes
2 answers

Solve: T(n) = T(n/2) + n/2 + 1

I struggle to define the running time for the following algorithm in O notation. My first guess was O(n), but the gap between the iterations and the number I apply isn't steady. How have I incorrectly defined this? public int function (int n ) { …
9
votes
7 answers

What is missing for this P != NP proof?

I tried to recover a password. When thinking of this I recognized that the problem "password recovery" is a very nice example of a NP problem. If you know the password it's very easy to verify it in polynomial time. BUT if you don't know the…
gruenewa
  • 1,666
  • 11
  • 16
7
votes
1 answer

What class of language can Perl regular expressions be used against?

I know that some of the capabilities of the Perl regular expression engine are not regular. However, what class is it? It might be context-free, but CS theory was never my strongest subject.
Thomas Owens
  • 114,398
  • 98
  • 311
  • 431
4
votes
3 answers

Big O estimation of Math.random()?

Is it possible to obtain a Big O estimate of Math.random()?
Corey Farwell
  • 1,856
  • 3
  • 14
  • 19
4
votes
1 answer

Designing a DFA (alphabet 'a' and 'b') : The number of 'a' in the string must be a multiple of 3, and the string does not contain 'aba'

Here is the problem: And here is my line of reasoning when I first came upon it: This one seems difficult Finding a regular expression for it seems tricky, so i cannot follow this path to convert the regular expression to a DFA So I decided to…
4
votes
2 answers

Which Law of Computer Science is: "Information cannot exist apart from its carrier"?

After reading the page "Laws of Computer Science and Programming" and not finding this law, can anyone tell me what this law is? The point of the law is that the carrier IS the information. In other words, you cannot divide the information on a HDD…
John Held
  • 41
  • 1
4
votes
3 answers

LISP 1.5 How lisp is like a machine language?

I wish that John McCarthy was still alive, but... From LISP 1.5 Programmer's Manual : LISP can interpret and execute programs written in the form of S- expressions. Thus, like machine language, and unlike most other higher level languages, it…
3
votes
2 answers

Data structure with quick insert and search

I have a problem I'd like to code. I have a process which generates numbers 0 through n-1 and I want to stop it when it generates the first repeated element.* I'm looking for a data structure that makes this fast. In particular, adding a new element…
Charles
  • 11,269
  • 13
  • 67
  • 105
2
votes
0 answers

How to find the ith number that has n factors, considering that n isn't prime?

The brute force approach would be checking every possible number. If it has n factors: x++. until: x = i. but I just learned that you could get i = 1 that has n factors by: Getting the set S of prime factors e of n. Arrange set S in descending…
2
votes
1 answer

Subtle nuances of Big O notation for computation complexity

I was just working on a LeetCode problem, Roman to Integer, the conversion of Roman numerals to integers, and after finishing up and comparing solutions, I noticed a rather interesting nuance in how the solutions listed describe their computational…
TheEnvironmentalist
  • 2,694
  • 2
  • 19
  • 46
2
votes
1 answer

Determining whether a nondeterministic finite automaton accepts every possible string

Given an NFA, is there a way to determine whether it accepts all strings constructed from its alphabet, without having to iterate over the infinite set of possible strings?
2
votes
1 answer

System of congruences with non-pairwise coprime moduli

I have a set of congruences x = a1 (mod n) ... x = ak (mod nk) And I want to find x, this can be solved by the Chinese remainder theorem and related algorithms: https://en.wikipedia.org/wiki/Chinese_remainder_theorem Some examples:…
2
votes
2 answers

Average number of swaps performed in Bubble Sort

I came across this problem right now: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=3155 The problems asks to calculate the average number of swaps performed by a Bubble Sort algorithm…
2
votes
5 answers

Online resources for Introduction to computer and computer sciences for absolute beginner

In our office, we have an office boy(completed high school(10+2 years)) with average academic record so far). He wants to learn programming. I have started coaching him in Computer Science basics (history of computer science, number systems, etc.),…
Mir Nazim
  • 636
  • 1
  • 8
  • 20
2
votes
1 answer

Number of elements that satisfy a relation

Given two arrays: 2 5 6 4 3 7 1 5 1 6 2 3 7 4 count the number elements x, y that satisfy the condition that x is before y in both arrays. Progress so far: Sort the arrays by their indexes. For the example this would be: …
1
2 3 4 5 6