instruction
stringlengths
35
29.1k
I coded a solution for the famous Travelling Salesman Problem but my code does not work properly, although it seems okay. In a grid of size m x n, you are allowed to move only down/right, and you need to go from the top-left corner to the bottom-right corner. Each sell has a reward value. How much is the maximum rewar...
Suppose we are given a set of $n$ points on the plane. How many different planar graphs can we form on those $n$ vertices, assuming that each edge must form a straight line between the two vertices it connects? I'm interested in either showing for every set of points there are $2^{o(n\log(n))}$ planar graphs; or showi...
Given An array of elements, all elements are positive (unsorted, but sorting is not a problem if required) The objective: To create two subarrays, so that abs(sum(array_1) - sum(array_2)) is the smallest possible The order of elements in the subarrays and the amount of elements don't matter but all elements should ...
Let A = { | M is a DFA which doesn't accept any string containing an odd number of 1s}. Show that A is decidable. The questions seems simple so I designed the following TM D that decides whether there exists a DFA with this property or not. D = "On input w: Construct a DFA B that accept any string containing an odd ...
I'm having a hard time wrapping my head around an algorithm, and not really sure if such a problem is known, common and possibly named, or if this is somewhat unique. I have 2 different clouds of points (2D). I need to generate an index map from one to the other by proximity. Points that are closest should map to each ...
Suppose given recurrence relation $$T(n)=T(\sqrt{n})+T(n-\sqrt{n})+n$$ $$T(1)=O(1)$$ How we can find an order of above recurrence relation? My attempt: I read following post, but get stuck in understanding that solution.
I've started learning C++, and I know a little bit of C. Something that always struck me as somewhat off was that the address-of operator is represented with the seemingly random ampersand (&) symbol instead of, say, the "at" symbol (@). Is there some kind of history behind this?
I was reading an article on how to solve sliding window problems and it said: Fast/Lagging This one is a little different, but essentially the slow pointer is simply referencing one or two indices behind the fast pointer and it’s keeping track of some choice you’ve made. In the House Robber problem you are trying to ...
I am wondering if there are any results for the following max-min assignment problem: Given $n$ machines $C = \{C_1, C_2, \dots, n\}$ with the $k$-th machine has power $C_k$. There are $m$ tasks $T = \{T_1, T_2, \dots, T_m\}$. Each machine can cover a subset of the tasks in $T$. Now we assign each task to a machine tha...
I would like to compute matrix multiplication A * B where A is Nx3 and B is 3x3. We also know that the elements of B only contains 0, 1, and -1. The content of A is arbitrary floats. Is there any speedup we can do?
How to compute a table of numbers (all possibilities), where repetition is not allowed and order is not important. Example: I have a set of prime numbers. In this example I have four: {3,5,7,11}, but it can be anything, and I want to choose every pair out of that set. To make things easier, I want to compute the indice...
I am trying to understand the following exercise from Introduction to algorithm (3rd edtion). Exercise 24.1-3 (page 654) Given a weighted, directed graph $G=(V, E)$ with no negative-weight cycles, let $m$ be the maximum over all vertices $v \in V$ of the minimum number of edges in a shortest path from source $s$ to $v...
How can I find an NFA for such a language, considering the alphabet to be {0, 1}. I've tried deriving it from the DFA (@Steven) and the regular expression (@Yuval Filmus), but no luck.
so i have this problem where: I have to accomplish a challenge A with n quests. Each quest gives me: p points and needs t time to be done. The object is to complete the challenge A that needs M points to be completed, in the least possible time. So let's say A has these following quests: q1 => p1=20 points, t1=5...
Given recurrence relation : $$ T(n) = \begin{cases} T(n-\log n) + 1 & \text{if } n \ge 1, \\ 1 & \text{otherwise.}\\ \end{cases} $$ To find asymptotic order of $T(n)$ i do as follow: Suppose $n=\log m$ now : $$T(\log m)=T(\log m-\log \log m) +1$$ $$\implies T(\log m)= T(\log \frac{m}{\log m}) +1$$ ,but in th...
On page 139, example 2.4.5 of "Categorical Logic and Type Theory" by Bart Jacobs demonstrates the interpretation of the abstraction typing rule with respect to a $\lambda 1$ category. Specifically, the category in question is $(\mathcal C \ell 1 (\Sigma), T_1)$: An object of $(\mathcal C \ell 1 (\Sigma), T_1)$ is a pai...
I don't understand why do we need to have more than two nodes in doubly linked list when all we need to maintain is the most recent and least recently accessed nodes. I was going through solutions for LRU Cache and it seems that all solutions seem to ignore this. The linked list's size keeps increasing. Can we do this ...
I have undirected weighted linear tree (path tree) with $n$ nodes ,and a weight function on edges $\omega: \mathbb{N}\to \mathbb{N}$, additionally given $k\in \mathbb{N}$, How we can find a path with lenght $k$ that have minimum number of edges in $O(n)$? I think as follow: Run Bellman Ford for each node and then se...
Given a graph $G = (V,E)$ and a probability $p \in [0,1]$ with which each edge is sampled from the graph $G$. The goal of the stochastic matching problem with fewer queries is to find a subgraph $H \subseteq G$ of fewer* edges such that we maximize the following ratio A realization of a graph $G = (V,E)$ with a paramet...
Given two strings $s$ and $t$, is there a way to find a string $a$ such that $d(a,s)=d(a,t)$, where $d$ is the Levenshtein distance? I am sure that a genetic algorithm would work pretty well but I would prefer an explicit solution.
Suppose "CFG+" was created, where it is identical to standard context-free grammars in every way, but rather than rules being limited to unions, was also closed over intersections, both between CFGs and between other CFG+'s. Consider non-context-free language: $$ \{ a^nb^nc^n|n≥0\} $$ With the addition of intersections...
I was working on a problem for some time now, and I made a data structure to solve it. To my surprise, I could not find any instance of this data structure on the internet (though I am certain someone has thought of this). Put simply, it is a sorted linked list and a sorted array, with the array pointing to spots a fix...
I am trying to understand the concept of big-O notation problem and came through this problem. Can you tell me how could $$O(n) = 1 + \Theta(1/n)$$
Suppose in a 5 stage pipeline when the stall will actually happen if there is a RAW hazard? The stall will start after Instruction Fetch(IF) stage or Instruction decode(ID) stage? In few cases I see that the stall start after IF that is before executing ID and in multicycle pipeline, the stall starts after decode stage...
The following corollary can be found at page 653 of "Introduction to algorithms (3rd edition)" Corollary 24.3 Let $G = (V, E)$ be a weighted, directed graph with source vertex $s$ and a weight function $w: E \to \mathbb{R}$. Then, for each vertex $v > \in V$, there is a path from $s$ to $v$ if and only if BELLMAN-FORD...
Question on operating system If we execute kernel programs in the user mode and user programs in kernel mode what are some consequences
Given that the MMU does all the memory translations and etcetera, how does it maps a system consisted of multiple RAM chips? Are their spaces concatenated (e.g Chip 1 + Chip 2)? If so, how does that works given ASLR?
I'm looking at the pseudocode for chord algorithm here: // create a new Chord ring. n.create() predecessor := nil successor := n // join a Chord ring containing node n'. n.join(n') predecessor := nil successor := n'.find_successor(n) // called periodically. n asks the successor // about its predecesso...
Given an unweighted, undirected graph $G=(V,E)$ without loops or multiedges, and vertices $v,w$, one can use breadth-first search to check if $v$, $w$ are connected, and in particular the algorithm will return a shortest path between them. BFS has time complexity $O(|V|+|E|)=O(|V|^2)$. Now let $k$ be some fixed integer...
Suppose that: You're using a programming language that doesn't support fixed-point or floating-point numbers. The said programming language rounds down divisions, e.g. 12 / 5 = 2. You're adding 18 trailing decimals to represent fixed-point numbers in your algorithm. for instance, you'd represent 0.5 as 500000000000000...
I have a problem like this: we have an array of elements like this : (a0,b0) (a1,b1) . . . (an,bn) and I wanna find the number of elements which have one of this two condition: 1) if ai>aj and bi<bj then:count:=count+1 or 2) if ai<aj and bi>bj then:count:=count+1 I've already found an algorithm that is $O(n^2)$, but I...
I have the following regular expression for the set of all strings such that each block of five consecutive symbols contains exactly two 0's (consider the alphabet to be {0, 1}): (0+1+ϵ)4+(11100+ϵ)r(0011100r)*(00111+ϵ) r=11+(110+ϵ)s(0110s)*(011+ϵ) s=(0+10)*(1+ϵ) How should I convert this into an NFA? Please explain ...
I'm looking for an algorithm/insight into a problem that's an extension of the Maximum Weight Matching problem. The maximum weight matching problem looks for the max-weight set of edges that contain 0 common vertices. The problem can be thought of as grouping the vertices into sets of 2 such that no vertex belongs to m...
In 2014, inspired by Regex Golf, I started exploring, along with a mathematician going by the name teukon, what could be done in the unary domain in ECMAScript regex that went significantly beyond matching primes and powers of 2 (both of which were puzzles in the Regex Golf site). This is a dialect of regex that includ...
I have a set $S$ of intervals. I'd like to store them in a data structure, so that I can handle the following query efficiently: given a query interval $q$, count the number of intervals $s \in S$ that contain $q$, i.e., count the number of intervals $s \in S$ such that $q \subseteq s$. (This is like a stabbing query,...
I'm in a scenario where ~30% of the time, my array is almost completely sorted, and the other 70% of the time, it is basically completely random. I want to quickly determine if my list is almost sorted, use insertion sort if it is, or quicksort otherwise. I've been searching this up all day but no luck. The alternative...
int i=0,j; while(i<=n) { while(j<=(i+1)){ a=a*a; j++; } i++; This question was in my homework and we have to calculate the frequency count of the code above. I am having difficulty understanding how the code will execute and how many times will the loops execute. I know the inner loop is dependent on 'i', ...
The stream cipher is an encryption algorithm that was designed to approximate an idealized cipher, known as the One-Time Pad. It's crucial for a stream cipher to remain secure is to have a pseudorandom generator that hard to predictable and a seed that was never used. For this to be achieved, I assume we need to have a...
I am grading an exercise in Automata and Formal Languages and see many of the students use $\{\varepsilon\}$ as the empty language. At first I thought this was an error, and I have asked the lecturer who confirmed. But I keep seeing this and I'm losing my confidence. Is this kind of thing used by anyone? Meaning, does ...
Let me explain my trouble by another example. The wiki page says that Lattice problems are an example of NP-hard problems However, by clicking NP-hard, i find this definition A decision problem H is NP-hard when for every problem L in NP, there is a polynomial-time many-one reduction from L to H. What the fact? Lat...
I know there are many algorithms for finding a pattern in a text like Boyer Moore, KMP, RabinKarp and so on. I want to know what is the one that is mostly prefered by text editors and IDEs, as I find them efficient.
If we have a graph $G=(V,E)$, can we find a vertex cover with size $\lceil \log |V| \rceil$ in polynomial time?
Suppose there are three categories of people. Type X, Type Y, Type Z. In each type, there are two objects of subtype Type 'a' and type 'b'. For example. X: a1 , a2 , b1 , b2 Y: a3 , a4 , b3 , b4 Z: a5 , a6 , b5 , b6 Each object of type 'a' should be assigned with an object of type 'b'. But it is desirable not necessary...
if we have a Graph (V, E) and for all nodes v_i, v_j exists a path from v_i to v_j can you give me an example of such graph with dominating set size 2 and doesn't have a vertex cover of size 3?
Given $k$, a $k$-domino is a non-ordered pair of integer values of $[\![0, k-1]\!]$, for example $\langle 0, 3\rangle$ or $\langle 1, 1\rangle$ are dominoes, the domino $\langle 3, 0\rangle$ being the same as $\langle 0, 3\rangle$. A sequence of length $n$ of dominoes is a sequence $(d_0, d_1, …, d_{n-1})$ where $d_i =...
Specifically, how many bitwise operations (approximately, could be just order of magnitude) occur each time a Bitcoin ASIC miner performs a SHA-256 hash in typical mining computation, i.e. as it guesses the nonce and computes the hash of the 1 MB block to be added to the blockchain? By bitwise operation, I mean the mos...
I want to generate a grammar that can't generate the words $qw$ and $wq$ but can generate the word $qwwq$. In other words, $L(G)=\{m ∈ \{q,w\}^* \mid m \neq wq,qw \}$. My grammar: \begin{align} &S \to qSw \mid wSq \mid qXq \mid wXw\\ &S \to qYw \mid wYq \mid q \mid w\\ &X \to qX \mid wX \mid qXw \mid wXq \mid ε \\ &Y ...
The Heesch number of a shape is the maximum number of layers of copies of the same shape that can surround it. For example the following shape (in the center) has a Heesch number of 4, because we can get at most 4 layers to surround it: Given a shape, is there an efficient algorithm to compute its Heesch number? The o...
I want to make a regular expression for the language consisting of words whose length is at least 3 and which contain at most two $x$'s, that is, $$\{w\in \{x,y\}^* \mid |w|\geq3\text{ and the number of }x\text{'s in }w \text{ is at most } 2\}$$ I wrote: $$ x^+(x+y)^+y^+ $$
If we have length $n$ unsorted array such that each element is integer and different, how to find $i$ largest numbers in linear time O(n)? but $i \leq n^{\frac{1}{2}}$. For example, if we have $A = [11, 6, 8, 1, 9, 100, 88]$ and input $i = 2$, then output is $[100, 88]$ (sorted).
Given $A=\left\{n\in \mathbb{N} \mid \text{$n$ is odd}\right\}$, we want to prove that if $S \in P$ then there is a Karp reduction from $S$ to $A$. My attempt: If $S \in P$ we can solve $S$ with a reduction that converts in polynomial time an input from $S$ to $A$, but I don't know how to prove formally the function a...
I was going through the playlist of an online course on Social Network Analysis offered by the Indian Institute of Technology (Madras), when I came across the claim that "when a lot of people get together and start discussing and debating conflicting ideas, true knowledge is known to emerge"-- and thus implying that Wi...
So I'm a newbie to c++. I know the basic concepts of c++ as I have already learnt c language. For competitive programming DSA is very important. But I don't know any STL functions. Is it possible to learn DSA without knowing STL? Which one is advisory to learn first(STL or DSA) so that it will be easy further? Also sug...
You have a few variables that can only assume the values 0 or 1 and you use those to form two polynomials. Is there a way to multiply the two polynomials that is faster than O(n²) where n is the number of terms in the polynomial? What I could come up with: As the variables are binary, they all follow the equation X²=X...
I have two similar questions, one about the H-trivial monoids and one about the R-trivial monoids. I cannot see the reason why H-trivial monoids, i.e., the monoids where H induced classes are singletons, coincide with the variety A of aperiodic monoids, also characterized as the monoids that satisfy the monoid equatio...
True random number generators use an unpredictable physical means to generate numbers, whereas pseudo-random numbers utilize mathematical formulas to produce a certain sequence of numbers that will appear random. I know that for PRNGs the efficiency is very high because they tend to generate a large quantity of random ...
We are learning how to solve recurrence relations in different ways (Forward Substitution, Backward Substitution, Master Theorem, etc...). I really thought I understood the topic since most of the problems were in the form of $aT(\frac{n}{b}) + f(n)$ where applying the Master Theorem is no sweat, but we're given this r...
I was going through the text Compilers: Principles,Techniques and Tools by Ullman et. al. where I came across the claim in the question by authors. Below is the definition and following it is the claim by the authors. Form of a Syntax-Directed Definition In a syntax-directed definition, each grammar production $A\rig...
I was going through the text Compilers: Principles, Techniques and Tools by Ullman et. al where I came across the following claim: L-attributed definitions include all syntax-directed definitions based on LL(1) grammars. What is the intuition or logic behind this statement? In the later sections they show that L attr...
Below is an excerpt from the Red Dragon book. $$(1) \quad S \rightarrow A_1 \quad A_2 \quad\{ A_1.in : = 1;\quad A_2.in : = 2 ;\}$$ $$(2) \quad A \rightarrow a \quad \{ print(A.in) \}$$ We find that the inherited attribute $A.in$ in the second production is not defined when an attempt is made to print its value durin...
Is it true that adding two numbers in base 2 is more complex than multiplying them? If so can someone please explain why this is the case?
I am trying to solve the Budgeted Maximum Coverage Problem. I have read and implemented the greedy and modified-greedy methods to solve it, as proposed by Khuller. Both are approximation algorithms. The greedy provides a $1/2(1-1/e)$ approximation, and the modified greedy guarantees $1-1/e$. I am trying to get better r...
New to the board, if this is the wrong section I apologize and I will delete it. Will be helpful to be provided correct exchange to guide me through this process of learning. If you have a given an array such as A[1...n] of numeric values (can be positive, zero, and negative) how may you determine the subarray A[i...j]...
This demonstrates the limitations of considering expected running time of an algorithm as a useful measure. For any $n>0$, describe a function $f:\{0,1\}^n \to \mathbb{N}$ such that $\mathbb{E}[f] = \mathbb{E}_{x\in \{0,1\}^n}[f(x)] = n^c$ for some constant $c$ and ${\sf var}[f] = E[f^2] - (E[f])^2 = \Omega(2^n)$. ...
There are two parties A and B going on. Some people are going to party A, some are going to party B. We are given instructions of the form different 1 3, meaning that person 1 and person 3 are attending different parties same 3 4, different 4 5, and then given a command tell 1 4 we have to answer if they are at...
We have been taught that: Insertion-sort will best work if we have a small list. Quick-sort will best work if we have a long list. Merge-sort will best work if we have a huge list. It is not intuitively understandable. However, let us say if we have a list with 20 elements and want to sort it because shifting action ...
Every RL paper has a section with some finite sample analysis/error bound/ convergence proofs. I have difficulty fully understanding such proofs and coming up with my own analysis for my personal projects. Can anyone suggest books/courses where I can develop my skills to do such work?
I was playing around with graph theory and I noticed that a directed integer graph with unique vertices $V$ and edges $E$ such that each vertex only points to vertices with a higher value can be used to enumerate all $n \choose 2$ ways to choose $2$ values from a total of $\left|V\right|$ possible values. For example: ...
Turing's Checking a large routine: Finally the checker has to verify that the process comes to an end. Here again he should be assisted by the programmer giving a further definite assertion to be verified. This may take the form of a quantity which is asserted to decrease continually and vanish when the machine stops....
I have a problem that is similar to the conventional interval scheduling algorithm but it is two dimensional, so I have another metric to take into account. My dataset format: Cars with the start and end time of parking, along with their length in meters. Total street length in meters. Number of cars. Opening hours of ...
LOOP = {<M,w1,w2,w3>: M is a Turing machine that doesn't halt on at least 2 of the wi} HPC = {<M,w> : M is a Turing machine that doesn't halt on w} Show that LOOP is polynomial time Turing reducible to HPC I am not sure how to begin solving this kind of problem. Also the question I am trying to solve brings up the def...
I am reading section 9.3.3 Dealing with local optima in Algorithms by Dasgupta et al. and the authors mention that in randomized restarts, it is four times likely to end up with a bad solution. They, then in the next sentence, imply that this a good thing as there will be fewer repetitions needed. Here's the text for ...
Can a finite automata not have a start state? I think it is possible for a finite automata to not have a start state. However, I'm not sure if I'm correct.
Show that a Turingmachine with tapes that are infinite in both directions semi-decides the same languages as a classical TM. Apart from the entry-word, the tapes are filled with empty spaces and the head's on the first letter of the entry-word Under "classical" TM we understand a TM that has a tape that starts at the...
Currently, I am writing code in Python for a paper that I'm reading and has been implemented in R already by the author. For this paper we have a corpus with $n$ documents and $m$ words. In one of the steps, I have to calculate the probability of document $j$ as follows: Step 4 We use document-term matrices with the G...
I'm not sure why the algorithm computes $c_k$ with $\sum_{j \neq k} w_j x_{i, j}$. Why does one need to ignore the $k^{th}$ feature here? I'm not sure how this is derived. Is this the result of taking the gradient with respect to the $k^{th}$ feature? Also what exactly is $a_k$ and $c_k$?
I have a problem that I am working on an algorithm for: I have $k$ sets of distinct positive integers (each set is distinct, not necessarily across sets) $S=\{A_1,A_2,A_3,...,A_k\}$ where $\forall A_i\in S,\ A_i=\{a_{i1},a_{i2},a_{i3},...,a_{in_i}\},\ a_{ik}\in \mathbb{Z}^+, a_{ip}=a_{iq}\iff\ p=q$ (so $n_i$ would be ...
Can we express the matching capabilities of Unix library function glob() using a single-stack push-down automata, i.e. set of context free formal languages? If not, which is the minimal automata that we need? For those that do not know what glob() does, it is a pattern matcher generator using a few operators: * matche...
I'm trying to build a NFA for the following language $ L = \{ \sigma_1 \sigma_2 \sigma _3 \ldots \sigma _n \mid \sigma _1 \neq \sigma _n \}$. The catch is that for $ \Sigma $ such that $ |\Sigma|=2^k $, the NFA should have $\Theta(k)$ states. I was thinking of representing the letters in binary but I'm not sure what I ...
I am working on chapter 13 of CLRS. I am studying how to fix the colors on a red-black tree after deleting a black node. Suppose we want to delete the node 2. This is a black node. He will be replaced by his rith child in the RB-DELETE algorithm. Because we removed a black node and the node replacing it is black (all ...
I've recently stumbled upon a problem that I struggle realy hard with ever since. There are two large decimal integers, order of magnitude $10^6$. The task is to find how many bits in the binary representation of $A*B$ are set (how many 1s are there in the binary representation). Now, for small numbers, that's trivial....
I need to prove that determining whether a graph has a relaxed-Hamiltonian cycle (definition given ahead) is NP-hard. A relaxed-Hamiltonian cycle in $G$ is a closed walk $C$ that visits every vertex of $G$ exactly once, except for at most one vertex that $C$ visits more than once (i.e. that vertex may repeated twice ...
Definition: AtmostONESAT: SAT instance having promise of $\leq1$ witness. What is the complexity consequence if an instance of $SAT\in$ AtmostONESAT can be decided whether or not there is a witness in $P$? I believe the problem is similar to UnambiguousSAT (wiki says we get NP=RP if USAT is in P https://en.wikipedia.or...
What is the regular grammar of the language: $$L=\left\{a^nb^nc^md^m\left|n,m\ge 1\right|\right\}\:above\:\Sigma =\left\{a,\:b,\:c,\:d\right\}$$ My attempt: $$S\rightarrow aAbcBd|aXd$$ $$A\rightarrow aAb|\epsilon$$ $$B \rightarrow cBd|\epsilon$$ But I'm not sure if I'm right until here. Is it good? Edit: This language ...
Below is Question 8.1 in Algorithms by Dasgupta et al. There's a solution to this problem that uses binary search from here. Pasting the answer for posterity. My questions are: When they say input size, are they just referring to edges or both edges and vertices? Is it correct to say that we make at most $log( |E| l...
I would like to find the first positive solution(if there is one) to this equation: $$\frac{ax^2+bx+c}{dx^2+ex+f} = gx+h$$ The simplest way I fond would be to do the following: $$ax^2+bx+c = (dx^2+ex+f) * (gx+h)$$ $$(=)$$ $$ax^2+bx+c - (dx^2+ex+f) * (gx+h) = 0$$ $$(=)$$ $$Ax^3+Bx^2+Cx+D = 0$$ and find the roots of the ...
Let a relation $R$ be A-polynomial if there is a polynomial $p$ and a polytime algorithm $A$ such that for each $x$: If $(x,y) \in R$ then there is a witness $w$ of length at most $p(|x|)$ such that $A(x,w) = y$. For each $w$ such that $A(x,w)$ halts, we have $(x,A(x,w)) \in R$. Prove or disprove: Each $R$ in FP is ...
According to this we can do so by replacing every edge in the undirected graph with two edges backwards and forwards with the same capacity. But I'm having a hard time seeing how this prevents something like $f((u,v))=c$ and $f((v,u))=c$ (where c is the capacity in the original undirected edge) but then that means the ...
My understanding is that an NFA compiled using Thompson's Construction should have a running time that is linear in the length of the input string, with a space complexity that is linear with the length of the regex pattern. Consider this pathological example: $a^*a^*ab$, which should match at least one $a$ followed by...
Is there a standard name for an algorithm to handle this type of tree merge? Each node of the tree has a label. Nodes from the 2 trees should be combined if they have the same label, and their values should be totaled. Example: tree1 and tree2 are merged to produce "output" const tree1 = [ { label: 'Parent A', ...
I had this question in Learning theory, but it's really just a question in probability theory to be honest, so I'm gonna try to rephrase it in a way that really emphasizes what I was trying to do to solve it: Let $\mathcal X_N=\{0,1\}^N$, $\mathcal Y=\{0,1\}$ and define a uniform distribution, $\mathcal D_N$, on $\mat...
Self-driving car technology continues to attract popular attention and interest in today's media, but how would a computer scientist explain the theoretical nature of the problem? For example, we are frequently told that Sudoku and Go are examples of NP-completeness and PSPACE-completeness, and a range of practical pro...
I am wondering what do JAMZ, JAMN, and JMPC stand for in Tanenbaum's Mic-1 architecture. I know that MPC, the control store’s memory address register, stands for "MicroProgram Counter", but what does J mean? Likewise, there are 1-bit flip-flops where the values of N and Z are latched. The book says that if JAMN is set,...
Consider an operator $+$ defined on $P(\mathbb{N})$ as follows $$A + B = \{2x:\ x\in A\}\cup\{2x + 1:\ x\in B\}$$ Show that $A$ is $m$-reducible to $A+B$ and $B$ is $m$-reducible to $A+B$ As per the definition of reducibility $B$ is reducible to $A$ if there exists a total computable function $f$ such that for all $x\i...
I have a matrix over integer of size (50,50). I want to know whether it is possible to exchange rows and columns in such a way so that the transformed matrix is a lower triangular whose diagonal entries are non zero. Is there any algorithm which can determine this efficiently?
Consider an operator $+$ defined on $P(N)$ as follows: $A + B = \{2x\mid x \in A\}\cup \{2x + 1\mid x \in B\}$. Show that both $A$ and $B$ are Turing-reducible to $A+B$ I am kind of confused about this notion of turing reducibility thing. Does it mean that There is a turing machine which converts an input from $A$ to a...
I am a theoretical physicist, and new to CS.stackexchange, and have a little knowledge of CS, and in Machine Learning (only some general stuff). In physics we often analyze the spectrum of linear bound operators on finite dimensions, or simply try to understand the eigenspace of some matrix $M: v_j, \lambda_j$, where $...
I have a basic linear regression model that predicts the spread and total points of NCAA college basketball games. My inputs include various efficiency metrics about each team playing each other. A snippet of the data I am working with looks like: Team_1 Team_2 Off_Eff_T1 Def_Eff_T1 Pace_T1 Off_Eff_T2 Def_Eff_T2 Pace_...
Background I need such an algorithm inside an android app (home launcher) to show the recently used apps. I want to avoid simple LRU / MRU logic by combining those logics (or use an alternative if anyone has a suggestion). I don't want an app that was started 100x before 10 weeks to stay on top until another app was st...
I was refreshing some old tests about sorting algorithms, there was a question as follow: Question: we have n weight disks with different weights and we want to sort them pair by pair, How many times we have to weight in worst case (maximum comparisons) to sort the whole disks? the answer was $ \lceil \log n! \rceil...