instruction
stringlengths
35
29.1k
In Lambda Calculus, the distinction between data and code doesn't seem to exist. Is there something fundamental about this, or purely Lambda Calculus's thing? Some context: as a software developer, I got used to the concept of data so much that I never considered its true nature. I'd very much appreciate any references...
I have a table like this: PostId | Body | AuthorId 2 b F 2 b E 2 b C 4 d A 4 d E 8 h F So what I want is to get all the rows that have mo...
Suppose that $L$ is some language over the alphabet $\Sigma$. I was asked to show that the following languages is decidable: $$L' = \{w \in \Sigma^* | \text{ there exists a word } w'\in L \text{ such that } |w'| \leq |w| \}$$ I.e., $w \in L'$ if $L$ has some word with length smaller than $|w|$. The way I was thinking...
I want to solve a linear programming problem in the $2n$ variables $x_1, \ldots, x_n$ and $y_1, \ldots, y_n$ where the cost is of the form $x_1/y_1 + \cdots + x_n/y_n$. Specifically, I want to solve \begin{align*} & {\rm minimize}~ \sum_{i=1}^n x_i/y_i \\ &\mbox{ subject to } Ax + B y \leq c \\ & x>0, y>0, \end{align...
I observed that all the interval tree implementations I am able to come up with are required to utilize a stack (or a-like) to answer queries (report any overlapping interval with a key). In general when visiting a node in an (common) interval tree you are required to visit multiple child nodes and check for results th...
let's say $f(n) = O(g(n))$ and $l(n) = O(m(n))$ is it always true that $f(n) \cdot l(n) = O(g(n)) \cdot O(m(n))$ ?
If we have a Turing machine in a model with a tape that is infinite only to the right and assume at some point the head tries to move left from the leftmost position. How should we define the behavior in such a case? Is a machine doing so for some input not a valid Turing machine? And if so, how can we make sure when w...
I have a bunch of objects that I am not sure on how to represent in order to maximize memory occupancy and possibly avoiding large CPU overhead. The most natural way to see the whole data structure is as a tree. A picture is worth a thousand words Each tree node contains an object that I simply represented as an integ...
In general for the (two-party) set disjointness problem for inputs of length n, we know that the parties need to communicate $\Omega(n)$. Surprisingly, today I discovered (if I understood correctly) that this is not true for product distributions, i.e. when Alice's and Bob's inputs are chosen independently from arbitra...
I've been looking at the following combination sum problem: Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target. The same repeated number may be chosen from candidates unlimited number o...
Function Problem: Given $N$ find a $2$_$sum$ that uses at least $ONE$ prime. Fact: Prime Gaps grow logarithmically on average. And, in worst case if memory serves correct it grows with a bounded constant. Take notice that $count$ (defined below) will only equal to $s$, if the $AKS$ primality statement executes $s$ tim...
Here is a picture from Andrew S. Tanenbaum, Computer Networks, 5th edition, Chapter 3 (The data link layer), Page 207(English Version)/Page 206(Japanese Version): I want to verify whether my interpretation is correct or not. My interpretation is in the picture that has red arrows. From the picture, I made a table to...
I'm trying to implement a decision procedure for finding solutions to a scheduling problem; this involves computing the point in time which is under the most contention. Each task to be scheduled has a continuous compactly supported piecewise linear distribution of possible time allocations; the total contention at any...
Given n numbers, design an algorithm to find the smallest $n^{\frac{2}{3}}$numbers, in sorted order. (Assume $n^{\frac{2}{3}}$ is an integer.) I don't understand this question. Can I simply $x = n^{\frac{2}{3}}$ and fetch the $A[x]$?
I am designing a feature recommendation system and I have encountered an algorithmic problem and I am wondering if any of you know if there are known algorithms to solve this type of issue. In our recommendation system the content recommended can have in its metadata information at what range it should be put. To demon...
I have a language: $$ \{a^jb^k \mid j \neq k \text{ and } j \equiv k \pmod 3 \}$$ I want to prove that this language is regular. My first thought was to create a regular expression that accounts for all three of the cases of modulo 3 like such: $$(aaa)^*(bbb)^* | a(aaa)^*b(bbb)^* | aa(aaa)^*bb(bbb)^*$$ However, this do...
For double hashing, we have some constraints on $h'(k)$ (1) It should never evaluate to 0 (2) It should be relatively prime to m How to show that all slots in an open addressing table will be included in a probe sequence.
Given a CFG in Chomsky Normal Form and a sentence s. I want to count the number of different parsing trees that parses s. assuming I know how to change the CYK algorithm so it would count the number of parsing trees, how can I determine if one tree X is different then tree Y? obviously it can be done in a naive way tha...
I would like to know if someone can give me an example of how a prefix sum which contains 8 elements can be computed with just three processors. Prefix sum
I'm currently working on a personal software project (as a hobby) and would like to know which kind of approach I should follow according to you. My application scans some websites (like Amazon or eBay) to check items of a specific category and show them all together ordered, for instance, by price. Currently I use Pyt...
I am learning about block ciphers and while I understand the concept of Electronic Codeblock mode and cipher block chaining, I could not find any relevant practical examples online. Can someone provide a short example of a scenario where we convert plain text into cipher text using ecb and cbc (with initialization vect...
I have the following function. int fun(int n) { int count = 0; for (int i = n; i > 0; i /= 2) for (int j = 0; j < i; j++) count += 1; return count; } It has O(N) time complexity. I thought it's O(N LogN)(i.e. If we remove the inner loop we get) for (int i = n; i > 0; i /= 2){ ... } This is...
Let $T(n):=\begin{cases} \frac{2+\log n}{1+\text{log}n}t(\lfloor\frac{n}{2}\rfloor) + \log ((n!)^{\log n}) & \text{if }n>1 \\ 1 & \text{if }n=1 \end{cases}$ I need to prove that $t(n) \in O(n²)$, thus $t(n) \leq c\cdot n²$ I asked the question here and I got really great help last time, the thing is after I was shown l...
So what confuses me is that let's consider a function f. According to a definition from a text book it asserts that f is called recursive, if there is a Turing machine that computes it (for all input strings output of the machine should be equal to output of the function given the same input). But in general, we say th...
Assuming we have two programs $p_1$ and $p_2$ and two line numbers $n_1$ and $n_2$. Does $p_1$ reach $n_1$ in less computational steps than $p_2$ reaches $n_2$? By reduction from Halting, this is clearly not decidable, but I think it is semi decidable. To do so, I would build an interpreter, that executes $p_1$ and $p_...
I'm trying to understand splay tree performance compared to a standard balanced tree like AVL/red-black. In practice, I am pretty skeptical of the amortized bounds Tarjan and Sleator proves in their paper. Maybe because I am not that smart to actually understand these proofs, but I am still curious of one certain patho...
For many years now, I have heard about "AI" and "neural networks" and all these buzzwords, and it is regularly claimed on Slashdot that this or that open source program is able to "do AI". But then I go to its website and I have no idea what I'm even looking at, let alone how to actually use it. I give up and forget ab...
I am given two functions: $ fl(fl(x+y)+z) $ and $ fl(x+fl(y+z)) $ and asked to derive their relative error. Then, given a set of conditions: a) $ x < y < x $ b) $ x > 0, y < 0, z > 0 $ c) $ x < 0, y > 0, z < 0 $ determine which parenthesization has less relative error. After some algebra I determined the following rela...
A friend in industry proposed a problem to me. If you have a supply warehouse, you can treat each station with products as a node. Each node has a probability it will be visited by an employee working on an order. Is there a way to decide what product goes at each fixed node to minimize total travel time, by all employ...
Ternary heap is like a binary tree, just every node can have up to $3$ sons and not $2$. I try to bound the number of nodes in the heap, $n$, using the height of the heap $h$. The solutions get to: $$ 3^h < n < 3^{h+1} $$ Yet, I get to: $$ \frac{3^h}{2} < n < \frac{3^{h+1}}{2} $$ In short, what I do is: $$ \sum_{i =...
I want to solve Problem 4.10 from Randomness by Salil Vadhan. https://people.seas.harvard.edu/~salil/cs225/spring15/PS3.pdf Consider a bipartite expander $G$ with left degree $D$ so that every subset $S$ of the left vertices with at most $K$ vertices has at least $(1-\epsilon)D|S|$ neighbors. Then $G$ also has the prop...
I am trying to compute the Follow set of the following Grammar: E -> E' E A A -> + | * E -> num E' -> num I start by adding the end of string symbol, via. some non-terminal S such that: S -> E$ E -> E' E A A -> + | * E -> num E' -> num Becomes the Grammar. With this I get the following set constraints for the product...
I'm stuck with the following problem by Skiena (The Algorithm Design Manual, p. 106): Problem: Give an efficient algorithm to determine whether two sets (of size $m$ and $n$, respectively) are disjoint. Analyze the worst-case complexity in terms of $m$ and $n$, considering the case where $m$ is substantially sm...
Let's say I've finished my compiler for my new language. Next step is write a custom editor with syntax highlighting (type checking and semantic can wait), is there a cookbook or any kind of guidance to accomplish this project?
Suppose there exists an algorithm that takes as input an unsatisfiable SAT formula, and never fails to verify it in polynomial time. However, when the input is a satisfiable formula, it doesn't work (let's say time and memory problems, the algorithm gets lost in the reasoning). Then Co-NP = P because we can verify uns...
i think the above is incorrect; specifically, i think H isn't bijective. say our alphabet is the lowercase letters [a-z] and that char(a) = 0. then, e.g., H("abc") = H("bc"). am i missing something?
I'm taking a class. In this class every week we have a partner. There are an even number of people in the class. We'd like avoid having repeat partners if possible so that everyone gets to work with as many people as possible. I'd like to know how many weeks we could accomplish this before we're forced to partner someo...
Given a undirected graph which only has two different edge weights $x$ and $y$ is it possible to make a faster algorithm than Prim's algorithm or Kruskal's algorithm? I saw on Kruskal's algorithm that it already assumes that the edges can be sorted in linear time with count sort, so then can we gain any benefit by know...
I have a hashtable with length $m$. Initially it's empty. Next, $n/2$ unique random numbers $\in [0, n]$ are added to it. What would be variance of chain length when such $n/2$ numbers are being added $x$ times? I tested it using code with $n=2^{16}$, $m=2^{15}$ (part of md5 was used as index) and got the following res...
Suddenly a thought came to my mind and I thought of resolving it as follows. We know that: String is a finite sequence of symbols from an alphabet $\Sigma$ i.e. we cannot have an infinite sequence representing a string, which means there is no definition such as $w = "abcabe...........$ which is unending Now when we co...
Exercise 3 from https://massimolauria.net/courses/2015.ProofComplexity/lecture6.pdf Consider the set of inequalities $x_i+x_j\leq1$ for $1\leq i<j\leq n$. Find a derivation of $\sum_{i=1}^n x_i\leq 1$ in $O(n^2)$ length. If it were just algebra I could just show by contradiction that at most one $x_i$ could be 1 and ...
I have been asked this question, but don't know how to go about answering it. Three process, which are implementing Lamport's clocks, are running and a lot of events are taking, place including some messages being sent between the processes. The arrows and circles represent in-processor events and messages being sent ...
I'm trying to figure out the running time for a Dijkstra algorithm. All the sources I have read say that the running time is O(E * log (E)) for a lazy implementation. But when we do the math we get O(E * (Log(E)+E*Log(E))). Since E isn't a constant, I don't see how someone could reduce this to O(E * log (E). Are we a...
Say I have a deterministic turing machine which solves decision problem S with oracle access to both problems B, C that are in $NP$. Can S be solved with oracle access to only one problem in $NP$? That is, can B and C somehow be combined into one problem in $NP$ (thus showing S is in $P^{NP}$)?
Given a square matrix of size N X N (1 <= N <= 1000) containing positive and negative integers with absolute value not larger than 1000, we need to compute the greatest sum achievable by walking a path, starting at any cell of the matrix and always moving downwards or rightwards. Additionally we also have to find the n...
I would like to determine if the following language is decidable or not. L = { w $\in$ $\Sigma^*$ | $T(M_w)$ is recognized by a Turing machine with at most 42 states}. I know that every finite language is decidable, but I am not sure if this has anything to do with this particular problem. Every help is appreciated, I...
I need to get feeling for the feasible size of a LPP, that can be solved on a PC. Say, its a good one (8 cores @ 3+GHz, 64GB RAM). We also assume that number of variables is close to the number of additional conditions. I know it depends on the solver, but what size is feasible for solution in several hours/few days? ...
Our local ninja Naruto is learning to make shadow-clones of himself and is facing a dilemma. He only has a limited amount of energy (e) to spare that he must entirely distribute among all of his clones. Moreover, each clone requires at least a certain amount of energy to function (m) . Your job is to count the number o...
I have the following alphat {0,1}. I'm told to draw a DFA which fulfills the following: {w|w starts with 1 and ends in 0} This is the DFA I came up with.
I am learning Computer Architecture from Introduction to Computing Systems (2nd Edition) and am stuck on this question. What operations can be used to convert the binary representation of 3 into ASCII representation for 3? What about binary 4 to ASCII or any other digit? The concepts I have learnt until now are Basic...
we have the alphabet {0,1}. {w|w contains at least two 0s and at most one 1} It tried this: (However I'm not sure if it's correct. If it's incorrect why?)
I am well-aware of the result showing that one can convert an epsilon-NFA (that is, an NFA with epsilon transitions) $A$ to an NFA without epsilon transitions $A'$, where $L(A) = L(A')$. Is there a similar result comparing the state complexities of $A$ and $A'$? That is, if one has an epsilon-NFA $A$ with $n$ states, i...
Here is the question: Link. In a gist, we need to count the total count of numbers that would divide every number in an array. The approach that I took was that any number that has to divide all the numbers must be less than or equal to the smallest number in the array. For e.g., if the array is [6 90 12 18 30 18] - an...
My understanding is that symbolic execution only deals with specific paths and bad patterns, while SAT solvers, or satisfiability modulo theories in general, provide a much more robust analysis of the program. Could someone validate the statement above and (briefly) explain the differences between these two formal veri...
i have seen in the "logic to cs" class i take - a theorem that states: "every recursive (computable) function $f$ can be expressed using the arithmetic dictionary {$C_0, C_1, f_+(,), f_x(,), R_\le(,)$} with the structure {$D=\mathbb{N} ,C_0=0,C_1=1, f_+(a,b) =a+b, f_x(a,b)=ab, R_\le(a,b) = a\le b $}" But we didnt prove...
I am currently studying Algorithms, Fourth Edition by Sedgewick et al. On page 226, there is an analysis of the quick-union algorithm's find() method's worst case. This is the algorithm: private int find(int p) { // Find component name. while (p != id[p]) p = id[p]; return p; } Suppose we have origi...
I am trying to calculate the Time Complexity of the Recursive Function, suppose this, function T(int n){ if(n == 1) return 1; return T(n-1) + T(n-1); } the time complexity equation is: T(n) = 2T(n-1) + C, taking C = 1 and T(1) = 1. Now, since I am working on this, I am confused whether I am doing the right process u...
Say we have a place-transition digraph system. A transition can fire if all input places have marks. A transition fires by consuming items from input places and placing one into each output place. A number near the transition is a transition price. So, for example, we can get an image like this: We want to find the ch...
I have a big problem with converting GNF example. This is my CFG $ S \to AS\mid BS\mid \lambda\\ A \to aC\mid BCA\mid c\\ B \to AB\mid b\mid \lambda\\ C \to S\mid d $ I simplified the CFG by removing redundant, $\lambda$-production, unit production. $ S \to AS\mid BS\mid BA\mid CA\mid AB\mid BCA\mid aC\mid a\mid b\mid ...
Background: I have a .yaml file which holds around >3000 elements. The elements are related to each other through a recursive relationship. I want to create a tree view containing those items. A good algorithm is needed, since I also have other .yaml files with more items. Question: How can I convert a tree with recurs...
what is the time complexity of the following code. please help me. // a is mxn matrix for i = 1 to m: l = {} for j = 1 to n: if(a[i,j] != 0): add j to l if(len(l) > 1): for k=1 to len(l) for j=k+1 to len(l): some other code
I want to know why $\text{DSPACE}(O(1))=\text{REG}$, especially in the direction of why all languages in $\text{DSPACE}(O(1))$ can be recognized by a finite automaton. I've thought for some time and know that the idea is to encode the finite possibilities of memory as finite states, and also have read https://cs.stacke...
Consider two index sets $S = \{0, 1, 2, 3, 4, ..., N - 1\}$ and $Q = \{0, 1, 2, ..., \frac{N(N + 1)}{2} - 1\}$. Let $R = \{(a, b)\space |\space a, b \in S, a \ge b\} = \{(0, 0), (1, 0), (1, 1), (2, 0), (2, 1), (2, 2), \dots\}$. There will be $\frac{N(N + 1)}{2}$ elements in $R$. Is there a one-to-one function $f : Q \t...
Stoer-Wagner algorithm can be used to find global minimum cut in a graph. I'm wondering if it could be adapted to find a minimum s-t cut, given s and t. We can start a single phase with {s} but there's no guarantee that vertex t will end up in the other subset. Is there any way to do it?
I am building an app where a user controls inputs via multiple sliders each with discrete steps. The app then uses the combination of slider values to run some calculations and returns back an output value. The sliders are meant to be highly responsive, so the user can immediately see the impact of their input combinat...
im looking for a formal proof to demonstrate that all regular language is in L (logarithmic space). I deduced that all regular languages has a DFA that accept them, so if i find a way to transform all DFA to a L-Space Turing Machine, i would be able to prove this. Thanks for helping.
Let us start this question out, by defining for a Turing machine, the set of words it doesn't halt on. Define: $P(M)=\{w\in\Sigma^*|M$ doesn't halt on $w \}$ We know that the $HALT$ problem is $RE\setminus R$ - thus every TM $M$ that computes $HALT$ has a word it doesn't halt on, i.e $P(M)\ne\emptyset$. From this, aris...
First question: How would one prove that by removing free (unbound) variables from lambda calculus, and allowing only bound variables, its power is not reduced (it is still Turing-complete) ? Second question: Is the proposition given above really true? Is lambda calculus sans free variables really Turing-complete?
Is something like this possible: You have state A,B,C all pointing towards accepting state D. Is this allowed? Where online can I find a list of rules that define how an automata must be drawn or conceived?
I'm asked to draw a DFA of this {$\epsilon$, 0} but have no clue what it means. Can someone help me understand what the automata is supposed to do? I know that $\epsilon$ is the symbol for empty word. As an example having to make an automata for this {w| w contains at least two 0s and at most one 1} is pretty understa...
Can you enumerate a class of languages in such a way that the description of every language/ machine enumerated encodes where it was in the enumeration? Ex:if you are given the description of the bth machine/language enumerated you could quickly check, by some tag or marker in the description of the bth machine / langu...
I have a language $$ L = \{ww^R, w \in \{ab\}^5\}$$ I know this is a regular language because it is finite (since w can only be of length 5). I want to prove it's a regular language, so I'd create a regular expression for it. Theoretically, my regular expression could be the union of all strings in the language, but is...
I have a function whose time complexity is given by the following recurrence: \begin{equation*} T(n) = \begin{cases} \mathcal{O}(1) & \text{for } n=0\\ T(k)+T(k-1)+\mathcal{O}(1) & \text{for } n=2k\\ T(k)+\mathcal{O}(1) & \text{for } n=2k+1\\ \end{cases} \end...
I have a point's array of some 2d shape(polygon). The polygon could be either crossed or convex, I don't know it. And I want to join those points in the correct order. My first thought was to take some point as an origin and start looking for the closest one and so on. But this approach doesn't work for some crossed p...
Came across this in a book, and I'm wondering why the following language is regular? $$ L = \{a^nww^R: n \geqslant 0, w \in \{a,b\}^3\}$$ Is it correct to say that $$ \{a^n : n \geqslant 0\} $$ is a regular language because it can be expressed by a regular expression $$a*$$, and $$ \{ww^R: w \in \{a,b\}^3\} $$ is a reg...
Do any one give me some hints to solve this problem. Explain is steps by steps.Thanks
So as the title says i m trying to find this NFA. So far i thought to make an NFA that "guesses" what comes after the first 0 and i got this: After some time trying to get rid of all the extra (7 !) states i put in i got to this beauty: But now i cant figure out how to get rid of the one extra state. Also if you hav...
I developed an algorithm that transforms any simple connected graph, cyclic or not, into a tree. The resulting tree is syntax-preserving, in a sense that it allows to reconstruct the original input graph and only the original input graph. In other words, the constructed tree preserves adjacency information, while resol...
Let’s say I have a JavaScript loop iterating over input of size N. Let’s say all elements in N are unique, so the includes method traverses the entire output array on each loop iteration: let out = [] for (x in N) } if (!out.includes(x)) { out.push(x) } } The worst case runtime of the code inside the loop seem...
$L=a^*b^*c^* \setminus \{a^n b^n c^n \mid n \geq 0\}$ can be proved as context-free by partitioning it as $L = \{a^nb^mc^* \mid n \neq m\} \cup \{a^*b^nc^m \mid n \neq m\}$ and further dividing each $\neq$ into smaller and larger. You will have four sets. You can give CFG's for each. Then since CFGs are closed under un...
I was given a question and don't really know to solve it. Given a regular language $L$, is the following language also regular? $$L_1 = \{ w \mid \text{each prefix of } w \text{ of odd length is in $L$} \}.$$ I think that $L_1$ should be regular, but I don't have a clue how to prove it. Thank you for any input.
An enumerator is defined as a 7-tuple: https://en.wikipedia.org/wiki/Enumerator_(computer_science) A Deterministic Turing machine is defined as a 7-tuple: https://en.wikipedia.org/wiki/Turing_machine How are these definitions different? Can a DTM M simulate an enumerator E, for part of its computation can it call an en...
In all the examples I have seen, the pumping length $p$ is not specified. The string is a pattern that somehow has the $p$. E.g. when proving $L=\{a^n b^n c^n | n \geq 0\}$ is not context free, we assume the string $s \in L$ has the form $a^pb^pc^p$, and continue. Do we have to select such a general pattern? E.g. Can I...
Here is the full problem. You need to calculate Euler's totient function of a binomial coefficient $C_n^k$. Input The first line contains two integers: $n$ and $k$ $(0 \le k \le n \le 500000)$. Output Print one number $\varphi (C_n^k)$ modulo $10^9+7$. My thoughts: It is known that $$\varphi(a)=a \prod_{p|a}(1-\frac{...
In this book ‘Theory of computation’ By Dexter Kozen on page 313,exercise 127 he says "A set of total recursive functions is recursively enumerable (r.e.) if there exists an r.e. set of indices representing all and only functions in the set. For example, the complexity class P is r.e., because we can represent it by an...
I have found that X + Y sorting is an open computer science problem but that book was too old and then I have google it but didn't find any strong evidence that it is still open or there is an algorithm that can solve it in O(n2) comparison without using Fast Fourier Transform. Is there any algorithm proposed that can ...
I can't seem to find a solution to the following question. Given the following grammar for palindromes: $$G_{pal}=\{\{a,\dots,z\},\{P\},P,R\},$$ with $R$ consisting of the rules $$P \to \epsilon \mid a \mid aPa\text{ for every }a \in \Sigma.$$ Prove that every palindrome $w$ is in $L(G_{pal})$: $$w = w^r \longrightarr...
I'm wondering if PDAs with more than one initial states are also accepting context free languages. If found that question on this site about NFAs and would like to know if this answer is also valid for PDAs if one defines a new single initial state and connects this with the former initial states using $\epsilon : \e...
Decision Problem: Given a set $S$, is there at least a given $N$ $>$ $1$ amount of solutions, for an $Exact~Cover~by~3-sets$ for $C%$? $s$ = $1,2,3,4,5,6$ $c$ = $[[1,2,3],[4,3,2],[4,5,6],[5,1,6],[5,6,3]]$ Solutions $[1,2,3],[4,5,6]$ $[4,3,2],[5,1,6]$ $N$ = $2$ Yes, there are $N$ solutions. Algorithm Remove sets that ...
Here is an excerpt from Andrew S. Tanenbaum, Computer Networks, 5th edition, Chapter 3 (The data link layer), Page 213: When the polynomial code method is employed, the sender and receiver must agree upon a generator polynomial, $G(x)$, in advance. Both the high- and low-order bits of the generator must be 1. To compu...
Given two regular languages $A,B$ on the same alphabet $\Sigma$, I want to show that the following language is regular: $$ \{a_1b_1 \ldots a_kb_k \in \Sigma^* \mid a_1,\ldots,a_k,b_1,\ldots,b_k \in \Sigma,a_1\ldots a_k \in A, b_1\ldots b_k \in B\}. $$ However I simply do not understand how I'm supposed to do this. Simp...
I have two 4-bit 2's complement numbers a,b, and their sum in s (Also a 4-bit 2's complement number). Using only the basic logical operations, I need to write a procedure to find if an overflow occurs. If there is an overflow, the output needs to be 1000 otherwise it is 0000. The inputs in this procedure are a, b, s, ...
A computer has a cache memory and a main memory with the following features: - Memory cache access time: 4 ns - Main memory access time: 80 ns - The time needed to load a line in cache is 120 ns. - Write-through policy. If the hit ratio in this computer is 95 % and the 90% of the memory accesses are read opera...
I am having trouble finding the PDA with 1 state for this one. So far my solution is this but i cant figure out how to get to 1 state. Alphabet: {a, b}, Stack alphabet (the first symbol is the initial one): $ S (this can be changed,i just wrote these 2), Acceptance condition: empty stack, Deterministic (DPDA): false T...
What is the difference between the Magnitude and the Phase Spectrum of the Fourier Transform?
The problem I have two sets of numbers and need to find a mapping between those two sets, so that the total distance between two mapped numbers is as small as possible. Two numbers must not be mapped if they are farther apart then 0.18. As many numbers should get mapped as possible. Also, the sets are not necessarily t...
i encountered the following problem: Exact2IS ={G has exactly 2 independent sets} Assuming that given a graph G i can find an independent set how can i check if G has exactly 2 independent sets. (i can check if a graph contains independent set in O(1) and also find some independent set in O(1)) I was thinking on find s...
Problem Given data consisting of $n$ coordinates $\left((x_1, y_1), (x_2, y_2), \ldots, (x_n, y_n)\right)$ sorted by their $x$-values, and $m$ sorted query points $(q_1, q_2, \ldots, q_m)$, find the linearly interpolated values of the query points according to the data. We assume $q_i \in (\min_j x_j, \max_j x_j)$ I he...
Is there a simple linear algorithm for finding in an array A two such elements that $A[i] > A[j]$ and $i - j$ is as large as possible? If one wants to actually return the indices, then linear memory usage seems impossible to avoid. If the only result needed is the value $i - j$, i.e. the distance, can we get away with ...
I want to ask about the definition of regular languages. My book says there has to exist a deterministic finite automaton that recognizes it. Does this mean the finite automaton recognizes exactly this language and nothing else or it can recognize possibly some other words not in the language?