instruction stringlengths 35 29.1k |
|---|
Let $O$ be an optimisation problem and $P$ its decision variant.
I know that $O$ is said to be NP-hard if $P$ is $NP-$complete.
However, what to say about $O$ when the decision problem $P$ is no more in the class $NP$, and thus it's no more $NP-$complete(the algorithm of deciding is pseudo-polynomial and there is no be... |
What are they and what are their differences?
Unbanked access
Banked access
Common memory access
[EDIT]
This question is originated from my reading of MPLAB XC8 PIC Assembler User's Guide where the latest XC8 compiler requires a preprocessor directive to contain or wrap assembly codes in sections called PSECT. I hav... |
Most of the discussion about RNN and LSTM alludes to the varying ability of different RNNs to capture "long term dependency". However, most demonstrations use generated text to show the absence of long term dependency for vanilla RNN.
Is there any way to explicitly measure the time dependency of a given trained RNN, mu... |
I am trying to understand Kempe's algorithm to $k$-color a planar graph. This is what I understand till now:
Trying to 6-color a planer graph ($k=6$)
Find a vertex of degree <= 5 ($k-1$)
Remove this vertex
Color the rest of the graph using a recursive call
Put the vertex back, since its degree was at most 5 ($k-1$), w... |
Consider the methods used by processes P1 and P2 for accessing their critical sections whenever needed, as given below. The initial values of shared boolean variables S1 and S2 are randomly assigned.
Method used by P1
while (S1 == S2); Critical Section S1 = S2;
Method used by P2
while (S1 != S2); Critical Section S2... |
I know this is a similar question to this post, but I want to further clarify my understanding.
In the picture from wikipedia:
I understand that every problem that's in $P$ is also in NP.
does this mean that everything from MergeSort, to linear search is in NP [though not NP-HARD]? Or does this only apply to decision ... |
Consider the following code sequence that is executed on a processor that doesnt supports stalls and only supports ALU-ALU forwarding :
I1: lw $1, 40($6)
I2: add $6, $2, $2
I3: sw $6, 50($1)
I4: lw $5, -16($5)
I5: sw $5, -16($5)
I6: add $5, $5, $5
Now the only way to run this code on this processor is to insert nops .... |
I implemented logical expressions using a binary tree in C++. Now I want to be able to simplify such an expression using rules like e.g.
but have issues with the commutativity. Assuming the expression is
then the tree would look like this:
xor
/\
xor b
/\
xor true
/\
true a
The expressi... |
If I have a router that has a vulnerability that allows an attacker to gain full control it, does using a VPN on the network with the said router prevent an attacker from being able to snoop on the connection?
In other words, does using a VPN secure the connection from a device to a router? And would a VPS make a diffe... |
I try to show that this language is regular:
$L = $ { w $\in \ (a,b) ^ * $| for every u substring of w, $-5\le|u|_a−|u|_b\le5\}$
If I build a NFA and run on it every substring of w (skip other letters every time) - and only if they are all accepted (follows the condition) then accept w.
Is it possible in NFA? Is there ... |
I have a bit of experience with loop invariants but I'm not really clear on them. I'm trying to learn them through an Algorithm I have.
Reverse(X,Y)
n = X.length
for(i = 1 to n)
Y[n - i + 1] = X[i]
return Y
This copies values in array X into array Y in reverse order, and returns array Y. If X and Y bo... |
I have to write some algorithm in pseudocode for a paper. For this I have the "$\leftarrow$" to assign a value.
$x \leftarrow y^2$
now I want to write a method which adds to the variable. In normal Python code I would write x += 1 for this. Is there a style convention how to layout this in pseudo-code in a paper? I don... |
I've been working on a binary tree optimization problem with two choices of loss function (let's call them A and B). I'm fairly certain that the problem of minimizing either A or B individually has the optimal substructure property. That is, if I have a set U and I construct the A-minimizing tree T out of all the eleme... |
Are GPUs or CPUs capable of selecting n elements from an array in sublinear time using indices? If so, what would be some good alternatives to achieve this?
Lets say I have an array A = {1, 5, 6, 3, 6, 2} and indices I = {2, 5, 2, 4, 1, 0}. The resulting array should be: B = {6, 2, 6, 6, 5, 1}. The time complexity for ... |
While a basic algorithm to check for primality of a number 'n' [checking if a divides n for all a less than n] would take O(n), AKS test was the breakthrough after which it was placed in P complexity class.
|
Functional programming is said to be superior in many ways to imperitive programming. But I am struggling to find a simple functional way of writing:
x = f(y);
g(x,x)
Since in functional language this would be g(f(y),f(y)) thereby calling the function f twice. Whereas in imperitive language this seems more efficient. ... |
The wikipedia article mentions:
For graphs of bounded clique-width, the longest path can also be solved by a polynomial time dynamic programming algorithm.
However there are no references and I wasn't able to find anything relevant in literature. Nor was I able to come up with a naive algorithm that would achieve thi... |
When we quantify infinite sums, we do so by taking the limit as $i$ goes to infinity. For example, we look at $\lim_{n\rightarrow \infty}\sum_{n\in \mathbb{N}}n$, and then we say that this diverges and does not have a sum.
When we do diagonalization, we iterate over an infinite list while indexing each list item by a n... |
I have the following data:
A set $V$ of tasks, the starting time $s_j$ of each task and the duration $p_j$ of each task.
A set $K$ of resource, each resource has an availability function $R_{k}$ that is piecewise constant.That is, for each $t = 0, .., T-1$, we precise $R_{k}(t)$ the number of units available at $t$. ... |
There are $n$ sets of distinct positive integers, $S_1,\ldots,S_n$.
There is a set of recipes that allows us to construct tuples of integers from these sets. For example, the recipe {1,2} allows us to construct tuples of two integers: one from $S_1$ and one from $S_2$. Each integer can be used in at most one tuple. Wha... |
Background
I once implemented a datatype representing arbitrary real numbers in Haskell. It labels every real numbers by having a Cauchy sequence converging to it. That will let $\mathbb{R}$ be in the usual topology. I also implemented addition, subtraction, multiplication, and division.
But my teacher said, "This does... |
I have been reading this tutorial on time complexity, and I am a bit puzzled on its explanation of big $O$ notation. It writes:
$O(g(n)) = $ { $f(n)$ : there exist positive constants $c$ and $n_0$ such that $0 \leq f(n) \leq c*g(n)$ for all $n > n_0$.
The way I understand it, $c*g(n)$ denotes $c$ multiplied by $g(n)$... |
Exercise G in Chapter 6 of Richard Bird's Thinking Functionally with Haskell asks the reader to prove
foldl f e . concat = foldl (foldl f) e
given the rule
foldl f e (xs ++ ys) = foldl f (foldl f e xs) ys
There's no mention whether the given rule applies to infinite lists, nor does the answer in the book mention ... |
This appears to be a very basic question for this Stack Exchange, but hopefully still welcome. I am a math teacher and wanted to write a program to demonstrate normal distributions. I wrote a simple code in Processing that essentially flips a coin a certain number of times and makes a histogram of the results:
int pile... |
Is there an efficient classical algorithm that generates samples from the uniform distribution (or a distribution that is close to the uniform distribution in total variation distance), over the set $\{0, 1\}^{n}$, for a fixed $n$?
We can easily express the uniform distribution in terms of a formula:
$Pr(X = x) = \frac... |
I've been doing lot of programming challenges lately (such as on leetcode.com) and often find myself in a situation when I cannot pick a method for solving a problem. I stuck with questions like - should I use brute force or greedy search would work better or maybe dynamic programming would do the job? Then I start cod... |
I'm struggle on this practice question from this site....
Calculate the number of bits required in the address for memory having
size of 16 GB. Assume the memory is 4-byte addressable.
MY QUESTION IS: what is the difference between an "address" and "the memory is 4 byte addressable"?
I understand an address would be ... |
In CLRS the author said
"Technically, it is an abuse to say that the running time of insertion sort is $O(n^2)$,
since for a given $n$, the actual running time varies, depending on the particular
input of size $n$. When we say “the running time is $O(n^2)$,” we mean that there is a
function $f(n)$ that is $O(n^2)$ such... |
I'm attempting to develop from scratch a simple regex engine. I would like for my engine to have the ability to report, "The regex matched on a substring of this line starting at index and ending at index ."
It makes sense to me how to accomplish this using recursive backtracking.
However, I'd like my implementation ... |
Inorder traversal of BST is always sorted.But can we say Binary tree is BST if and only if inorder is sorted?I mean if inorder is sorted,can we conclude it is always BST?
|
Regarding the post Which combinatorial problem is similar to this problem?, it is quite hard to believe that, in the absence of information on the cost function, there is no algorithm better than exhaustive search to tackle this apparently easy-to-understand problem. I surfed the Internet and found something called the... |
A problem is said to be NP-hard if every problem in NP is reducible to that problem in polynomial time.
Hence, if P=NP, wouldn't that imply that every problem in NP is reducible to every possible problem, in polynomial time?
However the diagram above seems to imply that if P=NP, there exist problems outside of NP-hard... |
I am completing a final year project for hand gesture recognition using Hidden Markov Models
I have a fair understanding of Hidden Markov Models and how they work using simple examples such as the Unfair Casino and some Weather examples.
I am looking to implement multiple Hidden markov models where each model correspon... |
Consider the following eqautions used in LSTM ( taken from Andrew ng's course on Sequential model)
In an LSTM model, LSTM Cell has three inputs at any time step t
Input($X_t , a^{(t-1)}, C^{(t-1)})$,
Here $X_t$ is the input vector, $a^{(t-1)}$ is the previous hidden state and $ C^{(t-1)}$ is the previous cell state ... |
Suppose we have 7 vertices, each of which corresponds to a different integer modulo seven. The edge exists between two vertices x and y if x + 3 ≡ y mod 7. For example, there is an edge between 0 and 3, and an edge between 5 and 2. What is the length of the shortest path between 0 and 1?
My method to get the answer is ... |
As I understand, the term "NP-hardness" is applicable when we also talk about optimization or search problems (i.e. return the satisfying assignment for 3-SAT). How do we formally define NP-hardness for such problems? The standard definition:
The problem is NP-hard when any problem from NP is polynomial-time reducible... |
Consider a turing machine with infinite states. This machine is identical to a regular machine. Only that number of states could be infinite.
Does this machine has more computational power than a regular machine ?
If yes - Then show that a machine with infinite states can recognize languages that cannot be recognized w... |
I have permutations:
4 1 2 5 3
4 3 2 5 1
numbers can be order magnitude of 1000 (fits in two bytes)
I want compute 32 bit (or better 64 bit) hashes, it should be non cryptographically secure but evenly distributed in 32 or 64 bits.
This second permutations is derived from first by swap 1-st and 4-th element (count for... |
I ask this question because of some statements in the question "What is the 'continuity' as a term in computable analysis?" making me suspicious.
I'm engineer, not computer scientist, so I don't have the Turing machine but logic gates in mind when I'm thinking about algebraic operations performed with devices.
I read t... |
Main
I am confused about the motivation behind the need for a separate notation for П-types, that you can find in type systems from λ2 on. The answer usually goes like so - think about how one can represent a signature of identity function - it can be λa:type.λx:a.x or λb:type.λx:b.x. The subtle part, they say, is that... |
I have the following recurrence relation:
$$T(n,k) = T(n-1,k)+T(n-1,k+1)$$
With the following base cases (for some given constant $C$):
For all $x \leq C$ and for any $k$: $T(x,k)=1$
For all $y \geq C$ and for any $n$: $T(n,y)=1$
I want to get a formula for $T(n,0)$. I think that it can be seen that after $i$ iteration... |
I'm trying to understand the definition of Transition point of a BST, as given in Demaine, Erik D., et al. "Dynamic optimality-almost." SIAM Journal on Computing 37.1 (2007): 240-251
Define the transition point for [a node]
y at time i to be the minimum-depth node z in the BST Ti such that the path from
z to the root... |
what would be the time complexity of DBSCAN algorithm if we use it for graph(sparse) clustering $O(n^2)$ or $O(n \log{n})$?
|
Hey I would like to find a answer for b. for a look to the picture that is my answer for it. But I dont habe any Idea how i can solve this. Thank you guys. (I had to translate it to english maybe it will be hard to understand it sorry about that).
|
The main question asked me to build a certain turing machine such that given a word w over {0,1}*
the turing machine accepts all such words and ends in accept state with the tape string = the word apended with the number of zeros in it. I built the state diagram of this turing machine..
But now there is a question next... |
I'm trying to show $L^2 \in \mathsf{REG} \implies L \in \mathsf{REG}$ with $L^2 = \{w = w_1w_2 \mid w_1, w_2 \in L\}$ but I cant seem to find a proof that feels right.
I first tryed to show $L \in \mathsf{REG} \implies L^2 \in \mathsf{REG}$, by constructing an machine $M$ that consists of two machines $A=A'$ with $... |
Been mulling over this one for hours, my initial thought was { w ε {a,b}* | w is empty, or ends with either ab or ba} but that's clearly wrong as neither aba nor bab are accepted by the automaton. If anyone has any idea what language this automaton accepts it would really put my mind at ease.
|
I'm a complete beginner. Please forgive my ignorance.Trying to learn about CSP online, I noticed a lot of the focus on search methods and heuristics which tell you which variable to expand next (e.g. most constrained variable) and those that tell you which value to try first (e.g. least constraining value) but I've yet... |
Consider some problem $P$ and let's assume we sample the problem instance u.a.r. from some set $I$.
Let $p$ be a lower bound on the distributional error of a deterministic algorithm on $I$, i.e., every deterministic algorithm fails on at least a $p$-fraction of the instances in $I$.
[Edit: For a given instance $s \in I... |
I have encountered the following question in my homework assignment in Data Structures course:
"Does a function $f$ exists such that: $f(n-k) \ne \Theta(f(n))$ for some constant $k\geq1$ ?"
I think no such function $f$ exists, but I do not know how to prove it (or give a counter-example if one exists).
|
Imagine a set of two to six squares within 3D-space. The goal is to generate a convex hull around these squares as efficiently as possible.
The following constraints are known:
Each of the two to six squares consists out of 4 vertices (a vertex being a 3D-vector). The vertex-data are stored in such a way, that every v... |
I have problem of inferring a rooted tree out of a connected simple graph.
The inference can be done by finding its minimum spanning tree, but the result is restricted by additional two types of condition:
There is a known root, which is s in the following example.
We know directions of some edges if they are chosen. ... |
Now that many computers use UEFI instead of BIOS to boot the computer, and UEFI instructions are usually stored in a hidden hard disk partition, does this mean the newest computers do not need to have ROM, which is used to store BIOS program in the old days? Or, was ROM unnecessary long ago even before UEFI existed, as... |
I recently came across a function called the strawman algorithm which the pseudo code looks like this:
StrawmanSubarray(A):
Initialize bestsum = A[0]
For left=0 to n-1:
For right = left to n-1:
Compute sum A[left] + . . . + A[right]
If sum > bestsum: bestsum = sum
The time comple... |
I am trying to work through this programming problem but I can't progress because I genuinely don't understand what it is that its asking me.
New Students are arriving at college. Initially the students don't know each other, and each has a circle of friends limited to themselves. As the semester progresses, groups of... |
While making name-tags for a dinner seating, I stumbled upon a problem which I can't find any algorithm to solve, and I'm not sure where to begin.
The goal is to write the name of each dinner guest on a card, completing one name at a time.
The names are written with old-fashioned rubber stamps, so only 6 letters can be... |
While solving a few CSPs by hand, I noticed that I don't actually need to check for arc consistency after each assignment.
All I needed to do was to formulate the CSP in such a way that I'm adding extra constraints based on the nature of initial constraints in an attempt to predict arc inconsistency.
After assigning a ... |
Given a weighted simple undirected connected graph $G = (V, E, w:E \to \mathbb{R})$, let $\tau(G)$ be the set of all its spanning trees. Is there an efficient algorithm to determine or estimate with high probability the number
$W = \sum_{\mathcal{T} \in \tau(G)} \sum_{e \in E(\mathcal{T})} w(e)$
without actually enumer... |
What is the complexity of the following algorithm in Big O:
for(int i = 2; i < n; i = i^i)
{
...do somthing
}
I'm not sure if there is a valid operator to this type of complexity.
My initial thought was as follows:
After $k$ iterations we want: (using tetration?)
${^{k}i} = n \implies k=\log\log\log..._k\log{n}\im... |
I know that this question is asked a lot of time but I don't understand or I think, I got lost when I was reading Introduction to algorithms
They said, "It is not contradictory, however, to say that the worst-case running time of insertion sort is Omega(n^2), since there exists an input that causes the algorithm to tak... |
I have two postal codes (fixed size of 6 digits) to compare and return the mismatch score.
where the mismatch weight of initial indexes is higher, then keep reducing.
Example postal code 123456, with index[0] ==> 1 is northern region, and if index[0] ==> 2 is southern region. so it should have very high mismatch score... |
I'm a physics student wondering how I can mathematically show the largest possible value of a 64-bit double. I don't want to know just the answer, since that is freely available. The equation I was shown by a professor says a machine number is represented as $s\times m \times 2^{E-e}$ with $m$ the mantissa and $e$ the ... |
Are there any efficient algorithms to find the shortest homotopy between two paths in a $2$-complex?
|
I have a DAG which I would like to do a topological sort on but there is a catch. I also have a relation NotBetween(X,Y,Z) which means that in the sort the node Y cant come "in between" node X or node Y. In other words, Y < X OR Z < Y.
I've thought about several approaches to this, but can't find a solution. Maybe I ca... |
So, I have been solving problems in Google Foobar for the past two weeks or so ans has reached Level 4. The first problem is as stated below and I have come up with a solution which is able to pass all test cases except one. I have been stuck on it for the past 3 days and hasn't been able to made any progress so far. C... |
Given a probability $p$ and an integer $N$, I would like to generate a sample $S$ of the population $P=\{0,1,...,N\}$ such that integer $m\in P$ is sampled with probability $p^m$.
It is trivial to do this in time $O(N)$. I am looking for an algorithm that can perform this sampling in (expected) time proportional to the... |
This is a general question and one that has bugged me for a long time.
I want to start working on an artificial universe, not something too ambitious but more of a basic concept. What I have in mind is a simulation that has a sense of time, has physics rules, some beings that interact with each other and are able to le... |
Average case complexity for linear search is (n+1)/2 i.e, half the size of input n.
The average case efficiency of an algorithm can be obtained by finding the average number of comparisons as given below:
Minimum number of comparisons = 1
Maximum number of comparisons = n
If the element not found then maximum number of... |
It is known that any power of cycle on even vertices is in Class 1, that is, can be edge colored in $\Delta$ colors, where $\Delta$ is its maximum degree which equals twice the power. But, I wish to know a specific algorithm to edge color the powers of cycles of even order.
Say, I have the square of a $18$ cycle. Now, ... |
I have a large number of equivalences which look like:
$(a \leq 0.54 \wedge b \geq 0.12) \vee (c \gt 0.98)$ $\Leftrightarrow$ $(x \leq 0.25) \vee (x \gt 0.91 \wedge y \geq 0.01)$
This is just an example. In general, formulae on either left or right side of the equivalence could be anything that takes the form of a dis... |
A generalized regular expression is like a regular expression but with one more operation allowed: complementation. The (generalized) star-height of a generalized regular expression is the maximal number of nested Kleene stars. The star-height of a language is the minimal star-height of a regular expression describing ... |
Here the problem is that I’m confused how to take the pumping value $p$ is it arbitrary any value?
Also I don’t know if I should prove all $3$ conditions of the pumping lemma is false or if any one should be proved as false by considering the given language as regular by proof by contradiction.
|
As far as I understand, cross compilers, emulators, and simulators are all ways that one computer system to be able to behave like or run another computer system.
What is the difference between these concepts? Are some of them equivalent?
|
The normal argument for a decidable language to build an enumerating machine is given as follows:
Let $M$ be a Turing machine which decides a language $L$, and let $s_1,s_2,\ldots$ be a list of all strings in $\Sigma^{*}$.
Consider the following enumerating machine:
Ignore the input
Repeat the following for $i = 1,2,3... |
I am reading Sangiorgi's paper On the origins of bisimulation an coinduction.
Definition 2.5, on page 5, defines Stratification of Bisimilarity:
Let $W$ be the states of an LTS. We set:
$\sim_0 \overset{\text{def}}{=} W\times W$
$s\sim_{n+1} t$, for $n\geq 0$, if:
(1) for all $s^\prime$ with $s \overset{\mu}{\righta... |
What exactly is the definition of church turing thesis? It's really confusing.
I want to prove the following statement:
A Turing machine with infinitely many states is more powerful than a regular Turing machine, as it can accept all languages.
How does this statement not contradict the Church–Turing thesis?
I don't ... |
I have a problem where I need to sort array of arrays.
For A being a array arrays (a1,a2,a3,...an)
were each a = {0...d} d=fixed number of elements.
*The assumption all sublists will have fixed number & same of elements n. *sublists are already sorted from least to greatest
For example A = [{-2,-1,3},{-1,-2,INT_MAX},{... |
Why is paging done only for user code (user space)? I know that the basic intuition behind paging is for managing larger logical address space in smaller physical main memory space. Won't the kernel size also be large? If the kernel code is large enough and the RAM size is small, then how is it managed? Please clarify.... |
Input: Set of machines M, Each machine has an availability array D_m[t],
set of activities A, for each activity j its starting time s_j,
its duration p_j and its consumption in D during processing.
Output: True or False if the usage for each machine at each instant is less than the availability
for each machine m... |
Consider a graph with vertices $V$ and edges $E$. The standard version of the min cut problem is to find the partition of $V$ into a (non-empty) subset $C$ and its complement $\bar{C}$ so as to minimize the number of edges going between $C$ and $\bar{C}$. Algorithms are known for this problem which solve it in polynomi... |
I am looking for the name (definition?) of X in:
A regular expression is X iff it has exactly one possible match.
Examples: <empty regex>, abc, \., [.], a|a, a{8,8}, \Q.*?\E
Counterexamples: ., a*, a|b, \d, a?
I would call such a regex constant. Can I use this name? Is there a similar concept?
Additionally, I would... |
On my computer science course's exam I was given the following task:
You are given $n$ segments that lies on the same line: $i$-th segment starts at coordinate $from_i$ and ends at $to_i$. Your task is for each segment count number of other segments that intersects it.
EXAMPLE INPUT:
5
7 8
8 9
0 3
2 7
10 15
EXAM... |
In order to prove that SAT is in NP, I need to come up with a polynomial time verfier (an algorithm). The Cooks Levin Theorem uses a non-deterministic Turing machine but that's not what I am looking for.
The idea of the algorithm could be that we put in the values and calculate the answer. Then, we check whether the an... |
I explain it better:
There are some algorithms that is clearly in NP, also NP-complete, but that under certain conditions they can be solved in polynomial time.
An example is Bin Packing, the decision version of the problem is an NP-complete problem and it's defined as follows in the book "Computers and Intractability"... |
I have a set of urns that can each hold different amounts of sand. Porters can deliver sand to each urn subject to a transport fee per unit of sand. Each porter has a finite amount of sand they are capable of delivering to each urn. The objective is to fill the urns with all the available sand while minimizing total co... |
There are algorithms that are said to be unfeasible to be applied in practice due to their time complexity. In textbooks, it's common to see remarks like "it would take hundreds of years" about using them. Unfortunately, it's often the case an inefficient algorithm is the only proven solution for an interesting problem... |
I am attempting to match human input of titles to a list of titles, and also show likely candidates when a human enters a title not known. Ideally I'd also have some way to suggest the human input of a truly novel title matches no known title as well.
As an example, I have a list of titles like this:
The Conspirators
... |
Consider a tree $T = (V,E)$ and its induced disjoint trees $T_1 = (V_1, E_1), T_2=(V_2, E_2)$ by the removal of an edge $e \in E$.
Is there a data structure that enables the immediate determination of membership of vertex $u \in V$? i.e., is $u\in V_1$?
Ideally a data structure with at most polynomial space complexity.... |
Let $F$ be the set of all Boolean formulae.
We say that a Boolean formula $\varphi$ is positive (=monotone) if
$\forall \alpha\in F,i\leq n$, if $\alpha\wedge\neg x_i\models\varphi$, then $\alpha\models\varphi$.
Let $\psi,\xi\in F$. We say that $\psi\vdash \xi$ if $\psi\models \xi$ and $\psi$ is equivalent to a formula... |
I have been trying to calculate the Big-O of the following algorithm and it is coming out to be O(n^5) for me. I don't know what the correct answer is but most of my colleagues are getting O(n^3).
for(i=1;i<=n;i++)
{
for(j=1 ; j <= i*i ; j++)
{
for(k=1 ; k<= n/2 ; k++)
{
x = y + z;
... |
Let's say I want to count the number of ways a string can be decoded, once encoding algorithm follows this map: 'a'=>'1', 'b'=>'2', ... 'z'=>'26'.
I could simply count it using a recursive function as follows:
def num_ways(s: str) -> int:
if len(s) > 0 and s[0] == '0':
return 0
if len(s) <= 1:
... |
I'm trying to build an supervised learning algorithm that deals with the regression problem of predicting a user's rating of a new incoming item based on the user's previous ratings on items. The ratings will be in the range of 1 - 5 (1 = best, 5 = worst).
Features a item will probably have:
author (nominal)
release c... |
I am curious about the NP-completeness (or if not, an efficient algorithm) for the following generalization of the subset sum problem:
In subset sum, we are given a number $t$ and a collection $S$ of integers with $|S|=n$, and ask if we can use a subset $S'\subseteq S$ to sum up to $t$. We can generalize the problem by... |
IBM designed IBM i as a "turnkey" operating system, requiring little or no on-site attention from IT staff during normal operation.
This is a dream of mine. Unfortunately, it costs a million dollars per nanosecond and I have $0 budget.
The opposite of this dream is the nightmare of being forced to manually babysit an... |
As the title says;
is this language decidable and how do you prove it?
$$L =\{\langle M\rangle \mid M \text{ is a Turing Machine and there is an input that } M \text{ halts on} \} $$
|
I ran into natural mergesort in this Wikipedia page: https://en.wikipedia.org/wiki/Merge_sort#Natural_merge_sort
However, I can't find much information regarding:
The algorithm(s) to achieve natural mergesort, and the pros and cons of each method
How natural mergesort compares to bottom-up mergesort (pros and cons of ... |
Question
My use case for what is described below is not a language or compiler implementation, but finding a reasonable semantics for this feature in a an abstract calculus.
Ideally, you give me a name for this concept, with references to a language that implements it and how that is done, or a theoretical exposition o... |
In programming language theory, people study the theory behind programming languages. But I have never heard any formal definition of programming languages themselves. What is the formal definition, not of a particular programming language like Python or C++, but of programming languages themselves?
|
i, sq ← 1, 1
while sq < n
for j ← 1 to sq
k ← 1
while k ≤ j
k ← 2 ∗ k
i ← i + 1
sq ← i ∗ i
I have expressed the running time of the "for" loop as a sum in this way :
$$\sum_{j=1}^{i^2} \log(j)$$
In a similar way, how can I express the running time of the outer "while" loop with ... |
Let $T_1$ be a total Turing machine deciding language $L_1$, and let $I_1$ and $I_2$ be two separate inputs to $T_1$. Further, let $I_{c}$ be $I_2$ concatenated to $I_1$ with some separation symbol in between, and let $S_{T}(I)$ be the number of steps total TM $T$ needs to run until it accepts/rejects input $I$. I am w... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.