instruction
stringlengths
0
29.8k
⌀
|algorithms|satisfiability|counting|sat-solvers|
null
No, they are not. A C compiler typically compiles to machine code, which is not statically typed. While machine code is not really a programming language, this should be enough to convince you that the language the compiler compiles to doesn't need to be statically typed, or typed at all. And indeed, C has been c...
I've only recently started learning about deterministic/nondeterministic finite automata and languages and I'd like some clarification on common notation used to describe languages. A 0 or 1 raised to an nth power just means that 0 or 1 occurs n times, correct? For example: the language $L = \{ 0^n \mid n ≥ 1 \} \cu...
You need to distinguish between three kinds of operations: - Operations on numbers such as 0 and 1. $0^3 = 0$ when $0$ is taken to be a number. Here, $0^3 = 0 . 0 . 0$, where $.$ is integer multiplication. - Operations on strings of characters. $0^3 = 000$ when $0$ is a string of characters of length 1. Here...
Consider a finite nonempty alphabet $\Sigma$. The set $\Sigma^* = \bigcup\limits_{n\geq 0 } \Sigma^n$ is the set of finite words over $\Sigma$, indeed, for all $n\geq 0$, we define $\Sigma^n$ as the set of finite words of length $n$ over $\Sigma$. For every two words $w,v\in \Sigma^*$, we define the concatenation $w\cd...
Consider a finite nonempty alphabet $\Sigma$. The set $\Sigma^* = \bigcup\limits_{n\geq 0 } \Sigma^n$ is the set of finite words over $\Sigma$, indeed, for all $n\geq 0$, we define $\Sigma^n$ as the set of finite words of length $n$ over $\Sigma$. For every two words $w,v\in \Sigma^*$, we define the concatenation $w\cd...
I am having hard time creating regex for languages where symbols must be in certain length. I hope I am not ignorant about rules. we have to generate regex using $^*,|,+ \text{ and }\cdot$ right? I am expected to generate a regex for the language $L = \{ w \mid w \text{ is a string over } \{0, 1\} \text{ and } |w| ...
how to generate regular expression for the language where symbols have to maintain certain length?
|regular-languages|regular-expressions|
Working on exercise 6.1.5 part 1 provided some clarity on the issue (at least I believe so). However, the solution provided in the appendix doesn't seem to get into the weeds (implementation details) enough to address this question. It seems that we can get around this by starting the de Bruijn indices for bound var...
The best way to view this, in my opinion, is by looking at the abstract syntax tree. For `λw. b w`, this would be something like: ``` λw | @ / \ b w ``` Here, we're going to assign `w` the de Bruijn index 0, because you do not pass any binders in order to get to its definition. However, for `b` we ...
null
I am having hard time creating regex for languages where symbols must be in certain length. I hope I am not ignorant about rules. we have to generate regex using $^*,|,+ \text{ and }\cdot$ right? I am expected to generate a regex for the language $L = \{\text{ all strings must have odd no. of 0s and odd no. of 1s }...
I am having hard time creating regex for languages where symbols must be in certain length. I hope I am not ignorant about rules. we have to generate regex using $^*,|,+ \text{ and }\cdot$ right? I am expected to generate a regex for the language $\{ L = \{ w ∈ \{0,1\}^∗ : |w|_0 and |w|_1 \text{ is odd } \}$. both...
Well, if you will use Fibonacci properties with Aho-Corasick automaton, you can easily figure out that the running time is linear.
null
{"Voters":[{"Id":64055,"DisplayName":"minseong"}],"DeleteType":1}
{"Voters":[{"Id":64055,"DisplayName":"minseong"}]}
null
Yes, they are known as #SAT solvers. Some of them are exact, some of them are approximate. Some of them are based on a version of DPLL that exhaustively find every solution in a factorized way. Some of them, known as bottom up, are based on transforming the input CNF to Boolean circuits for which we know how to find...
The problem: > Given $k>1$ Turing machines decide if for every possible input exactly one of them halts. Is this variant of halting problem undecidable? Intuitively, it seems that it must be not only as hard as the standard halting problem, it actually is harder. Because even if you have a refutation input str...
Undecidability of the exactly-1-in-k halting problem
|complexity-theory|turing-machines|undecidability|halting-problem|
You need to distinguish between three kinds of operations: - Operations on numbers such as 0 and 1. $0^3 = 0$ when $0$ is taken to be a number. Here, $0^3 = 0 ⋅ 0 ⋅ 0$, where $⋅$ is integer multiplication. - Operations on strings of characters. $0^3 = 000$ when $0$ is a string of characters of length 1. Here, $0...
Consider a Turing Machine $M_1$. Create $k - 1$ looping machines $M_2, …, M_k$ that never halts. Then $M_1$ halts on all inputs if and only if for any input, exactly one among $M_1, …, M_k$ halts. There, you have a many-one reduction from $\textsf{ALL} = \{\langle M\rangle \mid L(M)=\Sigma^*\}$ which is known to ...
I've just read the Punycode spec in [RFC 3492](https://datatracker.ietf.org/doc/html/rfc3492), as well as descriptions of it across some other articles. Punycode uses a numeral system the authors called "generalized variable-length integers" (is that term well-known in maths in general?) to encode a sequence of integer...
What's the point of the thresholds in Punycode/Bitstring?
|number-theory|numeral-representations|
I created a DFA recognizing the language and used the Brzozowski and McCluskey's algorithm (state elimination method) to obtain: $$(01\mid 10)\left(00\mid 11 \mid (01\mid 10)(00\mid 11)^*(01\mid 10)\right)^* $$
I've just read the Punycode spec in [RFC 3492](https://datatracker.ietf.org/doc/html/rfc3492), as well as descriptions of it across some other articles. Punycode uses a numeral system the authors called "generalized variable-length integers" (is that term well-known in maths in general?) to encode a sequence of integer...
Consider the following graph $G = (V, E)$ where: - $V = \{v_0\}\cup \{u_1,…, u_n\}\cup \{v_1, …, v_n\}$; - $E = \{\{v_0,u_1\}, \{v_0, v_1\}\}\cup \bigcup\limits_{k=1}^{n-1}\{\{u_k, u_{k+1}\}, \{u_k, v_{k+1}\}, \{v_k, u_{k+1}\}, \{v_k, v_{k+1}\}\}$. [![enter image description here][1]][1] Then the graph has mo...
null
Can you make interesting decentralised systems, e.g. cryptocurrencies or serverless games, that aren't susceptible to 51% attacks by design? (Rather than, as I've seen proposed, external solutions like fining mining pools that have too large a hashing power)
Consider a Turing Machine $M_1$. Create $k - 1$ looping machines $M_2, …, M_k$ that never halts. Then $M_1$ halts on all inputs if and only if for any input, exactly one among $M_1, …, M_k$ halts. There, you have a many-one reduction from $H_{\textsf{ALL}} = \{\langle M\rangle \mid M \text{ halts on every inputs}...
Consider a graph $G = (V, E, w)$ such that: - $V = \{s\}\cup \{v_1, …, v_n\}$; - $E = E_1 \cup E_2$, with: - $E_1 = \{\{s, v_i\}\mid i\in \{1, …, n\}\}$, $f(s, v_i) = n + 1$ - $E_2 = \{\{v_i, v_{i+1}\}\mid i \in \{1, …, n\}\}$, $f(v_i, v_{i+1}) = 1$ (with the convention that $v_{n+1} = v_1$). Then the sh...
null
null
null
It does not matter whether 8192 bits are subdivided into 1024 items of 8 bits, 512 items of 16 bits, 256 items of 32 bits, or not subdivided at all - the amount of information one can store in that memory stays always the same. To express this fact in simple math counting the combinations: $2^{8192} = (2^8)^{1024} ...
null
null
The odd-odd language can be accepted by a four state finite state automaton. It stores for each of the symbols whether it has seen an even or odd number of that symbol. Thus we need two bits, one for each of $0,1$. Reading and $0$ or a $1$ will flip the corresponding bit. The fun part is that we can reduce this eleg...
I am studying about 2Q Cache Replacement Policy and i came across [this post](https://medium.com/@koushikmohan/an-analysis-of-2q-cache-replacement-algorithms-21acceae672a). <br /> They have worked out an example with the following page keys [1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5] and cache memory of 5 pages. A1in size i...
Reason for page miss in 2Q Cache Replacement
|algorithms|logic|cache|
null
null
Page miss in 2Q Cache Replacement
|algorithms|data-structures|logic|cache|page-replacement|
can someone help me with this problem? Consider a hashing scheme that uses r hash tables T1, . . . , Tr of size m, where collisions in each table are resolved by chaining. When a key k arrives, it is hashed into each table Ti using hash function hi, and then stored in table Ti having the smallest chain in location hi(k...
What is the probability of no collision in two hash tables, where a key is hashed to both tables and chained to the shortest chain from the tables?
|hash-tables|
Fagin's Theorem (see [Wikipedia][1] and [these lecture notes][1]) states that there is an equivalence between second-order logic (SOL) formulas with existential quantifiers, and problems in NP. **I was wondering if we can also extend this result to other complexity classes in the polynomial hierarchy?** For exam...
Extending Fagin's Theorem to the Polynomial Hierarchy
|complexity-theory|time-complexity|logic|np|first-order-logic|
A question I am to answer wants me to find the big O of a recurrence, I am doing it with the iteration method. For the base case, which we get after applying the recurrence $i$ times, can we make this any number as long as we assume it will be in constant time? Such as $T(5)$, $T(100)$ etc. I can't give anymore info to...
null
Karnaugh maps do not always give the simplest expression possible, but they do always give the simplest "Sum of Products" expression possible (https://web.archive.org/web/20190920201621/https://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Logic/Logic3.html).
null
Assume a variant of a one-tape deterministic Turing Machine that reads and writes on the portion of the tape that the input $w$ appears (like linear bounded automata). My question is, how we could bound the time complexity for membership in this type of Turing machine? I think the time complexity could be the worst...
Time complexity of specific variant of Turing Machine
|formal-languages|turing-machines|
- If the machine is a decider, meaning halts on its input $w$, then it does not repeat a configuration in its run on $w$. Hence, the number of configurations that the machine can be in bounds its running time from above. The number of configurations is at most $|Q| \cdot |\Sigma|^n \cdot n = 2^{log(|Q|\cdot |\Sigma|^n...
So in an exam, this was the recurrence: $$ T(n) = 2T(n/2) + n log(n) -n + O(log(n))$$ $$T(1) = 1$$ Why does the master method not apply here? I think it is indeed int he form $$aT(n/b) + f(n)$$ You can say: $$a =2$$ $$b = 2$$ $$f(n) = n log(n) - n + O(log(n))$$ My guess: $O(log(n))$ is too broad and cannot ...
Is this a special case of a recurrence where the Master Method is not applicable?
|recurrence-relation|master-theorem|
Python `float` corresponds to C++ `double`. According to Institute of Electrical and Electronics Engineers Standard for Floating-Point Arithmetic ([IEEE 754](https://en.wikipedia.org/wiki/Double-precision_floating-point_format)), `double` or `binary64` is specified with: - Sign bit: $1$ bit - Exponent: $11$ bits -...
The programming language is C++, and the elements of the input `vector` are of type `int` and able to take all valid `int` values. So it’s not possible to store extra information in the input `vector`. Now, is it possible to sort the `vector` in linear time and constant extra space? Simple solutions are preferred.
Is it possible to sort numbers in linear time and constant extra space?
|sorting|space-complexity|linear-complexity|
Yes. Move all elements with value $-2^{31}$ to the front, order of the remaining elements doesn't matter. Easy in linear time. Then move all remaining elements with value $-2^{31}+1$ to the front (but after the $-2^{31}$ elements). Then do the same with $-2^{31}+2$, ..., $2^{31}-1$. Total time for $n$ elements is $O(2...
If you require a comparison-based sorting algorithm akin to quicksort and merge sort, the answer is "No." Simply put, it can be proven that sorting an array of $n$ elements using a comparison-based method in that respect would require, at least, a complexity of $O(n\times log(n))$. Alternatively, [Kelly Bundy](https://...
null
The programming language is C++, and the elements of the input `vector` are of type `int` and able to take all valid `int` values. So it’s not possible to store extra information in the input `vector`. Now, is it possible to sort the `vector` in linear time and constant extra space? Simple solutions are preferred. A...
(Note: This was posted before their edit.) Yes. Move all elements with value $-2^{31}$ to the front, order of the remaining elements doesn't matter. Easy in linear time. Then move all remaining elements with value $-2^{31}+1$ to the front (but after the $-2^{31}$ elements). Then do the same with $-2^{31}+2$, ..., $2...
An effectively universal Turing machine $T$ is a Turing machine for which there exists a recursive reduction $f:A\rightarrow B$ that makes $T$ behave on $B$ like some universal Turing machine would behave on $A$. Is there any connection between effectively universal Turing machines and Turing-completeness? Also, ...
Effectively universal Turing machines and Turing-completeness?
|turing-machines|reductions|halting-problem|turing-completeness|
null
I was thinking about quicksort with multiple pivots and i came across this question.How can we efficiently implement a version of Quicksort where we choose k−1 pivots to partition an array of unique numbers into k classes? My goal is to demonstrate that this multiary partitioning can be achieved in O(n log k) time, en...
Quick sort with K-1 pivots
|algorithms|algorithm-analysis|quicksort|divide-and-conquer|selection-problem|
No, they are not. A C compiler typically compiles to machine code, which is not statically typed. While machine code is not really a programming language, this should be enough to convince you that the language the compiler compiles to doesn't need to be statically typed, or typed at all. Examples: - C compil...
Fagin's Theorem (see [Wikipedia][1] and [these lecture notes][2]) states that there is an equivalence between second-order logic (SOL) formulas with existential quantifiers, and problems in NP. **I was wondering if we can also extend this result to other complexity classes in the polynomial hierarchy?** For exam...
I want to write a regular expression that generates precisely those words over Σ(a,b) that contain at most 1 non-overlapping occurrences of the subword bba. I can't use ? or |. It has to accept the empty word and words suchs as a or bb or aaaaaabbabbbb. So far I've tried to place bba in the beginning, middle or endi...
Regex Question, creating words with a possibly recurring subword
|regular-expressions|
I want to write a regular expression that generates precisely those words over Σ(a,b) that contain at most 1 non-overlapping occurrences of the subword bba. I can't use ? or |. It has to accept the empty word and words suchs as a or bb or aaaaaabbabbbb. So far I've tried to place bba in the beginning, middle or endi...
Let $L_1, L_2$ be regular languages. You can proof with a product automaton that $L_1\cup L_2$ is also regular. But you can also construct a NFA. Since $L_1, L_2$ are regular, they also have an NFA representation $M_1, M_2$. You can create a NFA with a start state $q_0$ with one edge each to the start states of $M_...
Difference between product automaton vs. NEA
|automata|finite-automata|
So, i just got through studying DRAM architecture. I learned that a row address, column address, bank number etc are provided to the DRAM during a read operation. Based on the address provided, 64 bits will be transferred back to the memory controller (assuming the data bus is 64 bits wide). So if we have 8 DRAM chips,...
Memory addresses requested by CPU vs Memory Address Provided to DRAM
|computer-architecture|memory-management|cpu|
Given a set Z of n points (p1,p2,p3..pn). The coordinates of these points are arbitrary numbers and are unsorted. If they give me s and t to be two points in Z. A northeast path from s to t in Z is a sequence of points (s=t1,t2,..tk=t) such that every point for any two points ti and ti+1, ti+1 is on the northeast of ti...
Find the longest northeast path in O(nlogn) time
|algorithms|algorithm-analysis|
I want to write a regular expression that generates precisely those words over Σ(a,b) that contain at most 1 non-overlapping occurrences of the subword bba. It has to accept the empty word and words suchs as a or bb or aaaaaabbabbbb. So far I've tried to place bba in the beginning, middle or ending. But the thing is...
Simple. If the software requests a single byte the processors memory subsystem will request the 8 bytes contains this byte.