instruction
stringlengths
35
29.1k
I was going through MST(minimum spanning tree) algorithms in a given undirected graph. By using the disjoint data structure It is fairly easy. All I have to do follow these steps: Sort the edges as per there edge weights. O(ElogE) And then select edges one by an check by the union and find algorithm if they form a cyc...
Safe programming languages (PL) are gaining popularity. What is the formal definition of safe PL? For example, C is not safe, but Java is safe. I suspect that the property “safe” should be applied to a PL implementation rather than to the PL itself. If so, how do we define what is a safe PL implementation?
Consider the volume "The Princeton Companion to Mathematics" which has the broadest range of topics attempted by any book in the field. Does a Computer Science counterpart exist?
I have an image-based processing module that takes photos for some computer vision processing. I have many videos, but I need to sample representative frames as its inputs, preferably those frames with higher attention. What are some good and effective algorithms or approaches to take K sample frames in a video? Intere...
I have a set of strings that are slices of a single, longer string. It is not guaranteed, however, that any two strings from this set must overlap: only that all of them together overlap. I want to reconstruct the original longer string. For example, suppose the longer string is LGHFDJGHSJGHDFKSJBSFSHJKADGHS. The slice...
I have a scenario, in which I have m independent jobs to be schedule on n workers parallely. Time required by each of these jobs is known. The problem is how to distribute these m independent jobs such that the total run time of completion of all the m jobs by the n workers is minimum. One ad-hoc greedy approach I can ...
How to prove that "EXPtime contains PSPACE"?
For example: This looks like a context free grammar: → → | → | → | c but it can be reduced to this regular language: → | → | → | c I want to know if it is possible or not and why
I've been reading about how the kernel manages memory in x86 from this popular blog post(https://manybutfinite.com/post/how-the-kernel-manages-your-memory/) and had a few questions. There is a part where the author describes page table entries and their associated fields. To quote "This lack of a PTE no-execute flag i...
I am currently reading the proof presented in Sipser's "Theory of Computation" for the undecidability of the problem of checking whether the language accepted by a linear bounded automata is empty. In this proof, a contradiction is derived via a reduction from the problem of checking whether a Turing machine, $M$ accep...
Determine the worst-case complexity (in number of comparisons of two array elements) that allow you to conclude that a given array with n elements is not sorted. I sort of have a general idea of what is going on. Suppose I have two element array, then make one comparison between these two elements. If I have three elem...
How is program counter(PC) incremented when instruction takes more than one word? How does PC know when to increment by one word or by more than one word since incrementation is done before decoding the instruction(if I am correct)?
I am reading the lecture notes and have a question. I am trying to understand the beginning of Section 3 on page 2. Problem: Given an input stream $\sigma$, compute (or approximate) its length $m$. Naive solution: $O(\log m)$ bits, exact solution. I don't understand why it is not $O(m)$ bits but $O(\log m)$ bits. Any ...
How to convert the following statement with the existential quantifier to statement with universal quantifier? $\exists n. n>1\rightarrow x(n)\not=1$ Please give me some suggestion?
I know how to find odd length cycles(a bipartite graph cannot have odd cycles) but I cannot manage to make an algorithm when considering even length cycles.
I am reading the lecture notes. I am trying to understand Morris' algorithm on page 2. The Morris' algorithm is as follows. Problem: Given an input stream $\sigma$, compute (or approximate) its length $m$. Initial: $X=0$ For each item in the stream, increment $X$ with probability $\frac{1}{2^X}$. Output: $2^X-1$. ...
I am wondering if the second Quantum Fourier Transform (QFT) in Shor's algorithm is necessary. I am probably missing a point but it seems that an offset elimination function would suffice to determine the period? QFT eliminates the offset value and it changes the period from r to M/r, where M is a sufficiently large va...
Assume a computer architecture with 32 bit address.The system has been designed with 1MB cache which comes with 64KB cache line(cache block size). 1.What is the maximum main memory capacity this system can have? Since computer architecture is 32 bit does it mean word size is 4 bytes?am i correct? Words in one cahce lin...
We define the following problem as: Let $M$ be a TM with alphabet $\Gamma$, with $\{a,b,$ #$\} \subset \Gamma$. We define, for every natural number $n$ the graph $G_{M,n}$ by: $V_{M,n} = \{a,b\}^n$, the vertices $E_{M,n} = \{(x,y) : x,y \in V_{M,n} $ and $M$ accepts the string $x$#$y$ with a run that requires at most ...
What is the difference between min heap and max heap? is it possible to shuffle the elements during insertion time? If so then how come the complexity is logn
I am struggling to understand why linked lists seem to be accepted to have better big-O performance than arrays for in-middle insertion/deletion. The performance differences between lists and arrays for front-of and end-of operations make sense intuitively, but for operations in the middle, not so much. I see why the m...
When playing Terra Mystica, it might be useful to predict how many spades you will get throughout the game, and use this information to decide where to build, such that you stand a good chance of having the longest network. Let's abstract that into the following problem: Let a graph $G$ be given, $G = (V, E)$. Associa...
A Verifier for a language $A$ is an algorithm $V$ such that $$A=\left\{ w \space | V \space \text{accepts} \space \langle w,c\rangle \space\text{for}\space \text{some} \space \text{string} \space c\right\}.$$ My question about this definition is what is this string $c$ stands for? Let's say I have a graph and I wan...
I have three different cases of non-deterministic turing machine. The first machine has: Branch "accept" and branch "loop". The second has: Branch "rejecte" & branch "loop". Third has: Three branchs "rejecte" "loop" "accept". The question is which machines will rejecte and which ones will accept and which ones will en...
I know that it doesn’t have to be balanced so in theory given that the height of the tree is $h$, the minimal number of nodes is obtained when each node has 1 key and 1 child, and since the first level "doesn’t count" in the height, I should have $h+1$ nodes. The maximal number of nodes in a $M-way- tree$ should be ...
My question is a very basic one. It seems feasible to believe that $\mathsf{P = NP}$, because there is some "pathological" good algorithm for SAT, yet it is impossible to prove that the algorithm is actually correct and/or that it runs in polynomial time, in a standard axiomatic system like ZFC. Let's fix a logic $L$ t...
I am trying to find an algorithm which calculates an optimal and stable allocation of $n$ students to $m$ projects, where each student strictly ranks all projects by preference. The available projects are predetermined and of fixed number and each student needs to be allocated to exactly one project. Each project needs...
Is the field of theoretical computer science so complex, that it is just "too much" for a bachelor thesis? Unfortunately I haven't found any old thesises because the relevant chair of the university hasn't been occupied for years. Because of theoretical computer science is the only topic that really interests me, I tho...
So I have sets of functions $A$, $B$, $C$, $D$, $E$, and $F$. I want to run them in a nested way. I also want to run some of them in parallel, and some of them in sequence. Here is how that might look: In Parallel A { In Sequence B { In Parallel C { In Sequence D { In Parallel E { In Seque...
Can someone explain to me what this statement implies? I am assuming that it means that a string consisting of three characters repeated. What I don't understand is if the repeated string is all 0s or all 1s or both? Give the state diagram of a machine (any Turing-Complete model) that decides the following languages ov...
According to the wiki page of TSP as a graph problem, It is a minimization problem starting and finishing at a specified vertex after having visited each other vertex exactly once Then what if a triangle is given, with two edges weighed $1$ and the third weighed $100$,obviously, the shortest path to visit all three ...
"Assume a system with 4 GB virtual memory and 1 GB physical memory with 32 bit addresses. if the page size is 4 KB, How many bits will be allocated as the Higher Order Address bits and Lower Order Address bits to identify page numbers and corresponding words respectively?" My question is, What does "higher order addres...
I've got a problem at hand that's about scheduling tasks to different ressources, basically a simple job shop problem. But: my tasks "branch" dynamically, that is, there are tasks that not only have a start time parameter but also a parameter that defines how many independently scheduled series of tasks the task shall ...
Knowing how a Universal Turing Machines works and its capabilities, is it possible to obtain the collection M = {M0 , M1 , M2 , M3, … } of all possible Turing Machines? If so, can we prove that a language L = {wj |wj not accepted by Mj } is not accepted by the Universal Turing Machine?
The Hessian of multi-layered network exhibits known behaviour at critical points as shown in [1]. The tools of random matrix theory allow [2] to deduce the asymptotic distribution of the eigenvalues of the Hessian. There are some numerical experiments with distributed Newton type stochastic methods. The scalability (ab...
Are there any non-trivial functions in TC1? Apart from that are there functions which are known to be in NC2 but not in TC1?
Let $\mathcal{L}$ be a loss function associated with a multi-layered neural network. So it seems almost everyone in AI/ML community is interested in the Hessian $H=\partial^2 \mathcal{L}$ of $\mathcal{L}$. So if you read [1] on page 193 the left colum you find the following text "An important question concerns the di...
Let $T=(V,E)$ be a tree rooted in $r$ and let $L$ denotes the set of leaves of $T$. For a given $v \in V$, let $C(v)$ be the out-neighors of $v$ i.e. its children in $T$ and $p(v)$ be its in-neighbor i.e. its predecessor in $T$. We have a metric $d : V \times V \rightarrow \mathbb{R}^+$ (respecting the triangular inequ...
My professor uses the term "clean graph" to mean that the nodes have no idea of the topology. Each node is aware of its ID, but has no idea about parents or edges and so on and it has to discover. Is this terminology a thing? Because I find no evidence in the internet. Is there another term for the same thing?
A basic question about the connection between two notions. I am sure these are known notions in CS but I struggle with the basics: First Definition: A probabilistic algorithm $A(n)$ decides $L$ if for every $x \in L$, it holds that $\Pr(A(x) = 1) \geq 1 - \epsilon$, and for every $x \notin L, \Pr (A(x) = 0) \leq \delta...
Is there a good survey or some papers with algorithms in the Turing machine model? I know the paper STRING-MATCHING AND OTHER PRODUCTS contains Turing Machine version of KMP. Are there any other such papers?
Consider the following problem: let $(U \cup V, E)$ be a bipartite graph. Is it possible to label the vertices of $U$ with either $``+"$ or $``-"$ such that every vertex of $V$ is adjacent to a vertex labeled $+$ and a vertex labeled $-$? This seems like a pretty natural problem, and I would be surprised if it hasn't b...
Polynomial Interpolation in the general case is $O(n^2)$ time complexity, but it can be done better in particular situations. For instance, when the polynomial can be evaluated at the complex roots of unity, it can be interpolated in $O(n\log n)$ time with the Fast Fourier Transform. Or at least, that's the only situat...
This question is about how to create an if statement (one of the control-flow statements) from scratch. An if-statement is typically a built-in construct in languages. However, I am wondering if there is a way to construct an if-statement from some other non-control-flow primitives. I am also wondering how to do this w...
This question concerns the time complexity of outputting the unions of subsets of a given set. Given $m$ subsets of an $k$-element set, can the union of those sets be computed in linear time with respect to $m+k$? Or $(m+k)p(\log (m+k))$, where $p(x)$ is some polynomial? Or at least known is there a subquadratic al...
How will the value, A(2) be available in, line 2, if A(2) is being calculated in, line 3?
I think I have quite a good understanding of string algorithms. However, a couple of days ago, I came across this post: Find all pairs of strings in a set with Levenshtein distance < d I was wondering, whether there are more string algorithms which do not have good worst-case guarantees but are good in practice. I gues...
I am going through Professor Skiena's textbook and he says that there are 3 types of cut-nodes - root, bridge cut node, and parent cut node. Now if the earliest reachable ancestor from a node is itself, it's parent and the node (if not leaf) become bridge cut nodes. My question is that we have a simple 2-node undirecte...
Yesterday at work I came across an interesting problem that I wasn't able to figure how to structure properly. I'm relatively new to the field and was wondering if I could get some help around here. What i have here is a table like this: |1-2| 3-5 | 6+ | ($) ________________ | ...
Given $\\N$ points in 2D space, one is required to cluster them into $\\M$ clusters, with each cluster of a given size $\\S_m$ such that $\sum S_m = N$, in order to minimize the sum of the distance of the points from centroid of their respective cluster. The clusters (or call them bins) are to be filled completely. Una...
According to Turing thesis, Can we say all programming languages that support turing machine like C have same power for solving problems and performing algorithms? In other words is there any algorithm or problem that one of them can solve it and the other can't?
How do I fill a truth table from the following expression? I can't decide whether it is SOP or POS. Y=(A+B)C+AB`+(A+C)C`+(`AB)
If I have a turing machime TM, can I recognize end of input on the tape? I know that the "end of input" in a turing machine is signaled with a special character, $\sqcup$. Can I do this - Let $TM$ be a turing machine. Until we reach the first $\sqcup$, continue. If we reached $\sqcup$, replace it with a special charac...
I've recently come across the problem that seems to be quite interesting but i don't know how to tackle it. I suppose that it might be a special case of maximum flow problem but it seems to be rather different so i need an advice. Suppose that we have a weighted directed graph with two (possibly the same) vertices desi...
I am reading a paper on sparse matrices and there is an algorithm for sparse lower triangular systems. In the below pseudo-code $l$ is a sparse matrix and $x,b$ are sparse vectors. x=b for j=0 to n-1 do if x[j] != 0 for i=j+1 to n-1 do if l[i][j] != 0 ~5 operations. The paper cl...
I think I barely understand the usefulness of asymptotic notations. And I came across small o and I want to prove that statement is true. But I have no idea how to start. Those are 2 extra problems with the same idea : Prove that 1000.n^2+ 1000.n ≠ o(n^2) And Prove that 5.n + 10 ≠ o(n) Note: someone marked this questi...
I want to write a scheduling algorithm for the following scenario: There is a set of tasks to complete, each one with a due date, difficulty (easy, normal, hard) and progress on the task. The idea is that the user specifies the amount of daily hours available to work on tasks, so the algorithm can create a weekly sched...
Asume 512 Bytes direct-mapped cache with 64 Byte cache blocks (cache line size), is empty at the beginning and below given set of physical addresses are referred by CPU in the given order. At each physical address request, state whether it will be a cache hit or miss in the given cages. Note that all the addresses are ...
I have a reasonably smooth non-convex non-monotone function in high(ish) dimensional space, that I wish to find a local minimizer for, over a convex feasible region (the intersection of a ball with a set of halfspaces, so a "wedge" of the ball or a polytope), with the caveat that I want the minimizer to be away from th...
Is there a way to convert a 3SAT formula into a equisatisfiable 2SAT formula? Each method is of interest, even those that grow exponentially. (So if, for example, my 3SAT formula has 16 variables and 32 clauses, a transformed 2SAT formula would have 2ˆ16 variables and / or 2ˆ32 clauses) An example of a 3SAT formula I w...
In ciruclar queue the following command statement is very useful to use the determine the unused location. What is its importance? I know that without this line it won't be a circular queue. But how to say it in theoretical way? rear=(rear+1)%max
I am interested in collecting the list of the classifiers that (depending on their setting) can have linear time complexity (both in training and testing step) with respect to the number of samples $n$, the number of features of each sample $m$, and the number of classes $c$. In other words, I am seeking for a list of ...
For example in the definition of $\Theta$: $f(n) = \Theta(g(n)$ if there exist positive constants $c_1, c_2$ and $n_0$ such that $$ 0 \leq c_1 \cdot g(n) \leq f(n) \leq c_2 \cdot g(n) \text{ for all } n \geq n_0. $$ I was scratching my head for two weeks since we took this definition in class. Why do we need this c...
In this post someone said: $n + 1$ is approximately equal to 1 for $2^{n+1} = O(2^n)$. I don't understand this point. For example, in this example: $$ n + 1 \leq c \cdot n $$ for some $c$ and some $n \geq n_0$, the right-hand side will always be at least the left-hand side. But here: $$ 2^{n+1} =O(2^n)$$ the left-...
I have noticed that for all the matrices representing quantum gates, if we read rows left-to-right and top to bottom, the read the same as columns top to bottom left to right. Example: \begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & 1& 0 \end{pmatrix} (CNOT gate), if we read the values in from...
I am confused whether space complexity of a recursive algorithm depends on the total number of recursive calls or not. Say I have an algorithm which has exponential function calls, but stack size is linear, so in that case we can say that space complexity is not proportional to number of recursive calls but if we say t...
Seriously why do we consider how the computation time time increase with the number of inputs as a measure of performance when we can easily measure such as program execution time,power consumption,memory usage etc?Because all of these facts are depends on the hardware and programming language we use in that moment an...
What is the meaning of in place and out place in sorting? What are the difference of two of them? Couldn't find any good explanation in the internet.
What is nature of difference of regular language and context free language? My guess is RL - CFL = RL CFL - RL = CFL Am I correct with this?
I want to make the following reduction: HP is the Halting Problem: HP = {w#x | w, x ∈ {0,1}* , Mw halts on input x} w is the binary coded turing machine Mw. L3 is the problem which asks, if M accepts exactly 3 inputs. I know HP is not decidable, so I want to show that L3 is not decidable also: HP ≤ L3 How can I make t...
In Haskell you find graphs defined like this: data Graph a = GNode a (Graph a) Or this: data Graph a = Empty | Vertex a | Overlay (Graph a) (Graph a) | Connect (Graph a) (Graph a) class Graph g where type Vertex g empty :: g vertex :: Vertex g -> g overlay :: g -> g -> g connect :: g -> g -> g Or this: ...
Question about "Artificial Intelligence: A Modern Approach by Russell and Norvig" I have issue to distinguish clearly between intelligent and rational agent presented by Norvig and Russel. What I understand is that rational agent think and act like human but not intelligent agent. Thus, Russel present 4 types of intell...
If given a grammar, for example, a context-sensitive (type 1) can it always be "reduced" to a equivalent context-free grammar (type 2) and so on for grammars type 2 to "reducing" and getting a type 3? How can I prove or show that this is undecidable? (if this is the case) I know that is undecidable whether a context-fr...
What is the state diagram of a DFA that follows $L = \{w \in \{0,1\}^*\mid w\text{ has at least two or more 1's than of 0's}\}$. Examples: $110$ doesn't work, $1110$ works.
I'm learning computer graphics, and I read this course lecture in order to understand how graphics I/O works under the hood. But the following explanation was not very clear to me: The values in the framebuffer are converted from a digital (1s and 0s representation, the bits) to an analog signal that goes out to the...
If we have two languages $L_{1} \subseteq \Sigma^{\ast}_{1}$ and $L_{2} \subseteq \Sigma^{\ast}_{2}$ I proved that when $L_{2} \in \textbf{P}$ and $L_{1} \leq_{p} L_{2}$ then $L_{1} \in \textbf{P}$ Is it also true that when $L_{2} \notin \textbf{P}$ and $L_{1} \leq_{p} L_{2}$ then $L_{1} \notin \textbf{P}$? I don't ...
What are acceptable languages in computational complexity? Is it Turing recognizable? I was searching online and found this description. Does anyone beg to differ?
I'm interested in studying the problem of the optimal meeting point, which can be described as follow: $n$ individuals who want to gather in a restaurant (for example). They want a fair meeting point and to minimize the time/distance for everyone. I'm looking for information on that problem, but I've only been able to ...
I was trying to understand the egg dropping puzzle. The problem objective is: What strategy should you adopt to minimize the number egg drops it takes to find the solution?. (And what is the worst case for the number of drops it will take?) I understand we want to minimize the egg drops, but what does this worst case n...
I have the following problem. If L is decidable and L = L1 u L2 (union). So are L1 and L2 decidable, too? I know that, if L is decidable, the complement is also. And this means the complement is recursively enumerable. How can I proof it?
Wondering if/how you could define a highly nested structure as a Dependent Type (or an Algebraic or Parameterized type). Specifically, an HTML template. Not that they work like this (HTML templates don't have variables to plug in), but imagine a template like this: <template id="MyTemplate"> <section> <header> ...
Consider a particular algorithm that solves the binary search problem (or similar stuff) by performing $\sqrt{n}$ simple operations on numbers of $\log(n)$ bits. Suppose this algorithm works on a Word Ram machine with word size $w=\log(n)$. What happens if the algorithm uses a memory area with $n$ numbers that are not ...
How to get upper, lower, average bound of given algorithm? What should be the first step I should do? I search on the internet and only give me the definition of those 3. For example if take the algorithm of nlog(n)+2 then how do we find the lower and upper bound of this? What would be the first step?
I work at a summer camp where one of the activities is called Speed Dating. It's a game where participants talk with each other for a fixed amount of time. At the end everyone has to list three people they liked the most. I'm looking for an algorithm that would match participants based on their preferences. It seems li...
In a binary system we know that the next floating point number after 4 is 4+1/32. What is the machine epsilon? Is it 1/32 and if yes, why?
In a report on an open-source separation kernel (Muen kernel) I was reading, in the future work section, it says that cache coloring can be implemented to prevent covert/side-channel attacks. It is mentioned that In a second step each subject is associated with a color. All subjects of a given color share the same cac...
I am going from an IT minor to a Computer Science major. I made this decision because I love computers, I love the science behind them and I love learning most of all. My graduate research thesis is related to Artificial Intellligence. However, I feel slightly overwhelmed. Although I did have some math in my IT minor, ...
In the Foundations chapter of Elements of Programming (Stepanov and McJones, 2009), this paragraph appears: A value type is properly partial if its values represent a proper subset of the abstract entities in the corresponding species; otherwise it is total. For example, the type int is properly partial, while the typ...
Say we have an algorithm that takes an input a triple ($X$, $A$, $\epsilon$), where $X$ is a sequence of $n$ bytes, of which the algorithm might query only a subset, and $A$ and $\epsilon$ are numbers with $A \geq 1$ and $\epsilon > 0$. It is claimed that this algorithm runs in time $$ \tilde{O}(\frac{n}{A^3 \epsilon...
Assume also that $v_1,v_2$ are linearly independent, and $q_i \in \mathbb{R}^n$ denotes the $i$-th column of $Q$. This is what I've got so far. First obtain unit vectors $w_1,w_2$ which are orthogonal and $span\{w_1,w_2\} = span\{v_1,v_2\}$. Now compute a Householder matrix $H$ that aligns $w_1$ with $e_1$, i.e. $Hw_1 ...
In dynamo paper, it says that in production most of the users set N = 3, R = 2 and W = 2. The common (N,R,W) configuration used by several instances of Dynamo is (3,2,2). These values are chosen to meet the necessary levels of performance, durability, consistency, and availability SLAs. In most production system, N =...
One of the ways to prove that Graham Scan constructs convex hull in linear time is using planarity of the graph obtained by running the algorithm. This graph is always planar, so according to Euler's formula the number of edges can never be more than $3*n$ (where $n$ is the number of vertices). My question is, how do w...
Given a nonlinear cost function $G(\vec{x})$ of many variables, does there exist a method that allows one to find successive local minima $\vec{x}_0, \vec{x}_1, \dots$ so that $\vec{x}_n$ is orthogonal to $\vec{x}_{n-1}, \vec{x}_{n-2}, \dots, \vec{x}_0$? Sorry for the apparent lack of effort on my part, but the field o...
Assume we need to include a certain set of nodes in the tree within the whole graph, the generated tree can contain nodes other than the specified set of nodes. We also need the number of edges (or the total amount of edge weight) included in the tree is minimum.
I use Latin hypercube sampling to select what point to evaluate my function. As evaluations take a lot of time, I want to limit the time by adding already evaluated points. I thought about taking the min distance between the points, and if I have an already evaluated point that is near on LHS point, I remove the LHS to...
I have a task where a RAID 1+0 system (A RAID 0 connects two RAID 1's with two disks each = makes 4 disks in total) is given with no further details. Then let p be the probability that one disk shows signs of failure. The variable p is not further defined. Now I've received the task to calculate the probability that th...
We know that $\mathsf{DSPACE}(\log\log n) = \mathsf{DSPACE}(1)$ according to this proof. Can we claim that $\mathsf{DSPACE}(n)=\mathsf{DSPACE}(n/\log\log n)$ or something like $\mathsf{DSPACE}(n^3)=\mathsf{DSPACE}(n^3/(\log\log n)^k)$ for some $k\in \mathbb{N} $?
If a term rewriting system is confluent, then every term has at most one normal form. Is the converse also true, or is confluence a strictly stronger property? I.e. if every term has at most one normal form, does the rewriting system need to be confluent? My intuition is that the answer is no; for example, it seems to ...
I am aware of following two facts related to two concepts: regular languages and finite sets: Regular languages are not closed under subset and proper subset operations. It is decidable whether given regular language is finite or not. However I feel these facts are quite insufficient to prove whether following stat...
We are given a set of $n$ numbers and want to know whether it can be partitioned to two sets with an equal sum. To prove that an equal partition exists, it is sufficient to show a partition. What is the shortest way to prove that an equal partition does NOT exist? Apparently the only way to prove it is to show all the ...