instruction
stringlengths
35
29.1k
The interrupt disable method to achieve mutual exclusion works for uniprocessor systems. Why does the interrupt disable method to achieve mutual exclusion not work for multiprocessor systems?
With my thin knowledge on embedded systems, compilers, and computer architectures, I know that the basics of computer memory(physical) are sort of like an array, with addressing which work like pointers. I see that imperative programming(which eventually unwraps to assembly, or the Turing Machine) fits this architectur...
If I have a directed acyclic graph $G(V,E)$, which may consist of several disconnected subgraphs $G_i(V_i,E_i) \subset G(V,E)$, how do I find the root of every subgraph $G_i(V_i,E_i)$?
I have a set of strings and would like to establish whether the set has the prefix property, which basically means that no string in the set is a prefix of any other string in the set. So {a, b} is prefix-free (has the prefix property) while {a, b, ba} is not prefix-free (lacks the prefix property) because the entire s...
This is related to an question asked and answered already, but I thought it was better to open a new question than necro a 1+ year old topic. Below is a list of 32-bit memory address references, given as word addresses. 3, 180, 43, 2, 191, 88, 190, 14, 181, 44, 186, 253 We want to optimize a cache design for the give...
Given any $k$-string Turing machine $M$ operating within time $f(n)$, we can construct a single-string Turing machine $M$ operating within time $O(f(n)^2)$ such that for any input $x$, $M(x)=M(x)$ How can we prove that converse is false?
How to solve the induced sub-graph isomorphism problem?
This is problem from my Networks class. It wants us to compute the round trip time of a point-to-point network and I'm just not sure which information is pertinent. The question: NASA deployed its latest 622Mbps point-to-point laser link between Earth and a new lunar base. The distance from the...
For the undecidable languages I have seen so far , I am able to give a reduction from one language to other . Is it the case that every undecidable language is reducible to every other undecidable language? If not can you prove that there exists 2 undecidable languages A and B such that A is not reducible to B. Note : ...
I've been playing around with an alternative to the standard object-oriented paradigm for modeling data, and I would like to know if there is any research or already existing systems along the same lines. Let me briefly explain my ideas. What I call the object-oriented paradigm goes something like this. Objects are rep...
Given $c$, can you generate a string $s$ with $K(s) \ge c$, along with a proof of that fact? I think the answer is no except for small $c$, but I'm not sure.
Undirected min cut has a well known poly sized LP formulation by expressing the problem as one of finding a certain metric on the vertices minimizing the sum of distances on edges. Can this be extended to directed min cut? If not, is there a different, simple, poly-sized LP for the problem?
I am trying to understand how to prove that a polynomial will always grow faster than a logarithm. $\log n = o(n^\epsilon), \epsilon>0$ Intuitively, it is obvious, and plugging in a few numbers always yields true, but how can I prove this? Maybe this can be done inductively (I would prefer this method if someone would ...
We can express insertion sort as a recursive procedure as follows. In order to sort $A[1,...,n]$ we recursively sort $A[1,...,n-1]$ and then insert $A[n]$ into the sorted array $A[1,...n-1]$. How can I write a recurrence for the running time of this recursive version of insertion sort?
Is there a list of implications of $P=NP$? Presumably, a proof of $P \ne NP$ will be by contradiction, for which a list of consequences of $P=NP$ would be useful.
I am trying to construct a context-free grammar for the following language: $$L=\{w_1cw_2:w_1\neq w_2^{R}\},$$ where words are over $\{a,b,c\}$. I have tried to do this by taking the union of two sub-languages: The length of $w_1$ is not equal to the length of $w_2$. The lengths are equal. For 1, I've already written...
I'm trying to understand the A$^*$ search algorithm. I read in wikipedia that A$^*$ chooses nodes based on their cost, calculated as $f(n)=g(n)+h(n)$, where $h(n)$ is a heuristic estimation of the cost to reach the target from node $n$. But I don't understand how to determine its value. Thanks for your help.
What are the fastest distributed algorithms for minimum cost maximum matching in general graphs? I found two papers that talk about approximation algorithms but I want algorithms that solve the problem exactly. Paper 1 - Distributed Weighted Matching, Mirjam Wattenhofer, Roger Wattenhofer Paper 2 - Simple Distributed...
I was reading about latency and IOPS, and I understood what they mean and their significance in the storage world. But what I do not understand (many places it is mentioned) is that how can the numbers actually conflict with each other when an example is given. In this explanation, the author states one of the examples...
If we are given an undirected graph and we want to find if the graph can be broken down to two subsets of vertices at maximum and not more than that. The vertices in each set are such that each vertex has edge with all other vertices . A single vertex can also be a part of the subsets formed. Example The graph edges ar...
I'm implementing an algorithm that analyze several properties on large set of integers, the time complexity is bound to $N$ (set length) and $M$ (bits to represent the numbers). I'm having some trouble to figure out how to express its time complexity because I don't know how to handle next situation: The asymptotic ana...
I recently came accross an interesting "sweep circle" algorithm for delaunay triangulation [1]. It's basic idea is seeding with a trivial triangulation (3 points), then gradually extending it outwards (points are sorted by their distance from a chosen origin - the sweep-circle center) while preserving the legality of t...
I want to provide proofs for parts of a Haskell program I'm writing as part of my thesis. So far however, I failed to find a good reference work. Graham Hutton's introductory book Programming in Haskell (Google Books)—which I read while learning Haskell—touches on a few techniques for reasoning about programs such as ...
From Programming Languages: Principles and Paradigms, by Maurizio Gabbrielli, Simone Martini void fiefoo (valueresult int x, valueresult int y) { x = x+1; y = 1; } ... int i = 1; int[] A = new int[5]; A[1]=4; fiefoo(i,A[i]); we are to execute fiefoo with parameters passed by value-result. On termination, we will ha...
If A & B are regular languages, prove that complement of A is also regular language. (Closure of regular languages under complementation) Can anyone help me with the proof??
Why is every artificial neural network layered? Why isn't each node just a separate process?
I would like to know if there is a simple algorithm for checking the existence of a permutation that satisfies a number of order-constraints. For example, suppose we have a set (1, 2, 3, 4, 5) and a number of constraints: 1 should be before 2 2 should be before 4 4 should be before 1 (which is of course infeasible)....
As a starting point for our course in Artificial Intelligence, we are being taught induction. We received a number of homework assignments where we have to show our inductive approach for a given problem. An example of such a problem: "Sort an array of N numbers". Reading through the course material and online sources ...
Let B(x) be a computable predicate. Show that \begin{equation} G_B(r)= \begin{cases} 1 \;\;\;\;\;\text{ if there are at least r numbers n such that B(k) = 1 } \\ \uparrow \;\;\;\;\; \text{ otherwise} \end{cases} \end{equation} I want to write a program with just these four instructions to compute $G_B$(r) \begin{arra...
As part of an object tracking application, I am trying to solve a node-disjoint k-shortest path problem. My graph is (for now) k-partite. I have a single source and single sink. My edges are initially negative-positive but made non-negative by transformation. This paper provides (in appendix) a solution but the explan...
I have some expression (f n in the example below) returning a tuple. I would like to prove that f n is equal to let (x, y) := f n in (x, y), which seems like it should be easy. What tactic should I use? Definition f (n : nat) : nat * nat := match n with | 0 => (3, 4) | _ => (2, 3) end. Lemma foo : forall ...
I was reading this paper - Software defect prediction using cost-sensitive neural network by Ömer Faruk Arara and Kürsat Ayan It uses Artificial Bee Colony algorithm to train the neural network. In ABC algorithm, the input is an N x D matrix, where D is the "number of parameters to be optimized" in the problem. If the...
When I self-study "Programming Languages: Principles and Paradigms, by Maurizio Gabbrielli, Simone Martini", I have a question: what does deep binding mean for static scope? I learned the concepts of deep and shallow bindings for functional parameters from the following part in the book The general case, the one we ...
It's fairly simple to understand why the halting problem is undecidable for impure programs (i.e., ones that have I/O and/or states dependent on the machine-global state); but intuitively, it seems that a pure program's halting on an ideal computer would be decidable through e.g. static analysis. Is this in fact the ca...
When the halting problem is discussed, often the counterproof consists of some unsolved mathematical problem or a self-reference. Is the halting problem decidable for pure programs on an ideal computer? Is this of any relevance for most programms not even remotely dealing with complex math ? I often hear that performin...
Let T be a binary tree that is stored in the disk following the preorder layout. For example if this is $T$: then $T$ will be stored in the disk as follows: 10, 11, 0, 12, 13, 2, 7, 3, 14, 1, 15, 16, 4, 8, 17, 18, 5, 9, 6 Every node of the tree is a struct that stores the offset of the left child, the offset of the r...
Let $G = (V, E)$ be a graph and $G^*$ its edge complement (that is, $G^* = (V, E^*)$, where an edge $\{u, v\} \in E^* \Leftrightarrow \{u, v\} \not \in E$). What is the relationship between a coloring in $G$ and a coloring in $G^*$ ? I was expecting something like "If $G$ accepts a $k$-coloring, than $G^*$ accepts a $(...
In this question it is asked, "Is the language of TMs that accept finite languages Turing-recognizable?". It turns out this language $L=\{ \langle M \rangle \mid |L(M)| < \infty \}$ is not. I ask this: We know that the halting problem is Turing-reducible to $L$ but is $L$ Turing-reducible to the halting problem?
What is min # of pairs req’d for sufficient confidence from a given pairwise ranking algorithm? Note: I'm a little rusty and don't have a comp sci background, just an undergrad math deg about 10 yrs ago, which I don't use in my day job much. But I have an issue which I could really use help understanding. If you have a...
I was reading a question over at Stack Overflow asking whether it was NP-hard to list all simple cycles in a graph containing a particular node and it occurred to me that I couldn't think of any existing complexity class that was well-suited for talking about problems of the form "list all solutions to this problem." T...
One of my future goals is to know in depth about building a text-based dialog system to answer questions about a specific topic (say, Tolkien's legendarium), assume that I have a large body of article-formed facts about that topic (say, Wikipedia). Excluding the "Computer Engineering" part of the problem, I have a ques...
The Wikipedia article https://en.m.wikipedia.org/wiki/Lambda_cube is difficult to assimilate. I think examples (code snippets) that demonstrate each refinement might help clarify. For instance, a generic List in C# would demonstrate types based on types (I think). What are examples of the other axes? Are there meaningf...
A closure of a function includes the environment when calling the function. Does the environment included in a closure of a function include the actual parameters for the function? If I am correct, from mathematical logic point of view, a closure for an expression consists of the free variables of the expression. So I...
I asked my algorithms teacher today the very same question that is stated in the title, but he seemed a bit unsure, either on the question or on the concept, so I thought I'd try here too. Is there a minimal test that could determine whether a language or instruction set is Turing compete, or does a test of that sort f...
I read two papers discussing how to compare between decision trees. One of them is RTED (that is specifically for trees and sub-case is decision trees) can be found here (RTED: A Robust Algorithm for the Tree Edit Distance)here: and additional approach is COMBINING CLASSIFICATION TREES USING MLE by Shannon and Banks (S...
In programming languages, must a recursion be represented only in terms of definition of a recursive function? Does a recursion appear in other cases? I ask this question, because recursion and loop are two equivalent ways to make a programming language Turing complete. Loop doesn't depend on function, and does recursi...
Lets suppose that there exists a comparison-based algorithm that turns an arbitrary array to a state $A$ in $o(n\log k)$, and there is another comparison-based algorithm that turns an array in state $A$ to completely sorted in $O(n\log (n/k))$. $n$ is the size of the array, while $k$ is another non-constant parameter g...
I know that set of all deciders is countable. I am wondering whether it is infinite.In other words can we prove that the set of recursive languages is infinite ? Edit : The above question has small mistake as pointed out in one of the comments .. Since every recursive language has infinitely many deciders .. the two qu...
S->aAB A->bBb B->A|epsilon It seems that the string abbbb can be derived by using more than one ways. After using the starting production and the production for A, we get: S=>abBbB. From here, either of the B's can be replaced with epsilon and the other one replaced with bBb. So, there are two ways of deriving abbbb...
I am currently trying to understand how Computers are arranged and organized internally (so that I can learn Assembly Language) through an online book called The Art of Assembly by Randall Hyde. Irrespective of whether or not I'll learn Assembly, I'm finding it difficult to understand exactly how is everything synchron...
Is it possible to have multiple languages in a DFA? in my example in the image, I think the language L={w | w = 0x where x is {0}* } is accepted and the language L={w | w = 0x11 where x is {0}* } could be accepted as well.
Is there any turing machine that it is proovably known to be undecideable, it has to fullfit the following characteristics: Not rely on Open Problems/ Conjectures Should not use the same machine used in diagonalization proof In other words, is there an alternative proof that Halting problem is undecideable (other tha...
I read that the further you get from 0, the less precision, due the way they are stored. So why aren't numbers stored like this: $32$ bits for representing a value between $-2^{31}$ and $2^{31}-1$ before the decimal point and another $32$ bits for representing the precision. $\frac{1}{2^{32}} = 0,00000000023$, which wo...
I can obviously tell by inspection that it is not true but I cannot figure out how to prove it with witnesses (C and k). Thanks!
According to this article the following line of Lisp code prints "Hello world" to standard output. (format t "hello, world") Lisp, which is a homoiconic language, can treat code as data in this way: Now imagine that we wrote the following macro: (defmacro backwards (expr) (reverse expr)) backwards is the name of the ...
I noticed in another answer on this forum Note that the languages ∅, {ϵ} and Σ* are regular. How do you prove Sigma Star is regular.
If I am correct, The closure of a function is the non-local environment of the function. the non-local environment of a function is different depending on static or dynamic scoping. So is the closure of a function also different depending on static or dynamic scoping? Thanks.
Kriegspiel chess is a variant of chess in which each player is not aware of where the opponent's pieces are. In a human match, a trusted intermediary relays piece losses, legality of moves etc. This is, of course possible on a computer as well. What would a peer to peer implementation of Kriegspiel look like, in terms ...
Let's say I have a combinational device that has an input of 7 bits and outputs a 3-bit binary number that reflects the number of 1s among the 7 bits. How much information would be conveyed by the following outputs: 000 and 001? I know information, in bits, is calculated by log2(1/p), and p is M/N, where N is the numbe...
A heuristic function $h (n)$ is... Consistent if the estimated cost from node $n$ to the goal is no greater than the step cost to its successor $n'$ plus the estimated cost from the successor to the goal. Admissible if $h(n)$ never overestimates the true cost to the goal state. The textbook for my Artificial Intell...
I am not a specialist on computational complexity theory. I do work on optimization and I am currently researching about the implications of the class of problems with parallel solutions (NC) being not P-complete, i.e., NC$\neq$P for optimization. In particular, I am interested about the consequences for equations base...
I'm new to regular languages and I've been struggling to solve one for a while. The question is: If there exists a regular language L1 which has an alphabet {0,1}, prove that L2 is also a regular language if L2 comprises of strings x where x = ABC where B is an element in L1 and A and C are strings comprised of ...
I'm trying to understand some aspects of the $P=^?NP$ and $NP=^?coNP$ problems. I am engineer and not mathematician nor computer scientist so I do not completely understand what a turing machine is. I'm currently thinking about a variant of the "subset sum problem" known to be in $NP$ and suspected to be not in $coNP$....
I have a directed graph where all the nodes represent some task that needs to be computed. I need to compute the order of these tasks and also detect any cycles. Running Tarjan's algorithm on the graph gives me both. To the problem: I was wondering if there exists a good way to make use of parallelization. For instanc...
Example, if i have certain geographic points in an array A=[a,b,c,d...n] and have 10 points distributed in the solution space B= [1,2,3...10], how can I allocate each member of A to the nearest point in B in the quickest way.
I was going across some problems which translated the fact that $\log (n!) = \Theta(n\log n)$ to give $$\log(\lceil\log n\rceil!) = \Theta(\lceil\log n\rceil \log \lceil\log n\rceil)$$ and therefore $\log(\lceil \log n\rceil!) = \omega(\lg n)$. Now I just have this intuition that this sort of conversions shouldn't a...
I'm studying Hough Transform. I have fully understood the HT for detecting lines and successfully implemented it. I have more problems with the circle detection HT. Given a circle, if the radius is known i have to work in a 2d parameter space (each point in the image space becomes a circle in the parameter space; the...
The wikipedia says that the number of nodes n in a full binary tree, is at least $n=2^h-1$ and at most $n=2^{h+1}-1$, where h is the height of the tree. The following binary tree is full according to the wikipedia definition (every node has 0 or 2 children), n = 11, h = 4 but n is not greater than $2^4 - 1 = 15$. Am I...
There are n variables $x_1$, $x_2$,..., $x_n$ and each one of them takes values from 1 to k (k>= n) and all are distinct. How can I represent this in the CNF form? (I tried the trivial way of trying all assignments and then checking if they are distinct, but I think it could be done better)
I have been studying asymptotic notation and I understand that in big O notation $f(n) <=c1*g(n)$ and in omega notation we have $f(n)>= c2*g(n)$ where $c1$ and $c2$ are some constant. Now I was wondering if the function $g(n)$ here are the same and the big O and omega of $f(n)$ is determined by constants $c1$ and $c2$...
I am attending algorithms and data structures course in my University and my professor gave me an interesting question the other day. He told me to think about it. What is a problem, a task, and a solution? It seems to me like it's more of a philosophical question. All of those 3 things correlate to one another. To me,...
My text book gives the following definition of a primary key in a relational database, which I don't entirely understand. Help would be greatly appreciated. Let $R$ be a relation. Then the primary key for $R$ is a subset of the set of attributes of $R$, say $K$, satisfying the following two properties: Uniqueness ...
I am studying asymptotic notation and I was thinking of a possibility where if g(n) < f(n) is it possible to have f(n)<=cg(n). For example if - f(n)=6n+5 and g(n)=4n+5, such that it possible to say (6n+5)<=2(4n+5) where 2 is c. Are f(n) and g(n) here valid function in term of asymptotic notation.
Several years ago my professor gave me a book that contained the most important computer science papers, including Von Neuman's paper on architectures and Dijkstra's Go-To paper. The book was an older, blue hard-cover. Sadly, it got lost somewhere... and so I thought this might be a good place to see if anybody can poi...
The halting problem is undecidable of course. This implies that there is at least one program for which we cannot decide whether it halts or not, because theoretically, if all we know is that the halting problem is undecidable, it could still be that there is a program that can decide for every program except itself wh...
I was asked to model the following sequential circuits C1, C2 as transition systems (i.e. identify the output y function and register functions r1, r2, r3) For C2 there appears to be not input x and only output y with a register R3. I assumed that there would be two possible states R3 = 0, R3 = 1 and then Y2 = !R3. B...
problem statement for SKICOURSE is this Farmer John has N hills on his farm (1 <= N <= 1,000), each with an integer elevation in the range 0 .. 100. In the winter, since there is abundant snow on these hills, FJ routinely operates a ski training camp. Unfortunately, FJ has just found out about a new tax that will be as...
From https://en.wikipedia.org/wiki/Programming_language#Type_system Typed versus untyped languages A language is typed if the specification of every operation defines types of data to which the operation is applicable, with the implication that it is not applicable to other types.[47] For example, the data repr...
What are the differences between an implicitly typed programming language and a untyped programming language? Let me explain the above question and what I have thought about it. My question comes from reading https://stackoverflow.com/a/9159863/156458, where the huge slide says "untyped = no type declaration". I ...
How exactly is the complexity of a SAT solver measured? My main concern is that, for $N$ variables, you can have, e.g., an OR of $O(2^N)$ AND terms, which would take at least $O(2^N)$ time to process. If the formula can contain duplicate sub-expressions, e.g., $(A \land B) \lor (A \land B)$, then the formula's maximum ...
What is the difference between a Residual Neural Net and a Recurrent Neural Net? As I understand, Residual Neural Networks are very deep networks that implement 'shortcut' connections across multiple layers in order to preserve context as depth increases. Layers in a residual neural net have input from the layer before...
In programming language theory, there are operations which are distinguished between static and dynamic, e.g. static/dynamic scoping, static/dynamic typing, .... Does "static" or "dynamic" imply a compiler or interpreter implementation of a programming language? Let me explain the above question and my thoughts and con...
$a^ib^jc^k | (i = j)$ then k is even? I can write it as $a^ib^ic^k$ where k is even OR $a^ib^jc^k where (i != j)$ Both are DCFL and union of DCFL may be DCFL, but I think because of OR operator it gives a sense of parallelism and hence NCFL. I haven't tried to make a DPDA for it, because in exam I might not be have muc...
In programming language theory, which concept means that a name can refer to values of different types at different points of execution of a program, dynamic typing, implicit i.e. inferred typing, defined as opposed to explicit i.e. manifest typing, something else? Let me explain the above question. My question come...
What is the problem if we sort the intervals according to their finishing time like the interval scheduling problem? Could someone give a counterexample ? Note- (refer here for detailed definition) Interval Partioning Problem: Multiple Identical Resources are available and we have to partition all intervals across thes...
$$L = \{a^i b^j c^k \mid i \le j \text{ or } (j \le i \text{ and } j = k)\}$$ I think the given language is CSL as i can break this language like this $$L = \{a^i b^j c^k \mid i \le j \text{ and } j = k\} \cup \{a^i b^j c^k \mid j \le i \text{ and } j = k\} \cup \{a^i b^j c^k \mid i \le j \text{ and } j \le i \text{...
I'm reading Programming - The derivation of algorithms, and I want to understand the purpose of a predicate transformer. This is the excerpt (p. 14-15): A more precise way in which constructs may be introduced is as follows. For each construct $S$ one defines a predicate transformer, denoted $wp.S$, which is a functio...
I would like to know how Boyer-Moore text searching algorithm with Galil's rule works,. I tried to search for but I couldn't understand the information I found, for example this Wikipedia page. And why with this rule we go to a linear time complexity?
I am currently trying to wrap my head around intuitionistic logic and its interpretation using the curry-howard isomorphism and propositions as types. I came about this explained relation between $\forall$ and $\rightarrow$: A function type $s \rightarrow t$ is actually a function type $\forall x:s.t$ where the vari...
My intuition says that I can make a sorting algorithm(may be a strange, not an useful), such that with array it have different worst case time complexity class and linked list(assuming time complexity of operation performed in linked list are same as conventionally used) with different complexity class. But what about ...
I'm studying the articleVerifying privacy-type properties of electronic voting protocols which uses Applied $\pi$-calculus to formalize voting protocols and verifies some privacy-related properties. In certain parts of the paper they define some transformations over processes which are defined inductively. For example:...
Subtraction-based algorithm for finding the greatest common divisor works like this: For two integers a and b (a > 0, b > 0), if a > b, then gcd(a, b) = gcd(a-b, b) else if b > a, then gcd(a, b) = gcd(a, b-a). else if a = b gcd(a, b) = a What is the $\mathcal O$ of this algorithm?
Type inference can be done by a compiler, and in such cases, type inference is static. Type inference can also be done by an interpreter. An interpreter does the jobs of both compilation and execution. So is type inference done by an interpreter static or dynamic? This question is an example that motivated my question ...
I'm not sure how to get from the left hand side to the right. It appears in Sipser's Introduction to the Theory of Computing, in a proof of showing that a $t(n)$ time nondeterministic single-tape Turing machine has an equivalent $2^{O(t(n))}$ time deterministic single-tape Turing machine.
Not sure whether this is the correct place to post the question. some of my terms might not accurate. currently AI is used for classification, inference, and so forth, is AI problem decidable? for example, given a dataset, prior/constraints and neural network, whether it can recognize a pattern (properly accuracy great...
If we were to find the shortest-path tree rooted at some vertex in a weighted graph G, is it possible that the resulting tree is also a maximum-weight spanning tree of G? Please give an example! I tried every combination I could come up with using connected graphs with cycles on them (so that there is more than one pos...
I am new to machine learning and have started brainstorming some model ideas that involve financial instrument/time series data. I was thinking it might be useful to use a classification algorithm to predict if an instrument was in fact up or down y% (TRUE/FALSE) after n days, based on i.e. a combination of technical i...
I know that sorting the array take O(logn) time. But why finding the minimum of elements take O(n) time, which is more expensive? If I sort the array, I simply output the first element and this would be my minimum.
I wish to use alpha beta pruning in a problem with following constraints: Terminal nodes are likely too distant to be found in most searches Instead I want to maximize an evaluation function There is a fixed time limit per search (say 1 second) Moves are made on a "WeGo" basis ie. we both move simultaneously (I still...
I have to solve this using the substitution method. Floor functions cannot be skipped. IH: Assume that $T(k) \geq ck\log(k) $ for all $k \leq n$, where c is a constant. IS: Must prove $T(k) \geq ck\log(k) $ Proof: \begin{align*} T(n) &= 2T(\left \lfloor{k/2}\right \rfloor ) + k\\ &\geq 2 c\left \lfloor{k/2}\ri...