instruction
stringlengths
0
29.8k
⌀
In the absence of a direct answer, here are some ideas. I would say this is essentially a [job scheduling][1] problem with multiple optimization criteria: - total completion time - resource utilization The mathematical discipline that studies such problems is [scheduling theory][2], a subdiscipline of [oper...
>Can we combine these two to give an algorithm that betters the usual Time complexity? The key to your question is "what do you mean by time complexity?" Often it is quite clear, and we don't have to state it, but other times we do need to be careful. Sometimes the thing you are interested in is the complexity c...
null
In brief, set theory is about membership while category theory is about structure-preserving transformations – but only about the relationships between those transformations. **Set theory** is only about membership (i.e. being an element) and what can be expressed in terms of that (e.g. being a subset). It does not ...
null
null
The one key thing that you need to do differently to support GHC-style rank-N types is use the user-supplied type signatures to guide the process of translation to System F. In ordinary Hindley-Milner type inference, that's optional: you can instead infer your own type and then unify it with the user-supplied type afte...
null
Beam Search can fail to find any solution even with an admissible heuristic. (Suppose the beam has width $k=1$ and the root node has two children, $a$ and $b$, with $b$ being a solution and there is no solution reachable from $a$. Let $C(v)$ be the true cost of an optimal solution via vertex $v$ and $\infty$ if no solu...
I am a mathematician novice with the theory of computer science. During the course I took, we dealt with decisional problems (introducing D, SD, coSD classes linguage side, and P, NP, coNP, EXP, DP, AC0, complexity side) while we have only mentioned the function problems. I used the book Automata, computability and ...
Function problem vs decision problem
|complexity-theory|decision-problem|search-problem|
I am a mathematician novice with the theory of computer science. During the course I took, we dealt with decisional problems (introducing D, SD, coSD classes language side, and P, NP, coNP, EXP, DP, AC0, complexity side) while we have only mentioned the function problems. I used the book Automata, computability and ...
I'm self studying Introduction to Theory of computation and I'm a bit confused about a problem definition. I'm trying to understand and verify whether my proof is correct or not. **Question**: Prove that the regular language is closed under perfect shuffle The perfect shuffle between two languages $A$ and $B$ is ...
Does this DFA prove closure under Perfect Shuffle?
|finite-automata|closure-properties|
I am learning about blockchain and I've read that blockchains are immutable. Suppose my health information is stored on a block and I have gotten diagnosed with a disease and now my information needs to be updated. I have read online ([here](https://tykn.tech/identity-management-blockchain/#What_if_I_need_to_change_som...
How can information be updated in blockchain?
|blockchain|
null
No, the complexity cannot be constant, because the iterations $j = 2^j$ always yield a finite integer, and there is always a larger $n$. So the number of iterations is unbounded. Anyway, as the required n grow astronomically fast (see below), the number of iterations grows extremely slowly. The iterates are $$...
This does not work, I am afraid. Your state space is the union $Q_A\cup Q_B$ of the individual spaces, it should be the direct product $Q_A\times Q_B$ instead. See for example this answer: [Zigzag concatenation of two languages][1]. The reason is that one should also remember the state of the other automaton when swi...
In dived and conquer one uses the following formula to find the runtime: $$T(n) = aT(n/b) + f(n).$$ I am confused with the meaning of the constants $a,b$ as well as by the question how to find f(n). The textbooks could not help me. In exercises one usually gives this data and asks about the runtime. The master theorem ...
How to find the runtime out of a recursion formula when using divide and conquer
|time-complexity|recursion|
Your example is a bit weird, because you are not describing a problem you are trying to solve for a given length $n$… For the explaination, suppose you want to count the number of ships (like in battleship game) present in the square. - $a$ is the number of times you have to make a recursive call. Here, since there ...
**Hints:** You can guess this information from the equation itself. In $T(n)$, $n$ denotes the size of the problems. So $T\left(\dfrac nb\right)$ must the size of the subproblems, and there are $b$ of them. Now the $a$ in $aT\left(\dfrac nb\right)$ must be the number of subproblems that are effectively solved....
Your example is a bit weird, because you are not describing a problem you are trying to solve for a given length $n$… For the explaination, suppose you want to count the number of ships (like in battleship game) present in the square. - $a$ is the number of subproblems, aka the number of times you have to make a rec...
**Hints:** You can guess this information from the equation itself. In $T(n)$, $n$ denotes the size of the problems. So in $T\left(\dfrac nb\right)$, $\dfrac nb$ must be the size of the subproblems. Now the $a$ in $aT\left(\dfrac nb\right)$ must be the number of subproblems that are effectively solved. Fina...
null
Your example is a bit weird, because you are not describing a problem you are trying to solve for a given length $n$… For the explaination, suppose you want to count the number of ships (like in battleship game) present in the square. Suppose, for simplicity purposes, that no two battleships touch each other. - $a$ ...
null
I know that Quicksort is faster than, say, Bubblesort. And I know why (complexity metrics) but I never been able to find out how could someone start with Bubblesort, and then optimize parts of the code to end up with Quicksort… Is it even possible? Or it’s the case that going from Bubblesort to Quicksort such a lar...
How to design a faster sort algorithm? Is there sort of meta-algoritm for it? Or we do not understand how better sort algorithms were discovered?
|algorithm-analysis|sorting|program-optimization|
I know that Quicksort or MergeSort are faster than, say, Bubblesort or Selection sort. And I know why (complexity metrics) but I never been able to find out how could someone start with, for example Bubblesort, and then optimize parts of the code to end up with Quicksort or MergeSort… Is it even possible? Or it’s t...
Given sorted $0\leq x_1 \leq x_2 \leq ... \leq x_n$ and $y_1 \geq y_2 \geq ... \geq y_n \geq 0$ non negative **integers** accessible through oracles, with the additional constraints $x_{i+1}-x_i \leq 1$ and $y_i - y_{i+1} \leq 1$. Can we approximate the minimum of $x_i + y_i$ with $o(n)$ oracle queries to $x_i, y_i$ va...
Approximation algorithm for minimising $x_i+y_i$ for monotonically increasing sequence $x_i$ and monotonically decreasing sequence $y_i$
|optimization|approximation|adversary|
I know that Quicksort or MergeSort are faster than, say, Bubblesort or Selection sort. And I know why (complexity metrics) but I never been able to find out how could someone start with, for example Bubblesort, and then optimize parts of the code to end up with Quicksort or MergeSort… Is it even possible? Or it’s t...
|algorithm-analysis|logic|sorting|constraint-satisfaction|program-optimization|
Algorithm design is known to be an art. There is no magical recipe. It all depends on the mathematical properties of the problems addressed. In the case of sorting, the designers were helped by a few theoretical considerations: - there are $n!$ ways to permute an array, so any sort that relies on comparisons (eac...
Algorithm design is known to be an art. There is no magical recipe. It all depends on the mathematical properties of the problems addressed. In the case of sorting, the designers were helped by a few theoretical considerations: - there are $n!$ ways to permute an array, so any sort that relies on comparisons (eac...
Yes, absolutely. You are right. You can think of a block-chain like an "append-only log": anyone can append a log entry saying anything. That will give you a reasonable intuition. If you want to use it for something useful, you'll probably need to introduce extra checks. For instance, perhaps you can [sign](http...
Is there an **efficient** algorithm for minimizing a deterministic PDA in terms of states? Is it even computable? I know that it is not possible to minimize a [PDA](https://cs.stackexchange.com/q/37461/755) in general, but my question is about *deterministic* PDA. For tools like lexer generators, where occasional...
{"Voters":[{"Id":755,"DisplayName":"D.W."}],"SiteSpecificCloseReasonIds":[]}
{"Voters":[{"Id":755,"DisplayName":"D.W."}],"SiteSpecificCloseReasonIds":[]}
I have an example problem we are doing where we have xy. The special string I picked for the specific question was 0^p 1 1 0^p. My question is that when we "pump" Y, only part of y gets pumped so that the string results in 0^p+k 1 | 1 0^p. Why do we only pump the first half of Y if the whole special string is equal to ...
Help with understanding a stipulation in pumping lemma
|automata|pumping-lemma|
No, there is no "false positive". ------ Let me to explain the meaning of "the even-odd rule" a bit. > The SVG defines the even–odd rule by saying: > > This rule determines the "insideness" of a point on the canvas by drawing a ray from that point to infinity in any direction and counting the number of path ...
No matter how much one optimizes its code, a bad algorithm will always be bad. The key to great software is starting with a great algorithm. What distinguishes an algorithm is something that makes it fundamentally different from other algorithms. Iteratively improving an algorithm will never result in something th...
null
null
Algorithm design is known to be an art. There is no magical recipe. It all depends on the mathematical properties of the problems addressed. In the case of sorting, the designers were helped by a few theoretical considerations: - there are $n!$ ways to permute an array, so any sort that relies on comparisons (eac...
null
null
First preprocess the string to normalize it (casing, no digits, unique separators...). You do this for the database of known titles, and for the input string to be matched. It might also be of interest to discard the articles/prepositions/connectors as they convey little semantic information. Now you can use the str...
Bubblesort to Quicksort requires some cleverness, but is a quite natural progression. First, you implement Bubblesort, and you find that for 100,000 random items it is indeed very slow. 100,000^2 operations. You'll find easily that if you split the array into two groups of 50,000, sort both and merge the results, y...
---------- *I am interested in the formula of modularity difference between two partitions considered in the Louvain algorithm for community detection in graphs. I give a formal expression of this question below.* ---------- Consider an [undirected graph][1] $G$ with vertex set $V$. If $G$ is weighted, $\omega...
The modularity difference in Louvain algorithm for community detection in graphs
|algorithms|graphs|partitions|network-analysis|social-networks|
*(Short discaimer: I'm a mathematician by education (category theory, algebraic geometry) and so mostly unaware of how different fields in CS relate to each other. I'd be very happy to just get some directions. Also I'm not sure if the tags I added to the question are all correct.)* My question is concerned with inf...
Reference request: Time and proofs of a shared past
|distributed-systems|information-theory|blockchain|
*(Short discaimer: I'm a mathematician by education (category theory, algebraic geometry) and so mostly unaware of how different fields in CS relate to each other. I'd be very happy to just get some directions. Also I'm not sure if the tags I added to the question are all correct.)* My question is concerned with inf...
null
The other answers here explain very well the mathematical idea and thought process to come up with a sorting algorithm, there might be cases where even the "most optimal" algorithm you have, may not deliver the performance you expect. Of course they all sort so they are correct, but in practical scenarios, lower execut...
If the equal values are dense (say if the number of distinct values is less than a quarter of the array size), it could be worth to sort and determine the multiplicities. If they are sparse, sorting could be counterproductive. This said, counting the divisors for a value does not help counting those of other values....
The other answers here explain very well the mathematical idea and thought process to come up with a sorting algorithm, there might be cases where even the "most optimal" algorithm you have, may not deliver the performance you expect. Of course they all sort so they are correct, but in practical scenarios, lower execut...
I have always assumed that "Linked List" is something in the lines of struct Node { SomeClass payload; Node * next; Node * prev; } This implies the restriction of working with objects of only one type. Considering lists are horrible in access time I doubt anyone really con...
Are linked lists homogenious or heterogenious containers?
|data-structures|type-checking|linked-lists|
You say "linked list" without mentioning a computer language. First, a "Node" is not a linked list. It is a helper struct that may be useful to create a linked list, but it is just a wrapper around some thing with additions so it can be made part of a linked list. In Objective C or in Swift, you'd declare Node ...
*(Short discaimer: I'm a mathematician by education (category theory, algebraic geometry) and so mostly unaware of how different fields in CS relate to each other. I'd be very happy to just get some directions. Also I'm not sure if the tags I added to the question are all correct.)* My question is concerned with inf...
And here is my meta-algorithm for creating fast algorithms and fast implementations of algorithms: Step 1: Create a working algorithm. Step 2: Run the algorithm and figure out what bits run slower than you think they should. At this point you also understand the problem better. Step 3: With your better unde...
null
If $p$ is the pumping length of your language $L$, the pumping lemma guarantees that $w = 0^p 1 1 0^p$ can be decomposed as $xyz$ with $|xy| \le p$, $|y| \ge 1$, and $xy^iz \in L$ for all integers $i \ge 0$. Since $|xy| \le p$ and the first $p$ symbols of $w$ are $0$s, it must be that both $x$ and $y$ contain only ...
$\require{enclose}$ ### Definition of *parent* ### For any three strings $x$, $y$, and $p$, we say that $p$ is a ***parent*** of $x$ and $y$ if and only if all of the following: * $p$ is a $\enclose{updiagonalstrike, downdiagonalstrike}{\text{substring}}$ sub-sequence of some permutation of the concatena...
Factor $n$ as the product of two numbers roughly proportional to the rectangle sides, adding a few units if necessary. Let $n+r=n_xn_y$. Now fill $n_x$ columns one square large, that occupy the whole width, with free space to the right. You can space them randomly in the vertical direction. Then for every square, sc...
The [happened-before](https://en.wikipedia.org/wiki/Happened-before) relation is a standard mathematical tool for reasoning about time ordering of events in distributed systems. You can find a lot of development on foundations of it, tools for tracking it, and systems built on this concept. [Timestamping](https://e...
*(Short discaimer: I'm a mathematician by education (category theory, algebraic geometry) and so mostly unaware of how different fields in CS relate to each other. I'd be very happy to just get some directions. Also I'm not sure if the tags I added to the question are all correct.)* My question is concerned with inf...
No, there is no "false positive". #### What is the meaning when a rule *determines* the "insideness"? > The SVG defines the even–odd rule by saying: > > This rule determines the "insideness" of a point on the canvas by drawing a ray from that point to infinity in any direction and counting the number of path se...
null
I am taking a class in computer science and I am not sure about the following. When one transforms $247_{10}$ into its binary counterpart one gets $11110111_2$. However, the same binary number corresponds also to$-9$ when the 2-complement representation is considered. How does the computer know which of the two numbers...
Solving an ambiguity concerning unsigned and signed integers
|complexity-theory|
I am looking for a long list of words/terms which are related to aligning one string to another. * String Metric * Edit-Distance * Bioinformatics * Needleman–Wunsch Algorithm * Sequence Alignment * Global Alignment * Local Alignment * Levenshtein distance * Hamming distance * Damerau–Levenshtein ...
What is terminlogy missing from this list of words and phrases pertaining to string-matching and string-alignment?
|terminology|
null
Is the complexity of $F(n) = n*n^{log_3(2)}$ allowed to be written as $O(n)$, or must you specify and say $O(n^{1.63})$, or even must you write $O(n^2)$ since its an upper bound?
Complexity of $F(n) = n*n^{log_3(2)}$
|time-complexity|big-o-notation|
I was wondering if anyone can point me to a data structure that supports the following operations. Goal is to create a data structure $D$ that stores 64-bit integers and provides the following operations: - min() in $O(1)$ worst-case time - max() in $O(1)$ worst-case time - predecessor($x$) find the greatest elem...
Dynamic Data Structure for Sliding Window of varying size with Predecessor queries
|data-structures|
null
I was wondering if anyone can point me to a data structure that supports the following operations. Goal is to create a data structure $D$ that stores 64-bit integers and provides the following operations: - min() in $O(1)$ worst-case time - max() in $O(1)$ worst-case time - predecessor($x$) find the greatest elem...
null