instruction
stringlengths
35
11.4k
This is the so-called recursive style: And this is the so-called iterative style: It seems like it is defined recursively to me. The function doesn't hide the next call of the function defined in it at all. (SICP 95)
Suppose we are given a matrix $A$ over real numbers and we want to computer the inverse of matrix $A$. There are various algorithms to do so and it also turn out that we can use matrix multiplication problem to solve matrix inversion problem. My question: How to prove that matrix inversion is at least as hard as matr...
Nodes A and B are accessing a shared medium using CSMA/CD, with a propagation delay of 245-bit times between them (i.e., propagation delay equals the amount of time to transmit 245 bits). The minimum frame size is 64 bytes. Suppose node begins transmitting a frame at = 0 bit time. Before A finishes, node B begins tra...
Assuming that the worst case running time of merge sort can be described with this recurrence: $\ T(n) = \begin{cases} \theta(1) & \text{if }n = 1\\ 2T(\frac{n}{2}) + \theta(n) & \text{if } n\gt 1 \end{cases} $ Introduction to Algorithms says that it is possible for the same constant $\ c $ to represent th...
Consider the following generalization of maximum set cover problem: Given a collection $C$ of subsets of a finite set $S$. Find $C^{'} \subseteq C$ of cardinality $k$ that maximizes \[ \sum\limits_{s \in S} f(s, C^{'}) \] For example: If $f(s, C^{'})=\begin{cases}1 & \exists c \in C^{'}, s \in c \\ 0 & \text{otherwise...
I remember using a simulated machine with with a minimal instruction set in university. In particular I remember that the instruction that consisted of all zeroes loaded was a LOAD instruction. So, if you made a mistake and began executing empty memory then it would simply keep executing until it ran out of address spa...
The computational complexity of primality testing is usually specified in relation to the bit length of the number being tested. However, Mersenne numbers have the special property that the characterizing instance exponent $p$ is exponentially more succinct than the number it signifies. Surprisingly, most of the litera...
Can epsilon be in the input alphabet of an FST ?
Given is the NFA N: What's the language of this NFA? What's its complement? I'm learning for a test and I'd like to know if I solved this task correctly. The language L of the NFA N should look like this: L(N) = {x ∈ Σ* | x mustn't include 'aba' and x mustn't end with 'ab'} I have tried several different words and I...
In The Temporal Logic of Programs there is an operator first appearing on page 3 (48) under "Partial Correctness" that looks like an elongated super set symbol. What is it?
Problem: Given a vectors of size $n$ with integer data within $[1, n-1]$ range, find $if$ and $which$ numbers are multiple duplicates (numbers appearing more than once). The time complexity ought to be linear and space complexity constant (don't use any auxiliary data structure except the input vector and variables) a...
Is it possible to build a parsing algorithm that build a parse tree using a top-down method that simulate a derivation process for regular expressions, like we do for type 2 languages? My guess Given a regular expression r, build its FSA, then obtain the grammar that generate r in order to build a parse tree
Consider a job schedule decision problem with only one machine takes input $\{(r_1,p_1,d_1),(r_2,p_2,d_2),...,(r_n,p_n,d_n),K\}$; where $r_i$ is the start time for the ith triple, and $p_i$ is the process time of the triple; and $d_i$ is the deadline.Require for each $i$, schedule a job at time $t_i$ such that $r_i≤t_i...
Assuming I have two 0-1 decision variables X[a,b] and Y[i,j,e,d] where : X[a,b] = 1 if a is in b 0 otherwise Y[i,j,e,d] = 1 if (i,j) is matched with (e,d) 0 otherwise. I need to ensure that if two elements say k and l are both in f respectively i.e X[k,f] == 1 and X[l,f]==1 then no matching i.e for each (e,d) Y[k,l,e...
I'm familiar with the idea of basic tail recursion elimination, where functions that return the direct result of a call to themselves can be rewritten as iterative loops. foo(...): # ... return foo(...) I also understand that, as a special case, the function can still be rewritten if the recursive call is wrap...
Given a persistent red-black tree, I've been searching for an algorithm, approach, or equivalent data structure that allows me to efficiently merge two instances of the tree produced by divergent modification of a common ancestor. For instance, tree instances v1 and v2 produced by mutating the common instance v0, are c...
If I'm passing parameters as call by value-return and call a void function, will the local values within the function still be copied to the corresponding values in the caller function even though the called function doesn't return? For example: int x = 4; void foo(int a) { a = 8 + 8; } int main() { foo(x); ...
I'm new to formal language and automata theory and I was left alone with this exercise. The task is to define a formal grammar for given language. $Σ \in \{a,b\}$ $L = \{ w \in Σ^*\, |\, |w| \equiv 2 \mod 3 \} $ I already solved tasks of that kind, but now i struggle to understand what $|w| \equiv 2 \mod 3$ means. $...
Can anyone explain how are conditionals implemented in the CPU? Is special circuitry used?
I'm looking for a finite state machine that can match inputs to the regular expression .*b. deterministically (i.e. it cannot change state w/o being fed input and the transition to a new state is solely determined by the current state and the input word). Consider the following examples that should be matched by the au...
Is it possible to solving simultaneous multiple chinese remainder theorem on the quantum computer? We have $k$ variables. Each variable can take two values. The question is: can we calculate all possible circuits equations chinese remainder theorem (which may be $2^k$) and reduce to the smallest result on a quantum com...
I'm currently working on a few turing machine exercises and I can't understand how I can prove whether the below is at least partially decidable: $\{M \mid L(M) = \{x \mid |x| = 10\}\;\}$ where $|x|$ is the length of word $x$ Can anyone explain to me what the above statement actually means and an idea of how to go abou...
This is sort of a silly question that's been bugging me. I have a list of 100k numbers that I am calculating some statistics for. Specifically, I am computing the mean, minimum, maximum, and sum of these numbers. I'm doing it using a fold. In JavaScript: // define folding functions: let mean = (a, b, index, array) => a...
Given a Mealy machine $M$, is it possible to construct another Mealy machine $M'$ that generates the reverse outputs from the reverse inputs, and if so, how? That is, for each string $s$, $M(s) = t$ iff $M'(s') = t'$, where $s'$ is $s$ reversed and $t'$ is $t$ reversed. For example, if $M(``abcd")$ is $``efgh"$ then $M...
How to define a non ambiguous grammar for regular expressions on the $\Sigma = \{a,b\}$ alphabet? Given that: If $\Theta = \{+, ^*, (,),\cdot, \emptyset\}$ is a set of symbols A regular expression on $\Sigma$ is a string such that one of the following condition applies $r = \emptyset$ $r \in \Sigma $ $r = (s+t)$ or $...
Let's say we have given matrix of size $n \cdot m$, such that both $n, m$ are big numbers and we cannot keep the whole matrix in memory (up to 10 millions). In some of the coordinates of the matrix there are positive numbers and all other fields are zeroes (at most 100000 elements are with value different from 0). For ...
Recently it's been in the headlines that IBM was able to simulate a 56 qubit quantum computer using only 3 TB of memory. This is several thousand times smaller than one would expect the memory requirements of such a simulation to be. How were they able to do this? Did their simulation run correspondingly faster? Does t...
and why? It seem abstract in that it is and idea created and implemented with nodes arranged a certain way. But it did not show up in the text here: https://en.wikipedia.org/wiki/Abstract_data_type Here: https://en.wikipedia.org/wiki/Binary_search_tree they are referred to as data structure b.c. other ADTs can be cr...
Question: Show that every CF grammar G = (V,T,S,P) can be converted into an equivalent CFG in which every production is of the form A → xBC or A → ϵ, where x ∈ T U {ϵ} and A,B, and C are variables. For this question, I have considered that it can be proved by using Greibach Normal Form, because we can get the form: A →...
Given $n$ variables : $a_1,a_2...,a_n$ and $m$ inequalities of the form $a_i<a_j$, we want to know if there's a positioning that satisfies all the inequalities. a. We want to modelize the problem to a directed graph $G=(V,E)$. $V=?,E=?$ $V=\{a_i|i\in[n]\}$ $E=\{a_ia_j|a_i<a_j\}$ b. Complete the sentence: There exist...
I am trying to solve a question from the exercise of this book, pg. 46,section 7.4. Let $M$ be a deterministic Turing machine that only queries oracle strings that are shorter than the input string. Show that if $A = L(M^A)$ and $B = L(M^B)$ then $A = B$. I think I have to apply induction. Does it involve self-reducibi...
How can I solve this? I saw Solving the recurrence $T(n)=T(n-1)*T(n-2)$ but I don't know how I can apply it to $T(n)=T(n-1)/T(n-2)$?
Let there be two sets of $n$ points: $A=\{p_1, p_2, \dots, p_n\}$ on $y=0$ $B=\{q_1, q_2, \dots, q_n\}$ on $y=1$ Each point $p_i$ is connected to its corresponding point $q_i$ to form a line segment. Example: I need to write a divide-and-conquer algorithm which returns the number of intersection points of all $n$ line...
Help is needed, I've tried to solve it by myself but I could find any reasonable solution which is solid enough. this is what I've wrote: Consider a 0-1 ILP, where each variable x1,x2...,xn can assume values 0 or 1. The number of constraints is m. We can choose all possible 2n assignments of x1, x2...xn in non-det...
I tried to make a 4-bit adder, but it ain't working. When I do this: a 0000 b 1111 + _____ s 0101 but s should be 1111! And this is my 1bit-adder: What am I doing wrong? Is it possible to put a0123, and b0123 in just two 4-bit inputs instead of 8 separate inputs?
I have a graph with n edges and m vertices. This is an undirected graph. I need to find a 3 vertex cycle. Only 3. I'm confident I need to use an incidence matrix for this as this seems to be the best data structure. I'm familiar with cycle finding algorithms and they are all in crazy polynomial or even exponential time...
We have two functions: $f_1: \mathbb{N}\rightarrow \mathbb{N} \quad $ $f_2: \mathbb{N}\rightarrow \mathbb{N}$ By definition $f_1$ is turing-computable while $f_2$ is not. Then we define a third funtion $g(n) = f_1(n) + f_2(n)$. I want to show that $g(n)$ is not turing-computable: So first assume that $g(n)$ is computab...
How to prove that the problem VERTEX-COVER belongs to $NP$? The problem VC is defined as follow: INSTANCE: Graph $G = (V,E)$ and an integer $k$ PREDICATE: Is there a subset $V_1 \in V $ s.t $\mid V_1 \mid \leq k $ and $\forall (u,v) \in E $ $u \in V_1 $ or $v \in V_1$ ? My approach: I know that the class $NP$ can b...
My problem is as follow, imagine a complete undirected graph with weighted edges, i would like to extract a connected graph keeping all the vertices and where the edge with the highest weight is the minimum one compared to all others possible configurations. Is there another solution than bruteforce it.
I am reading Theory of Computation by Peter Linz. The transitions for PDA uses $\epsilon$ as end marker for input string. For example if the final state is $q_1$ then the transition is written like $\delta(q_0,\epsilon,z)=(q_1,z)$. Why don't they write the transition as $\delta(q_0,\$,z)=(q_1,z)$.
Given are 2 different languages and I'd like to know if I understand them correctly. L ⊆ ∑* is a regular language. cycle(L) = {vu ∈ ∑* | uv ∈ L} L/2 = {x ∈ ∑* | ∃y ∈ ∑* : xy ∈ L, |x| = |y|} I need to know that because the actual task is to show that these languages are regular by either describing how you build a DFA...
Is there some link between the concept of emergence and Turing Completeness? The ideas feel intuitively like they might be linked, but I can find nothing online. The idea came to me because I was exploring Conway's Game of Life, and it was hard not to suppose a link between these two properties. Edit: In response to R...
Let $f_1 $ and $f_2$ be two functions from $\mathbb{N} \rightarrow \mathbb{N}$. $f_1$ is turing-computable while $f_2$ is not. $h(i)$ is a function that returns $1$ when $f_1(i) = f_2(i)$ and $0$ else. The challenge is to construct $f_1 $ and $f_2$ so that $h(i)$ is computable and additionally so that it is not. My tho...
Is there a difference between the computational complexity and computational cost of an algorithm?
Given a $n \times m$ grid, define a valid coloring as mapping from the grid cells to a set of $k$ available colors such that no two adjacent cells have the same color. Cells are considered as adjacent if they share a side. How many valid colorings are there? Let $f(n, m, k)$ be the answer. I search for a way to compute...
This question is from my complexity theory course. How to change the standard DPLL algorithm for SAT in order to solve 3-SAT instances? The general DPLL algorithm for SAT is defined: Algorithm DPLL Input: A set of clauses Φ. Output: A Truth Value. function DPLL(Φ) if Φ is a consistent set of literals ...
What is the most effective way of finding median from $N$ numbers within given range ? It is guaranted that $N \leq 10^{9}$. The input consists of $L$ lines. Each line consists either of: a) S X , which means store number $X$, where $X \leq 10^{9}$. or b)F X Y, which means find median from stored numbers within ran...
I have some large number $n$ in base $b_1$ and I want to convert it to base $b_2$. $n$ is about a million decimal digits long, therefore it's impractical to convert it as a whole. However I don't need the entire $n$, just some arbitrary slice of it when it's converted to $b_2$ For example converting from base 10 to bas...
Prove that $L = \{\langle M \rangle \mid \langle M \rangle \notin L(M)\}$ is undecidable. Hint: If there were a decider TM DL for L, what would happen if we gave DL its own description as input? Here's what I've got so far: $\mathrm{ATM} ≤_M M$ (with $\leq_M$ being mapping reducible) Find a map : $f: \langle M \rangle ...
Suppose that I have a non-deterministic Turing Machine $M_1$ and its clone $M_2$. Given a string $x \in \Sigma^*$, it is possible that after $t_i$ seconds $M_1$ accepts $x$ and $M_2$ does not halt ? What happens if i run $M_2$ $2t_i$ seconds? My approach It is possible because the transition function $\delta_N$ is a pa...
This questions is taken from a complexity theory course. Design a push-down automaton that recognize $L = x \in \{0,1\}^* $ such that $x$ contains a number of ones double than a number of zeros. Example: x = 011011, 100011111, 011011110. My approach I tried to push on the stack a symbol "A" every time I read "0", t...
I am trying to find out if there is any generic way to find out first to nth best player in a tournament if n is less than the square root of input size i.e. 5 best players in the sample size of 25 players? I thought of using below approach to find out 2 best players. So for finding out the 3rd best player we can use t...
In a game application there is a session id assigned to each player every time they start a new session. Session id's are always unique and there can be billion users of this game. Whenever a user logs-in, get() function is called which basically assigns a bit to the user by setting a bit from a bitarray and when user...
I want to find secrecy rate of a main channel in case of Gaussian broadcast channel. e.g. I have a single transmitter and a receiver where eavesdropper wants to eavesdrop the communication over secondary channel. What will be the information rate, so eavesdropper can be kept ignorant of sent message
This question is from a Computer Theory Course What is the category of languages recognized by a MT with a two-dimensional tape? The Tape is an infinite matrix. For each move the head shift belongs to the set $S$ = {stop, north, east, south, west} My approach I know that TM recognize Recursively Enumerable or type ...
Is there a simple algorithm to check whether $n$ different balls (of the same radius) in $\mathbb{R}^d$ intersect? That is, coordinates of their centers $x_i$ are given, radius $R$ is given and we need to determine if there exists a point $p$ such that $$\| p - x_i \| \leq R \quad \forall i.$$ In other words, check whe...
The top rated answer to Why, really, is the Halting Problem so important? lists a few examples for a noncomputable problem. However, these mostly involve an infinite search space. Are there noncomputable problems with a finite search space? If not, why not?
I am attempting to compute a known sum or closest value to that sum using the multiples of a subset of numbers. In this approach I want to minimize the multiples or coefficient. For instance if I have the number 120 and I have a set of 50s and 20s, I would get 120 = 2*50 + 1*20. The set of numbers can be limited how...
I'm trying to understand the algorithm for implementing semaphores on SMP system using test and set instruction described here: https://people.mpi-sws.org/~druschel/courses/os/lectures/proc4.pdf (and a bunch of similar implementations on the web). Locking semaphore looks like this: void P(Semaphore s) { Disable inter...
You have to arrays of single digit numbers. (0 - 9). A = [....1 billion elements....]; B = [3,5,8,1,2,5,8,3,4,9,1,0,2]; I want to find combo of as few as possible subsets that of array B in A. So whole Array B could be in Array A by coincidence since it's very large and that would be the largest match as whole sequen...
This question was made during a class of Computer Theory in Rome, Italy. Let $G$ be a regular grammar, $\Sigma$ its alphabet and $L(G)$ the language generated by $G$ Given a regular grammar $G$, is $L(G) = \Sigma^*$ a decidable property? My approach I can design a Finite State Automaton that recognize the strings in...
Let combinator $X = \lambda x . x KSK$ as described by Hankin (1994). Then $K = (X X) X$ and $S = X(X X)$. Identity combinator however seems to have much more verbose form. If $I = SKK$ then also $$I = (X(XX))((XX)X)((XX)X)$$ I could possibly make this a bit shorter: $$I = (X (X X)) ((X X) X) X$$ but is this as far as ...
$L \subseteq \Sigma^*$ is a regular language. Show that the following language $L/2 = \{x \in \Sigma^* \mid \exists y \in \Sigma^* : xy \in L, |x| = |y| \}$ is a regular language as well by describing how you change an arbitrary given DFA for $L$ to another DFA or NFA which accepts $L/2$. About $L/2$, it only acce...
Given a stack, what is the minimum amount of swaps needed to sort it? Since the bottom of it stays intact and we slowly move to the upper part of it, if the stack contains n elements, the amount of swaps f(n) would be f(n) < n for n = 1, 2, 3, 4, is that correct? I cannot find a more accurate way to express it. Also...
This question wask asked in a homework of Computer Theory in Rome, Italy. How to simplify the DPLL algorithm in order to solve HORNSAT? My Approach: I know that an Horn clause is an OR of literals where it contains at most one pure literal and any number of negative literals. I would start with the following algorit...
I was reading about $\pi$-calculus, and some authors include in the basic operations a Choice operator $P \oplus Q$ which means that either $P$ or $Q$ will be executed, but not both. On page 8 of "Applied $\pi$ - an introduction" (available on http://www.cl.cam.ac.uk/~pes20/apppi.ps ), the author says that the coice op...
. Matches any single character, * Matches any sequence of characters (including the empty sequence). dict = ["cat", "cats", "and", "sand", "dog"]. pattern = "* t", -> true (can match cat) pattern = ".a *" -> true (can match cat, cats, can also match sand, because * can also express empty sequence) Is below recurrence r...
I have this grammar: $S\rightarrow SS |S \rightarrow(S)|S\rightarrow\epsilon $ Now this grammar generates the set of balanced parentheses. But this grammar is ambiguous. I am trying to find an unambiguous grammar for this language but all in vain. This has led me to believe that the language is inherently ambiguous. A...
I was trying to solve the King of the North problem in Kattis. Basically, the problem is, the king has a castle to protect. To do this, he wants to place bannermen across the open areas surrounding the castle (some parts are closed thanks to natural barriers). A more detailed description of the problem: Given a grid ...
What is the algorithm with the best complexity that finds solutions in a given range to the equation $x^2+y^2=z^2$ ? The best i could do is to iterate through all $x$ and all $y$ and store $x^2+y^2$ in a hash and then iterate through all possible $z$ and check if $z^2$ is in the hash.
There are n girls and n boys. Each girl i has an objective attractiveness constant Pi (a natural number). The bigger the number, the more attractive. Each boy has a range in which he is comfortable asking the girl out [Ai, Bi] (inclusive). A boy will not ask someone out who is below Ai or above Bi. I need to pair as ma...
I've come across this situation numerous times in the past few years where I have some classes like (pseudo-Java): interface Node<T> { ... } final class BranchNode<T> implements Node<T> { List<Node<T>> children; } final class LeafNode<T> implements Node<T> { List<T> elements; } If you know the height of a ba...
Given a planner graph which it's vertexes have weights and an integer, W, this graph should be partitioned into two subgraphs which sum of weights for each subgraph becomes at least W. I wanted to show this is np hard by reduction and I have used Max cut to show that (in max cut we have a graph with weights for edges a...
I couldn't wrap my head around for finding an example for the following recurrence. $T(n) = a T(n/b) + f(n)$ where $a \neq b$ and $b > 1$ If we divide n elements with b, it should give us a sublists each with size n/b Could somebody please give me a practical example of this?
I faced with the following issue: if the value of a floating point format number is in the range of underflow, it must be 0 or a denormal number.If the value is not 0 than what is the exact value of it?Is it conventional constant value or depend on different architectures? I am sorry but could not understand through wi...
Let $G=(V,A)$ represent a directed acyclic graph, where a value $v_i \ge 0$ is assigned to every vertex $u_i$. Let $T$ represent a threshold and $N = |V|$. Problem statement: maximize: $\sum_{i=1}^{N}v_i x_i$ subject to: $\sum_{i=1}^{N} x_i \leq T$ and $x_i \in \lbrace 0,1 \rbrace$ and $x_i(x_j-1) = 0 \quad \forall a\i...
How to describe a $\operatorname{LL(1)}$ parsing algorithm for strings generated by a given grammar? I have to design a parser for a specific grammar. Let $G$ be the grammar described as: $$S \rightarrow aBC $$ $$B \rightarrow bB \mid cC $$ $$C \rightarrow c \mid S $$ My approach 1. Test if the grammar is $\operatorn...
I need an algorithm that can compute all the different partitions of a set of n elements into subsets of size m. For example for $n=4$ for the set $\{a,b,c,d\}$ and $m=2$ the output should be $\{\{\{a,b\},\{c,d\}\},\{\{a,c\},\{b,d\}\},\{\{b,c\},\{a,d\}\}\}$
I came across the paper: "Efficient Self-Interpretation in Lambda Calculus" by Torben Mogensen, 1994: http://repository.readscheme.org/ftp/papers/topps/D-128.pdf It talks about the intepreter $E$ and the reducer Lambda Calculus forms, but after a brief reading I cannot see, what is the real usage for them. Could someon...
When we talk about the enumeration of TM's, do we mean the "regular" deterministic ones? So if we want to enumerate nondeterministic or probabilistic TM's, do we need a separate enumeration? I can see how we could describe probabilistic TM's as strings, just as we describe the deterministic TM's only now we have two tr...
The exercise I'm trying to solve is You are implementing a binary search tree class from scratch, which, in addition, to insert, find and delete, has a method getRandomNode() which returns a random node from the tree. All nodes should be equally likely to be chosen. Design and implement an algorithm for getRandomNode(...
need some help with the following question: I've watched a few youtube tutorials but I'm struggling to convert this specific CFG
I'm trying to understand how to find the asymptotic complexity of a linear recurrence relation. So far, what I understand is that if only one linear recurrence call is made (ex. cn + T(n-4)), substitution or the recurrence tree can be used. However, what should one do if there are 2 or more linear recurrence calls? For...
"Introduction to Algorithms" by Cormen et al., 3rd edition, Lemma 13.1 states that A red-black tree with $n$ internal nodes has height at most $2\log(n+1)$, i.e. $h \le 2\log(n+1)$. Can equality part of the above, $h = 2\log(n+1)$, ever be satisfied? If not, what is the best known upper bound? My attempts to assert t...
If a B+ tree has an occupancy of 67%, does that mean the tree holds all of an index, and has additional empty nodes taking up the remaining 1/3rd?
This question is asked during a class of Computer Science. What is the transitive and reflective closure of the derivation relationship? I know that if $R$ is a relationship on $A^2$, a transitivive and reflective relation on $R$ is the following $R^*$ $$R^* = R^+ \cup \{<x,x> \mid x \in A\}$$ but I don't now how t...
I read that no LL(1) grammar can be ambiguous. Can we just make a LL(1) predictive parser table for a grammar to determine whether it's ambiguous? If the grammar is not LL(1), can we say that grammar is ambiguous?
I wonder to know if given a Machine $M$, a string $x$ and a symbol $\phi$, would $M$ ever write $\phi$ ? My approach Maybe i can show if the problem is undecidable by contradiction using $M$ to prove $\operatorname{HALTING PROBLEM}$, but i'm stuck here. Any hints ?
Say we want to find a shortest possible sequence of x86 instructions to move the $9^{th} - 16^{th}$ bit of the $eax$ register to the $24^{th} - 31^{th}$ bit of the $ebx$ register without changing the other bits of the $ebx$ register, where the least significant bit is defined to be the $0^{th}$ bit. An obvious solution...
I am given the following invariant: Invariant The greatest $i$ keys of an Array are always in sorted order on the last $i$ indices of the Array. I am supposed to create a sorting Algortihm using this invariant. But I seem to have understood the concept of an Invariant differently, because with the information I find on...
I'm keen to learn more about machine learning, as I feel it could be something that might have its uses in my place of work. I write PC software that controls scientific instruments, and one of its functions involves measuring a voltage every 100ms for (say) 10 seconds, then plotting this on a chart in my software. The...
Since most examples of complexity analysis I've seen involve functions that return either nothing (e.g. in-place sort) or a single value (e.g. computation, lookup), I haven't been able to figure this out just by reading examples. If a function returns a new list, should the space complexity analysis of the function inc...
https://people.eecs.berkeley.edu/~luca/cs172-07/solutions/sol8.pdf I'm checking those solution and i'm having trouble understanding the proof that shortest path belong to NL (2.a). So being Shortest path = {(G=(V,E), k, s, t) | shortest path from s to t in G has length k} and rk-1 being the number of vertices reachabl...
I am trying to understand Floyd's cycle detection algorithm. I can see why the algorithm works. When the Hare moves twice as fast as Tortoise, if there is cycle, they will meet definitely at some point in the cycle. Is there any proof that proves the above point? I mean, without assuming that Hare and Tortoise meet a...
During a class, we was asked how to prove that a language L is strictly context-sensitive. In particular, we have to prove that $L = \{a^nb^nc^n \mid n > 0\}$ Could you help me to find the answer providing a detailed solution? My approach: I know that a language is strictly of type $n$ if there isn't a type-$j$-gramm...
During a lesson, our TA asked: What kind of languages can be recognized by a deterministic Turing Machine such that we can use only a tape portion that contains the input? My thoughts: my Theory of Computation book says that there is a special TM called linear bounded automaton (LBA) that corresponds to a non-dete...
Input : An matrix $A$, whose entries are from $\mathbb{Z}$ (set of integers) Output: det A (determinant of matrix A) Question : Suppose we are solving this problem over $\mathbb{Q}$ using gaussian elimination, what could be the size of numerators and denominators of the intermediate results? Gaussian elimination: By do...
I have recently been interested in low level computer science (as a hobby), and I have just learned about the way a computer organizes and stores information on a hard drive. I have learned the basics of how a filesystem works. I understand that in the case of Unix, an inode entry is created for each file in the inode ...
for example the runtime of this program: Thanks!
Be $L$ a formal language over the alphabet $\Sigma$. $L$ can be defined by induction: $L^0 = \{\epsilon\}$ and for $i>0: L^i = \Sigma*L^{i-1}$. Means that $|L^n|$ is the number of words in $L$ of length $n \in \mathbb{N}$ letters from $\Sigma$. Find $|L^n|$. For $\Sigma = \{a,b\}$, $|L^n| = 2^n$ scince $|\Sigma| = 2$ a...