instruction stringlengths 35 29.1k |
|---|
I want to know how hardwares write a byte in memory?
If there is difference between writing process in RAM and ROM I would like to know as well.
Specially I want to know:
Is hardware writes values bit by bit? (I mean like writing first bit then go to next)
Is there a header that move around and change bit by bit? If n... |
I have different time intervals (contains partial or full overlaps). I provided the sample input and output so that it would be easy to understand.
Sample Input-1:
[1-5, 2-3, 3-5, 3-5, 3-6]
Sample Output-1:
[(1-2):1, (2-3):2, (3-5):4, (5-6):1]
The above output informs that, for the interval (1-2), there is only one int... |
Lets say the alphabet is Σ=∅,what are the possible languages of this alphabet?
According to my definitions:
I know that an alphabet is a finite set of symbols Σ
I know words is a set of all finite symbols consisting of letters from the alphabet (Σ*) and an empty string part of all words ε ∈ Σ*
I know that a language i... |
Could we say that Dynamic programming is nothing but recursion + Memoization?
Although the formal definition of dynamic programming is that the problem should have an optimal substructure property, which in a way is nothing else but recursion.
|
In the Introduction to Algorithms Book By Thomas H. Cormen, Third Edition, they give an approximation algorithm for the Vertex Cover Problem with 2-approximation ratio:
Where G is undirected graph.
The complexity of this algorithm is O(V+E).
I do not know why.
It should be O(E) since the while loop in line 3 clearly w... |
Question
Let $L$ be a regular language. Let's say we sort $L$ by length and then lexicographically; then let $L_p \subset L$ be every $p$th word in $L$ according to this sort. Is $L_p$ regular as well?
Example
For example, let's use $L = a^*b^* = \{\epsilon, a, b, aa, ab, bb, aaa, aab, abb, ...\}$. Then $L_2 = \{\epsil... |
The right answer is Theta(n log logn). But, can someone explain why it is the case? I know intuitively that it is because k is k^2 each time, so it couldn't be (logn) for the second loop. However, what is the actual mathematical analysis that makes it (log logn)?
|
Suppose I have the mesh of an geometrical object (Interval in 1d, Region in 2d, Volume in 3d). How can I find out whether a point lies on its boundary or not?
I am looking for algorithms with explanations. Any resource would also be appreciated.
|
Given two binary matrices of the same size with the same element counts, how can we find a map mapping ones to ones such that the sum of differences of distances of all pairs of neighbors is minimised, where the distance of each cell is the number of steps it needs to walk horizontally, vertically or diagonally to reac... |
Let L be a regular language. Then there exists a regular expression r such that L = L(r).
Proof for NFAs with only 2 states (can be generalized!), partly seen during a lecture and completed by me:
Let $M=\left(Q, \sigma, \delta, q_0, F\right)$ be an nfa that accepts $L$
The nfa $M$ has only two states $q_0$ and $q_1$ w... |
i want to show that for all $CFL$ and not $REG$ languages $L \subseteq \{0,1\}^*$
exists $L_1,L_2\subseteq\{0,1\}^*$ with:
$L_1$ is $REG$
$L_2$ is $CFL$ and not $REG$
$L_1 \subseteq L_2 $
$L \subseteq L_2 $ and $L \neq L_2$
I struggle at showing it for all $L$.
What I did so far is some kind of a little sketch.
Let ... |
I know that to illustrate speed-up advantage of Grover's algorithm we can apply "square root": if the brute force search takes 100 hours, Grover's quantum search algorithm should take about 10 hours. What would be similar numbers for Shor's algorithm for, say, 10-digit numbers?
|
Given a real matrix $M \in \mathbb{R}^{n \times m}$ and a vector $v \in \mathbb{R}^{n}$ I would like to find an element $x \in \mathbb{R}^m$ such that $v - Mx$ has maximum number of zeros.
If the matrix $M$ has rank $n$ then it is easy to find some $x$ where $xM = v$. But in the case where $m<n$ the best I can think ri... |
Issue: I am having a hard time figuring out how to use the worst case for Rolling Hash, especially if the occurrences are only "a and b" for the string. Not only that but it is a bit of a hassle to figure out the process if the pattern that we tried to find from the given string will only contain one character occurren... |
I'm implementing a q-learning agent for tic-tac-toe that requires mapping from tic-tac-toe boards to float values. Since certain game states are equivalent and should have the same value, it would be more efficient to store all games that are mirrors or $90^{\circ}$ rotations of each other, only once. Is there an algor... |
I recently saw this answer on a question in the Quantum Computing SE. The answer demonstrated how we can probabilistically find the answer to the Deutsch Jozsa problem on a PTM in $O(1)$ time, with an error of $\frac{1}{2^k}$, where k is the number of entries we check.
I will provide an algorithm and proof of why (to m... |
Let $n\in\mathbb N$.
Given a set $S\subset\mathbb N$, let $\Delta(S) = \{a-b\mid a,b\in S\}$ denote its set of differences.
I'm interested in finding a small set $S_n$ such that $\{1,\ldots,n\}\subseteq\Delta(S_n)$.
For example, if $n=8$ we can use
$$S_8 =\{1,2,4,8,9\}.
$$
How can we construct a small $S_n$ efficientl... |
I am enrolled in the Algorithmic Toolbox course on Coursera, and as apart of the first week that are walking us through how to implement algorithms. But I am having trouble understanding the symbol and wording that they are using. This is an example of the psuedocode:
StressTest(N ,M):
while true:
n ← random integer be... |
Consider the problem of tiling a rectangular region with a given set of Wang tiles. It is well-known that this problem is NP-complete: every NP problem can be encoded as some form of tiling problem (see e.g. here). It is also well-known that there are particular sets of tiles that only tile the plane aperiodically. The... |
I realize this is sort of a trivial ask, but I want to make sure I understand OWFs and it's usually explained with some jargon that I don't find clarifying. So, I'd just like to know whether or not my understanding of one-way functions is "essentially correct":
$f$ is a one-way function iff it can convert $n$ input bi... |
Let $G(V,E), |V| = n, $ be a (undirected) graph and a coloring function $f: V\rightarrow \{1,2,3...s \}$ which assigns to each vertex a color, such that in total there are $n/s$ vertices of each of the $s$ colors.
Starting from a given vertex $a$, the task is to find out if there is a path in the graph, such that it co... |
I have an image with a list of segmentation polygons. Getting the bounding box with the polygons is easy enough. I used the bounding box to crop out the objects of interest.
Now, I want to scale the polygons so that they wrap around the cropped object. I scaled the polygons using the ratio of the original image size to... |
$\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 concatenation of $x$ and $y$.
$x$ is a $\... |
Before I even attempt coming up with an efficient algorithm, I tried googling for similar problems but didn't get far, most queries mentioning "sets" in them led to some sort of Multiple subset sum or other subset construction problem. What I'm looking for is quite literally the opposite.
The problem is very straightfo... |
I am struggling to understand the difference between the notions $P, NP, NP-$complete, $NP-$hard. Let's take the example of the $NP-$class. We say that these problems are solved in non-polynomial time, i.e. they have an exponential time complexity, while at the same time we say that they are verified in polynomial time... |
I am unsure if it has infinite equivalence classes or not, respectively how to interpret the textbook solution.
My approach was that it has infinite because,
lets say we have $x = a^5$ and $y = a^7$.
If we append them with $aa$ then
$x = a^7$ and thus $x \notin L$ and $y = a^9$ and thus $y \in L$. Because $9$ is a squa... |
Given an array of N integers, there may be a need to perform q queries. A query could be like determining the number of values that are less than an integer k. Which data structure could be used to minimize Time Complexity?
My Thoughts:
One easy way could be to keep the numbers sorted. And then, for each query, we just... |
Given $n$ distinct sets $S_1, S_2, \cdots, S_n$, how to find a set $X$ such that $X \cap S_1, X \cap S_2, \cdots, X \cap S_n$ are still distinct, and the size of $X$ is minimum?
For example, given $\{1, 2\}, \{1, 3\}, \{2, 3\}$, let $X=\{1, 2\}$, then the intersections are $\{1, 2\}, \{1\}, \{2\}$, which are still diff... |
Hello I am trying to solve this recurrence equation using the recursion tree method:
T (n) = T (n −1) + n^2 In particular, what is big-O of T (n)?
Here is what I have done so far:
I am not sure if I drew the tree correctly, and I don't know how to figure out the runtime. If someone could draw out the tree, and explain... |
Update: To clarify. MyNOR (http://mynor.org/) stores some combined instructions in ROM to make programs take up less space. It seems very possible that instruction sets for CPUs might do similar, in more normal computers. I was interested if such load as part of some operative system/kernel/whatever it is called, or is... |
Why is Solution 1 faster than Solution 2?
The input passed to both solutions:
let myArraySortedSquares = Array(stride(from: -100000, through: 100000, by: 1)).shuffled()
Solution 1 with O(nlog(n)) time complexity and O(n) time complexity
Time elapsed: 2.76 s.
// Time: O(nlog(n)) | Space O(n)
func sortedSquaredArray_sol... |
My book Sebasta's Concepts of Programming Language (Chapter 1) states:
Orthogonality in a programming language means that a relatively small
set of primitive constructs can be combined in a relatively small
number of ways to build the control and data structures of the
language. Furthermore, every possible combinat... |
if we define halting problem as follows
$
\begin{align*}
h(m,n) &=
\begin{cases}
1 & \text{if program $m$ halts on input $n$} \\
0 & \text{otherwise} \\
\end{cases}
\end{align*}
$
and we have two sometimes correct solutions $f$ and $g$ for $h$ that are always correct if they agree but fails to agree ... |
I have some algorithmic complexity estimates in Giga Operations Per Second (GOPS) and I would like to compare those with the capabilities of state-of-the-art processors. However, the processor performance is commonly measured in FLOPS.
According to this (Eq.4)
FLOPS_core = OPS * FLOPs/operation
What would be a reasona... |
Let's say there are four sets containing integers. No set has any duplicates within itself, but duplicates exist across sets.
A = [1, 2, 3, 4]
B = [2, 3, 4, 5]
C = [3, 4, 5, 6]
D = [4, 5, 6, 7]
The goal is to store each unique element in a resulting set R. The naïve single-threaded solution would be to iterate over ea... |
As part of pre-processing my (very large) directed acyclic graph, I want to eliminate as many unnecessary edges as possible. By "unnecessary" I mean an edge that could be absent from the transitive reduction of the graph. For example, in the graph {(1 -> 2), (2 -> 3), (1 -> 3)}, edge (1 -> 3) is considered unnecessary.... |
Wikipedia defines range of data type:
the set of possible values that that variable can hold.
Suppose we have two data types A and B. Now, with attention to
the definition of widening in section 7.4 of Concepts of Programming Languages, we
can say:
range of B is larger than A when range of B includes at least
ap... |
I am trying to understand what the time complexity for an autocomplete function for a Trie-based dictionary would be. Every node contains a letter and whether it is the last letter of a word, and if so, how frequently it shows up in the english language.
From my understanding, if we have a Trie (prefix tree), and we se... |
In the PBFT paper written by Miguel Castro it has been mentioned:
(In Abstract:)
"BFT has been implemented as a generic program library with a simple
interface."
(Also in page 71:)
"The algorithm has been implemented as a generic program library with
a simple interface. Thelibrary can be used to provide
Byzantine-fa... |
This is a pretty vague question and can be applied to many math problems not just recurrence relations.
Above I fully understand, setting up the recurrence relation from the algorithm given. And how the next step would be plugging and chugging to find a pattern that we can use.
So as shown above, we do not know what ... |
Consider an array A[1..n] that first increases up to some point p then it decreases until some point q and then increases again. That is A[k] < A[k + 1] for all k in [1..p] and [q..n] and A[k] > A[k + 1] if p < k < q.
Suppose we are searching for the element A[p] or the index p, whats the fastest possible algorithms
M... |
Prove or give a counterexample: for every function f from non-negative integers to non-negative
reals, o(f) = O(f) − Θ(f). Here “−” denotes the set minus operation. I try to make some tryout but failed to make the abstract function f to into working, can someone give me some Hints or solutions?
|
When I was trying to solve a problem, I met another problem like this:
Given a undirected connected graph $G=(V,E)(|V|\le100)$ and some subgraphs of $G$: $G_1,G_2,\cdots,G_n(n\le 32)$, and all $G_i$ is connected and include all the vertexs in $G$. We need to cut some edges in $G$ so that neither of the subgraphs $G_1,G... |
I need to propose an algorithm for a NP-hard problem. I use dynamic programming which leads to a running time $O(2^s\cdot n^2), s\leq n.$ The algorithm aims to finding a path in a graph $G(V, E)$ (in which each of the n nodes is colored in one of the $s$ colors) containing all the $s$ colors which are represented a sin... |
Let's say I have a 60 set of numbers from 0-100,000 so like [81, 98, 115, 189, 254, ... , 97866, 98441, 99671] all unique and progressively increasing. Would it be mathematically possible to compress this sequence by 80-90%? so far I've tried gzip which only compresses at 50% and other algorithms the best one I found w... |
What is the asymptotic of
${n \choose 3} \log ^4n$ ?
I know that ${n \choose 3}$ is in $\cal O (n^3)$, but what about the term $log^4n$ and what about the product of the two?
|
In classical kD-trees, the splitting dimension is chosen using a simple and systematic rule: dimensions are taken in a round-robin fashion.
But extra freedom is available because you could very well choose the splitting dimension at will on every level, and even differently on every node.
Has this been investigated ? C... |
What is known about the languages:
$$S_f = \{ [M] \ | \ \exists{x} \ \text{s.t.} \\ M \ \text{accepts} \ x \ \text{in} \ f(|[M]|) \ \text{steps}, \\ \ |x| \leq f(|[M]|) \}$$
I used to think that in order to check whether a string $[M]$ is in $S_f$ you cannot avoid simulating $M$ on all possible $x$ whose length is less... |
As described here the Takagi factorization of a square symmetric complex matrix $A=VDV^T$ where D is a real nonnegative diagonal matrix, and V is unitary. I'm wondering what the complexity of calculating this is for a $n\times n$ matrix? I would think $O(n^{2.8074})$, if using Strassen's matrix multiplication algorith... |
I'm trying to understand Complexity of the hamiltonian cycle in regular graph problem [1]:
I don't understand this part:
Lemma 2.11: HC-3-regular-(n-even) is NP-complete
The result is obvious since the number of edges of a 3-regular graph is (3/2) n.
I don't understand what is the relation of the number of edges and ... |
I have a flow question which I'm stumped on but seems like there should be an answer that I am not seeing.
Consider a network with a start $s$ and an end $t$ and a bipartite graph $L \cup R$. $s$ is connected to all vertices in $L$ via edges with capacity $1$. All vertices in $R$ are connected to $t$ via edges with cap... |
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 in general, but my question is about deterministic PDA.
For tools like lexer generators, where occasionally a counter or a stack would be needed to lex languages... |
For a given integer exponent $e$, I want to identify all factors of an integer $n$ which are of the form $p^{e}$, where $p$ is a prime. So, for $e = 1$, this is equivalent to getting the unique prime factors, for $e = 2$ it's extracting all of the square factors, etc.
Currently, I am doing this by iterating over the po... |
Question I was asked: Does it make a difference if I say "The worst case run time is $O(n^2)$ vs the worst case run time is $\Theta(n^2)$?"
To me, the only difference is that when we say $O(n^2)$, the function may also be $O(n)$, we do not know. But when we say $\Theta(n^2)$, we know for a fact the function is $O(n^2)$... |
I was reading through Sipser's "Introduction to the Theory of Computation" and in it, he states that all computational models with unrestricted access to unlimited memory are "equivalent in power, so long as they satisfy reasonable requirements". He gives the example of an requirement which is that only a finite amount... |
I have the following slide in my notes and I'm having trouble understanding how the three assertions are equivalent. I understand to a degree how the 2nd and 3rd assertions are equivalent, but the equivalence between the 1st and 3rd as well as the 1st and 2nd isn't really explained well here. Am I missing something? Is... |
I'm looking for a data structure to help me solve the following problems:
EDIT: This describes a skyline query.
Given a set of points (x,y), find the subset of points where if you order strictly increasing by one dimension, we only take points that are also strictly increasing in the other dimension.
We must be able to... |
DOI: 10.3390/e24070884 provides pseudocode for computing the assembly index of an object. It is written as recursive algorithm, which might be fine. But I would like to implement an iterative version of this in Python which has a recursion depth limit. Although this limit can be changed within a given program, an itera... |
I have a problem in a Data Structures course I am taking. The question is as follows:
Given a number of variables $x_1,\dots,x_n$ and given $m$ equality and inequality constraints (in total $m$ constraints). Find if there exists a valid assignment that satisfies all constraints in $O((m+n)\log^*n)$ and in $O(m+n)$.
For... |
I have a pathfinding project and I want to use Kruskal's algorithm as a maze generator. I am using a rank-based disjoint set data structure to detect cycles, which seems to be the standard way.
However, the mazes that I generate cannot be solved. Which leads me to think that there might be something wrong with my imple... |
Roots of unity are trivial to find numerically--just evaluate $sin$ and $cos$ to whatever precision you require. But suppose (because it's true) that I want exact algebraic representations for symbolic manipulation.
Well, I could cheat and use polar form, and store exact algebraic representations of the magnitude and a... |
Recently, my girlfriend and I were trying to get out of the house, when I encountered a phenomenon which I thought might be analogous to a tradeoff in concurrent systems.
Here's the real world setup.
Processes
Process A: Girlfriend orders coffee on phone.
Process B: Girlfriend gets ready at apartment, and ideally driv... |
I've seen some questions regarding the regularity of prefix language of non-regular languages (for examples, here and here). In both cases, the prefix language ended up just being the whole set of words $\Sigma^*$, for $\Sigma$ the alphabet over which the languages are defined.
So I was thinking of examples where $\mat... |
Is there an algorithm for enumerating a sequence of minimal-length substrings composed of terminal symbols within some CFG which are not substrings of any string in the language defined by that CFG? In other words, given a CFG, $G=(V,\Sigma ,R,S)$, find a sequence of increasing-length strings $E = \{e \in \Sigma^+ \mid... |
If I reverse a single edge in a DAG, how can I efficiently propagate the effects of that (e.g. change other edges) such that I don't introduce any cycles by said reversal? Is there a named algorithm for this that I should look up? I see some other questions about reversing an entire DAG; I'm only concerned with a singl... |
Consider the stable marriage problem with $n$ men and $n$ women. Let $A$ and $B$ be two stable matchings, and suppose that we form a new matching $C$ by assigning to each men his favorite partner between the ones he gets in $A$ and $B$. Prove that $C$ is also a stable matching.
This is my attempt. I'm stuck at proving ... |
In other words, if I have 10 arrays each with 10 of the same values but scrambled their order and heapified them all, is it possible to have different results?
|
The wikipedia for even-odd rule says
On a simple curve, the even–odd rule reduces to a decision algorithm for the point in polygon problem.
On a complex polygon, there are clearly false negatives in the holes. For example, the hole in the middle of a pentagram is within the boundary of the polygon, but any ray to the... |
In [1], Corollary 2.3, after proving that HC-k-(n-even) for a fixed k >= 3, the paper says that HC-k-regular being NP Complete is an inmediate consequence of the former.
Where:
HC-k-regular-(n-even) means if the graph has a hamiltonian cycle in a k-regular graph with an even number of nodes.
And HC-k-regular means the ... |
Let $M$ be a collection of elements given in the form of the array such that membership of any element can be done in $O(1)$ time. Which means elements of array $M$ are $\{1,2,\cdots,n\}$ such that $1$ is stored at $M[1]$ and $2$ at $M[2]$ and so on. The goal is to sample an element from the array $M$.
Note that we hav... |
I've learned that finite automata doesn't have memory and hence languages, where there are comparison within the string, can't be considered regular.
In our university there was a question where the following language was considered as regular in the solutions:
$\{WXW^R | W,X ∈ \{0,1\}^*\}$
here, $W^R$ is the reverse o... |
I have a question for my thesis research, but I am not able to find proof of this. Does anyone have any idea on what should be approach be in order to prove this?
Question: Prove that L1 ∪ L2 ⊆ L1L2, if λ ∈ L1 ∩ L2
|
I'm just a beginner, I've started learning programming, CS, math, and Unix. I know how to code in Pascal and also study C.
In the university a professional programmer, who teaches coding, said that literally everything in C is a side effect.
Accessing a volatile object, modifying an object, modifying a file, or callin... |
Suppose we want to prove by induction that $f(n) \in \Theta(g(n))$. How should the induction proof be set up? I'm tempted to say that the base case should prove that $f(1) \in \Theta(g(1))$ and the inductive step should be to prove that if $f(k) \in \Theta(g(k))$ for some $k\in\mathbb N$, then $f(k+1) \in \Theta(g(k+1)... |
Trying to solve the recurrence, but no clue how to deal with the (loglogn)^2 part
|
Fano's inequality says the following:
Theorem: Let $X$ be a random variable with range $M$. Let $\hat{X} = g(Y)$ be the predicted value of $X$ given some transmitted value $Y$, where $g$ is a deterministic function. Let $p_e$ be the probability of making a mistake, i.e., $p_e = Pr[ \hat{X} \ne X ]$. Then $p_e \ge \fra... |
I'm interested in characterizing the complexity of a decision problem related to path planning. For instance, consider the following problem: Given the current location and battery charge of an outdoor robot, does a trajectory exist such that the robot reaches a goal region without running out of energy?
I assume the ... |
I want to find the slope of the building with respect to the ground which means that I need to find how tilted is the building with respect to the ground through computer vision or any other techniques?
|
There is a relational schema :-
person (id, name, phone no, address, email, position)
so there will be the following functional dependencies
FD1:id, phone no, email -> name, address, position
FD2:id -> name, address, position, phone no, email
FD3:phone no -> id, address, position, name, email
FD4:email -> id, address,... |
I was told that search algorithm such as IDA* or Beam Search with any inadmissible heuristic is not guaranteed to find a solution. Can someone explain why that is the case? I was thinking sure the solution may not be optimal as the agent is too pessimistic to try out a potentially optimal path, but as least it will try... |
There is a counter that counts the number of items in the store. For every increase in item or item that has been inserted, the cost is a + kb where k is the number of digits that has been changed in the counter. For example, from 2999 to 3000 we have a + 4b as 4 digits has been changed and from 999 to 1000, we also ha... |
flag=true
for x=1 to n do
{
for i=1 to n do
{
for j=1 to n do
{
if flag=true then
{
for m=1 to k do
{
for l=1 to k do
{
some statements.... taking constant time
}
}
}
some other statements....taking constant time
... |
Considering the runtime analysis (with the master theorem) of the function below
$T(n) = 12T(\frac{n}{4}) + 2\sqrt{n} + \log^4(n)$.
As I could not figure out a way to get the equation in the form $T(n)=aT(\frac{n}{b}) + \theta(n^d)$, I aimed to get the equation in the form of $T(n)=aT(\frac{n}{b})+\theta(n^k\log^pn)$ ... |
Grinding through leetcode, I came across the question of the number of binary tree topologies for n nodes.
When looking up the best solutions, I saw the same line of code in each solution:
numberOfTrees += numberOfLeftTrees * numberOfRightTrees;
Why is the number of left and right trees multiplied together?
Whole solu... |
The Total number of comparisons for the worst case in the "Brute-Force String Matching" algorithm is: (n-m+1) where n = lenght of string and where m = length of pattern, that all makes sense to me except I want to be SURE my understanding of the +1 is correct. Let me set up an example first:
n = "four"
m = "it"
So we c... |
Consider an algorithm that is tasked with searching the array A. Let n be the size of the array, let i be a random number between 1 and n. Finally, k is the target object we are searching for. If A[i] = k, we have a match. If A[i] != k, we pick a new random i. The algorithm terminates when we have established a match o... |
I'm developing a functional programming language that offers Rank-n polymorphism. Like Haskell I don't want types to appear at the term level, but I have no idea to insert type abstraction and type application in a term afterward.
For example, identity function is defined like below in Haskell.
id :: forall a. a -> a
i... |
I'm newbie in algorithm time complexity.
I had a function, f(n) = 2n2 - 4n.
I have to proof that f(n) = O(n2).
We can take it like this:
f(n) = 2n2 - 4n
$\le$ 2n2 + n2 $\le$ 3n2
What if I just omit the -4n? Because, 0 is the upper bound of -4n? So, it becomes like:
f(n) = 2n2 - 4n
$\le$ 2n2 + 0 $\le$ 2n2
|
Today in my algorithms class, my professor explained how in divide and conquer algorithms we do things in "parallel" although I felt it was not exactly in parallel. Then I remembered from OS the fork() system call that creates literally another child process and computes in parallel with the parent process. Can we comb... |
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 com... |
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 defined as... |
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) that to do this we have to create a new block with the updated data and the pre... |
In divide-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$ and $b$, as well as by the question of how to find $f(n)$. The textbooks could not help me. In exercises, one usually gives this data and asks about the runtime. The ... |
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 the c... |
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$ values... |
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 ... |
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 $G$ with vertex set $V$. If $G$ is weighted, $\omega(u,v)$ denotes the weight of the edg... |
(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 informat... |
I have always assumed that "Linked List" is something in the lines of
struct Node
{
SomeClass payload;
Node * next = nullptr;
Node * prev = nullptr;
}
This implies the restriction of working with objects of only one type. Considering lists are horrible in access time I doubt anyone really constructs them o... |
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.