instruction
stringlengths
35
29.1k
As explained in answers to this question, reduction from $A \le B$ can be represented in the following way. But in this example: from here At least as I understand it: The reduction is from $\overline{HP}$ to $L_2$, so $A$ is $\overline{HP}$ and $B$ is $L_2$. But it's implemented in the way that $M'$ is TM of $L_2$ a...
I came up with a solution for LeetCode Problem 4: Median of Two Sorted Arrays The expected efficiency of this should be $O(\log(m+n))$, where $m$ and $n$ are the lengths of nums1 and nums2. For my solution I decided only to process only the first half of nums1 and nums2. Does that count as logarithmic time, or is it st...
I am trying to build a classification algorithm having 28 classes. These classes consists of Logo of companies like adidas , Nike etc. I have very low dataset below than 100 images and greater than 70 images. I have trained CNN model but not got decent results . Accuracy is not good. I want to switch on pretrained mode...
Theorem 15.1 (Optimal Substructure of an LCS) Theorem Let the $X=(x_1,x_2,\dots,x_m)$ and $Y=(y_1,y_2,\dots,y_n)$ be sequences, and let $Z =(z_1,z_2,\dots,z_k)$ be any LCS. If $x_m = y_n$, then $z_k = x_m = y_n$ and $Z_{k-1}$ is an LCS of $X_{m-1}$ and $Y_{n-1}$. If $x_m \neq y_n$, then $z_k \neq x_m$ implies that ...
I saw the solution but can't understand the intuition of the following question: Let's define $$L^{\ge k} = \{w\in L : |w| \ge k\}$$ and $$L=\{\langle M\rangle | \exists k:L(M)^{\ge k} = \overline{HP}^{\ge k} \}$$ $L\in R$ because $L=\emptyset$, the proof is a bit long and anyway I understood most of the steps, My ques...
Just out of theoretical curiosity, is there a way to transform a 0-1 multimensional knapsack problem to a maximum clique problem? Or maybe even easier, to a maximum weighted clique problem (the weights in nodes)? I assume that since the decision counterparts of both problems are NP-complete, and all NP-complete can be ...
In computer architecture I'm confused between speculative execution & branch prediction. Are the same or different?
Context I have a graph $G=(V,E)$ with weighted edges, all weights are positive integers $w(e)\in\mathbb{N}\setminus\{0\}$. The weights represent the popularity/count of each edge, for example $w(e) = 22$ means that amongst all edges the edge $e$ was visited $22$ times. Approach Given two vertices $v,v'$ in $G$, how can...
I am a CS first year student, and as I was reviewing over the theta notation unit, I saw that $\Theta(1)$ exists. I was wondering if there was any real life example algorithm that has a running time of $\Theta(1)$.
I have created a function that generates a complete, directed, and weighted graph, represented in an adjacency matrix but most Bellman-Ford implementations use an adjacency list. Is it even possible to use an adjacency matrix for Bellman-Ford without increasing significant time complexity? What would be the simplest wa...
It's claim 1 from Bader Abu Radi's solution to this question. My solution (have no idea how wrong it is): $B$ finite $\Rightarrow$ $B\in R \Rightarrow$ exists TM $\langle M_B\rangle$ that halts $B$. *Wrong from here Let's define reduction $f$ from $A$ to $A \setminus B$, in the following way $f(\langle M_B\rangle , x)=...
I am asked to select the functions that are bounded by the Big-Oh function O(n^2): $f(n) \in O(n^2)$. $f(n) = \sum_{i=1}^{n} n$ $f(n) = \sum_{i=1}^{n} i$ $f(n) = n + n^2$ $f(n) = 1$ I choose the answers 1, 2, and 4: Simplifies to $n \cdot n = n^2$, which is bounded by $O(n^2)$ Simplifies to $\frac{n(n + 1)}{2} = n^2...
I'd like to learn about formal syntax of programming languages: how do we describe the syntax of a programming language and how it should be parsed? How do we assign formal semantics to a parsed program? I've looked at textbooks like this one, but it is very practical. I am looking for something more theoretical: an in...
How many hardware page tables (physical) and page directories are kept in the memory management unit? If a cpu has a 32 bit virtual address, the upper 10 bits are used for the page directory, the middle 10 bits for the page table, and 12 bits for the 4K page frame. Does that mean 1 page directory containing 1042, 32 bi...
I am asked to select the bounding Big-O and Big-Omega functions of the following program: void recursiveFunction(int n) { if (n < 2) { return; } recursiveFunction(n - 1); recursiveFunction(n - 2); } From my understanding, this is a Fibonacci sequence, and according to this article here, https:...
One of my previous questions on an exam was the following Can you reduce a decidable language to a given regular language? (decidable language $\leq _m$ regular language). If so, does this mean that you can reduce every CFL to a regular language? The reductions are all referring to many-one reductions. My intuition t...
I'm trying to solve this recurrence. I applied the iterative method: $$T(n) = T(n-2)+n^2$$ $$=T(n-4)+(n-2)^2+n^2$$ $$=T(n-6)+(n-4)^2+(n-2)^2+n^2$$ $$\cdot$$$$\cdot$$$$\cdot$$ $$=T(n-2k) + \sum_{i=0}^{k-1}(n-2i)^2$$ So $n-2k=1$ when $n=2k+1$ and we have: $$\sum_{i=0}^{(n-3)/2}(n-2i)^2$$ Now how can I demonstrate that th...
Before I start with my question, I want to state some notation I am using. I fix some arbitrary but fixed enumeration of Turing Machines (TMs) and denote with $\Phi_i : \mathbb{N}\to\mathbb{N}$ the function that is computed by the $i^\text{th}$ TM in this enumeration. Furthermore $\Phi_i(x) \downarrow$ denotes that the...
I am reading Algorithms by Sanjoy Dasgupta, Umesh Vazirani, Christos Papadimitriou and I am trying to understand how the number of steps $nF_n$ and $n^2$ were calculated. Here's the part of the book in Chapter 0 that mentions them. Functions fib1 and fib2 are written below the excerpt. fib1, which performs about $F_n$...
If you are given two languages $A$, $B$ and $$A \leq_T B.$$ Is it possible to $\overline{A} \leq_T B$ or $A \leq_T \overline{B}$? Here is my shot. Case 1: $\overline{A} \leq_T B$ This is only possible if $A \leq_m B$ exists and $B=\overline{B}$. As you can transform any many-one reduction to its complement, we can show...
Why can't you just use strongly consistent reads for all your DB reads, with retries on 500 responses? According to CAP theorem increasing consistency should probably lower availability, but can't the decreased availability (increased 500 responses) be handled fairly easily using retries? (assuming you are fine with a ...
Consider the language $\{ uv : \text{$|u| \ge |v|$ and $v$ contains a 1}\}$. I am unable to understand how to accept this language using a PDA. How to check the length condition as well as check if there's a 1 in the $v$ portion? The question has previously been posted here but I couldn't figure out much from the answe...
Let's say a function $f$ is called with parameter $n+1$. Since I use pass-by-value-result, value of formal parameter will be transmitted to the caller's actual parameter at the end of the call. Let transmitted value be 10. What will be the value of $n$? 9 ($n+1 = 10$) or still 10?
Suppose a person has a sequence (S) consisting of integer numbers and would like to split the sequence into a number (possibly one) of continuous parts. For each part independently, I then choose any integer value and removes all occurrences of this value in the corresponding part (note that there could be no such occu...
I am not a computer scientist and this is my first question. This question is a question in layman terms and I also want the answer in layman terms. When I searched hyper-computation. There was a list of models of hyper-computers. Now, my question is that what are the problems with those models and if it is possible to...
It is well-known that many modal logics can be viewed as fragments of $FO^2$, i.e. two-variable first-order logic. But is there a modal logic that is not a fragment, but is expressively equivalent to $FO^2$?
I saw this proof and I wondered if I could prove $E_{TM}$ with Rice's theorem similar to the one described in the answer. Can you do the same thing by letting $M$ to only accept empty strings? (the $M$ that is described in the answer of the proof) So If $x$ is empty, accept If $x$ is any non-empty string, reject.
I am referencing the Book Fundamentals of Computer Algorithms" by Ellis Horowitz et al. At the part which they talk about multi-threading models, user-level and kernel-level thread are introduced. And at the scheduling chapter, under multi-core processors, they talk about software threads and hardware threads. Even tho...
I'm reading The Algorithm Design Manuel and one part is kind of confusing to me The part that's confusing to me is how in the "Proving the Theta" section he proves that selection sort is Ω(n^2). I mean, I understand that for some (c) c.n^2 can be a lower bound for selection sort, however I don't understand how he prove...
I have found an algorithm that runs quite fast on Subset Sum problem few years ago (sometime around 2016). It basically sorts the input set in descending order (instead of the regular ascending) and does the backtracking then to arrive at results. It solves a 1,000,000 instance set in 5 minutes on my i5 8 GB RAM machin...
The first time I heard about functional programming, someone told me "it's more reliable to code in a functional style because your type system is like a proof of correctness". I recently learnt about the Curry-Howard (CH) correspondence and I think this is what he was using as a basis for his assertion about functiona...
Let's define: $Disagree(M_1,M_2) = \{x| $The result of $M_1$ on $x$ different from the result of $M_2$ on $x\}$ that means: if $M_1$ accept, $M_2$ reject and vice versa $NPA=\{L|\exists M_1,M_2$ Nondeterministic polynomial TM $ s.t. Disagree(M_1,M_2)=L\}$ Is $NPA=R$? I thought about this problem from 2 clashing ways:...
The following is psuedocode used to shuffle the contents of an array $A$ of length $n$. As a subroutine for shuffle, there is a call to Random$(m)$ which takes $O(m^2)$ time for an input $m$. Determine the runtime of the following algorithms. Algorithm 1: function Shuffle(A) Split A into two equal pieces A, and B (this...
I'm trying to find the average case number of times that max is assigned by the algorithm findMax included below. findMax(list): maxNum = -oo # negative infinity for k = 0 to len(list)-1: if list[k] > maxNum: maxNum= list[k] return maxNum The distribution I have considered is uniforml...
Given a tree in which each node has a given value, I want to process "Path Minimum Queries": given two nodes, what is the minimal value of any node on the shortest path between them? My original idea was to solve Least Common Ancestor Queries on any two nodes (using an Eulerian Tour Tree or the Binary Lifting Method), ...
I am looking to create a single tape acceptor Turing machine acting upon the language of any ASCII string, that would only accept strings that contains at least five G's and at most three T's, and rejects any other ASCII string input. I am kind of stuck on how the machine would know that it had encountered greater than...
How are the fundamental approaches to proving theorems by LCF and Automath different? Considering their modern descendants - Isabelle for LCF and Coq for Automath, both rely on type checking to do proof checking. Theorems in Isabelle have a theorem type and the only functions that can create instances of this theorem t...
I am looking for a reference for maximum cardinality weighted matching and the best running time algorithm for it. Maximum Cardinality Weighted Matching: Given an undirected weighted graph $G(\mathcal{V},\mathcal{E})$ where $\mathcal{V}$ is set of vertices and $\mathcal{E}$ is the set of edges where each edge $(i,j) \i...
I'm currently reading The Algorithm Design Manual by Steven S. Skiena as my first book to algorithms. Something in the asymptotic part is kind of confusing to me. Proving the Theta The analysis above gives a quadratic-time upper bound on the running time of this simple pattern matching algorithm. To prove the theta, w...
I am studying the Alpha Beta pruning algorithm here. function alphabeta(node, depth, α, β, maximizingPlayer) is if depth = 0 or node is a terminal node then return the heuristic value of node if maximizingPlayer then value := −∞ for each child of node do value := max(value, alphabeta(child, depth − ...
I originally posted this over on Software Engineering, but it was suggested that I repost it here. I am working on a BCD Floating point library and I'm a bit stuck on the EXP (antilog) functions. The goal is to maintain accuracy for the entire length of the number which could exceed 100 significant digits. So the requ...
What is the minimum number of states required in any DFA to accept the regular language $L$ over $\Sigma=\{0,1\}$ which accepts those strings that start with 1 and end with 0?
My question related to relativized world. I would like to know about how to show that class is different from another class in the oracle world and whether this applied to our real world. For example, let us have the following assumption: suppose for all oracles A we have $P^A \neq PSPACE^A$, then Does it imply that $P...
I want to calculate the frequency of each character in an array. (e.g ['a', 'b', 'o', 'p'] There are several ways to do this: A Simple brute-force over the array would need $O(n^2)$ time and $O(n)$ space Sorting the array first and serial counting the characters is a better solution with $O(n \log n)$ time and $O(n)$...
I see a lot of lecture notes where they use the term "congruence" (ex: congruence relation) or deriving usages such as "the expression e is alpha-congruent to e2". Could someone please explain what congurence means exactly in this context and give some examples to a noob without much knowledge about math/lambda-calculu...
I'd like to understand more how data can be stored on disk so it can be read quickly. I don't want to say database record because I'm not asking how to build a database. My question is closer to how would I build a table. I'm not asking about indexing. I'm thinking about you have an application that already has some a ...
I have been reading about AI search, specifically the toy vacuum cleaner problem and I would like to code an example of this but I am finding the description of the state hard to get my head around. The problem states that the AI needs to be able to move between squares, either left or right and if there is dirt in the...
I have a set of numbers $P=\{p_1,\dotsc,p_{|P|}\}$, where $|P|$ is the length of the set. I want to select a subset, $S$, from $P$ such that its mean is approximately equal to a predefined value $\mu_s$ . $$\sum_{x \in S} x \approx \mu_s * |S|$$ My problem: $|P|$ = 5000 $|S|$ = 1500 $\mu_s$ $\approx$ 90 $(target$ $mea...
In Coq, the nat, the type of natural numbers, has type Set. By the Curry-Howard Isomorphism, all propositions of type Prop are types of corresponding proof terms. How do nats or other instances of Set figure into this isomorphism? In other words, is there a correspondent for Sets in the Curry-Howard isomorphism, as the...
I want to verify semantics of a library of atomic primitives that I wrote. The idea is, only if the semantics of all the primitives are consistent with each other, an application that uses them could behave predictably. For example, a composition of a primitive Fx(lck) which takes exclusive lock on an lck object could ...
I'm trying to efficiently compute events in a time series by grouping them into buckets. My goal is to have as few buckets as possible. The constraint is that events within one bucket are all within a 30 minute time window. To get more concrete, let's assume I've got these events: time event 15:15 1 16:58 2 ...
I am studying balanced trees, especially AVL trees. My question is whether is it possible to create an avl tree given any set of numbers. is it possible to prove the following statement? Let $A$ be the set of integers. Given any set $A$, it's possible to create an avl tree corresponding to the given set of numbers. I...
I am curious to know if RTOS provides deterministic scheduling gurantees then why not all OS'es are RTOS? In what sense regular OS say linux better then RTOS say FreeRTOS?
"make sure you understand why for a non trivial property $S$, $\bar{S}$ is also non trivial" My assumption is: $S$ is non trivial property: There are L1,L2 such that $L_{1},L_{2}\in RE$ and L1 sattisifies the property whereas L2 doesn't. If i assign the complement then it still holds the same just reverse the relation...
I have problems interpreting the definition of asymptotic notation where the functions involve two different set of variables. I am quite confident with the definition of $f(n) = O(g(n))$ and its extension to the multivariable case ($f(n, m) = O(g(n, m))$). However I don't actually understand the meaning of $f(n) = O(g...
As the title says, if an algorithm delivers $m$ before multicasting $m$, does the validity property still hold? I would argue that it doesn't matter, as the purpose of validity is to ensure that the process reaches consensus with the other processes that it multicasts to.
This question is about the correct terminology. Let $P1$ and $P2$ be two LOOP programs. Then $P1;P2$ is also a LOOP program, which executes $P1$ and then executes $P2$. Would this be called concatenation of LOOP programs or nested LOOP programs? I know the answer has to be concatenation because nested would mean having...
Can someone remind me the algorithm that split vertex of graph to 2 groups that at least half of the edges are external, I mean between the groups. As I remember it was a greedy algorithm, each time chosen the vertex with highest number of edges, or something similar
A company has several automatic vertical warehouses (called elevators). Each elevator have several trays and each tray has several slots. A slot contains a given quantity of a given article. Elevators, trays and slots are identified by unique IDs and slot also have access to the ID of their own article. In the same tra...
I apologize if this is not the right stackexchange for this question. I was playing around with the Python programming language, when I discovered something strange. It concerns replacing a substring of a string with another substring. For example, in "spammy", replacing "mm" with "xx" results in "spaxxy". However, in ...
We have five types of photo receptors in the eyes but computer color systems just use the three red, green and blue. Three could be motivated if rod and melanopsin sensations are just linear combinations of cone sensations. Is it so or would a five color display with two additional pixel components with a frequency di...
Where does the code for consistent hashing reside? I have read how it is implemented (at a high level), but am unsure if it is exposed as a microservice between the web server and the app servers or on each app server (would seem unlikely).
I train a neural network - one of the Resnet variations ($\approx 10^7$ parameters) on the CIFAR-10 dataset - and after each epoch, I would like to find the smallest/largest eigenvalues of its Hessian. Formally, we can view our NN as a function: let our dataset (training set) be $D$, let $x$ be NN parameters, and we wa...
I am trying to make a CNN model . Training the image . Want to know that When we apply kernel on image and take out the features of images. That features are rotation invariant or we have to apply some rotation invariant techniques? . Few person on stack overflow says that max pooling does rotational invariance , some ...
I want to try and write an example that solves the problem of travelling from one location to another described in the book AI: A modern approach. The problem involves getting from a particular city in Romania called Arad to Bucharest and the problem can be expressed as a graph like in the following image: If when con...
I have a question, does non-polynomial reduction exists for all problems? the issue is only regarding polynomial reductions?
I've been given a matrix path problem to solve and I need some hints / advises. You're given a $m \times n$ matrix where $m$ is number of rows and $n$ number of columns. When you're in a cell $(i,j)$ you can only move to cells $(i,j+1)$, $(i-1,j+1)$ and $(i+1,j+1)$. Three subproblems have to be solved. I solved first t...
Consider a relation R(A,B,C,D,E) and the only FDs, ABD->C BC->D CD->E These are the only 3 FDs. I want to know if the above relation is in 2NF or not. According to the definition of 2NF, a relation to be in 2NF, it should be in 1NF and it should not have partial dependency. But I'm not getting the partial dependency co...
I am trying to make a Convolutional neural network. Training the images of different brands of Logos. Have 100 images per class and there are 40 classes. I have trained the model now want to check that model is overfitted or not . What should be the number of epochs we will se that with no improvement after which train...
I am trying to understand the proof for this theorem (theorem 4.22 of the book 'An introduction to the theory of computation'): A language is decidable iff it is Turing-recognizable and co-Turing-recognizable. The first direction is OK. But the other is not, namely: What I don't understand is why the author assumed t...
I was trying to understand how we can solve the Longest Increasing Subsequence (LIS) problem in O(N log N) time. I came across a sorting algorithm called the patience sort algorithm. To learn it I was going through this document: https://www.cs.princeton.edu/courses/archive/spring13/cos423/lectures/LongestIncreasingSub...
I am wondering whether Neo4j and the associated Cypher query language is computationally equivalent to relational algebra? Any ideas or papers on that topic?
I am working on the following exercise: Consider a simple and connected undirected graph $G(V,E)$. Show that one can colour the edges of $G$ in polynomial time and with as few colours as possible such that there is no monochromatic cycle in said colouring of $G$. EDIT 1: OK, my approach turned out to be false. I will...
I know that the NSA has recommended cryptography algorithms, such as their A/B suite algorithms and their Commercial National Security Algorithms Suite. I also know that they change their recommendations for key size, an example being in 2019 when they changed the key size recommended for RSA and Diffie Hellman from 20...
I'm trying to understand what's the difference between $S=\emptyset$ and $S=\{\emptyset\}$ The diffenition that I found for $L_S=\{\langle M\rangle\ | L(M)\in S \}$ I understood that $S=\emptyset$ and $S=RE$ are trivial and $S=\emptyset \Rightarrow L_\emptyset=\emptyset\in R$ $S=RE \Rightarrow L_{RE}=\Sigma^*\in R$ But...
Let $quasiP$ be the quasipolynomial time complexity class. Is $E^{quasiP}=E$ false? Is $E^{DTIME(2^{(\log n)^k})}=E$ false at every $k>1$?
I am looking for an algorithm for approximating the chromatic number of an undirected simple graph with $n$ vertices in $O(n^{c_1})$ time and $O(n^{c_2})$ space, for some constants $c_1$ and $c_2$. More precisely, the algorithm should find an upper and a lower bound on the chromatic number. The closer the bounds are to...
I am implementing a 2-3 tree, where every leaf has a unique key and a value, and I need to write an algorithm which finds the sum of values of the leaves which their key is within a given interval. The time complexity of the function needs to be $O(\log n)$. I thought about saving for each internal node the sum of the ...
I wanted to recreate the results of this paper, where the authors draw the boundary between two parts of a building from stereo images. The authors mention that the epipole and the intersection of the two planes (two sides of a building) from two cameras can be found from the eigenvectors and the eigenvalues of the hom...
I don't know how to prove or show the following fact. $\quad$ $\{xx|x \in \Sigma^\ast\} $ can be accepted by a queue automaton. If it would be possible, show by deterministic queue automaton. If not, by non-deterministic queue automaton. If it's not that hard and if I can, please give me a hint.
I am writing an app which displays speeches on various topics, with each speech having a number of attributes. I want to give the user the choice to sort a list of speeches by an attribute, even within a previously sorted list of speeches. Consider for example: Suppose the previous list had been sorted by the attribute...
Disclaimer: I am not even an expert user of these two kinds of software. I understand that the trivial difference between proof assistants and CAS is that in proof assistants, the goal is to show that the given proposition reduces to a tautology. Whereas CAS are used to perform various transformations on mathematical e...
Is it correct to state that $u$ is a universal function if and only if $$ \forall f : \text{RE} \quad \exists g : \text{R} \quad \exists h : \text{R} \quad f = h \circ u \circ g $$ where RE is the set of recursively enumerable functions and R is the set of recursive functions? (Should R be replaced with something like ...
I want to make a following proof but I got some difficulties with it. Would be super if you people have any tips / advises. Introduction: Let (N,e) be our public key and (N,s) our private key with $N=pq$ and $ggT(\varphi(n),e)=1$, as well as $es\equiv 1\mod N$. I want to show that since Lemma of Bézout shows, that ther...
Thank you for looking into this, I have a problem regarding direct cache mapping, My problem really though is with the question formation itself and the problem I am about to present seems to have inconsistency and has unclear description. So the problem is as follows ( I am presenting exactly as given ) 32 bit archit...
Let us say that there exists a $\mathsf{NP}$-reduction from a problem $A$ to another problem $B$ when there exists a non-deterministic, polynomial-time Turing machine $T$ such that for each $a \in A$, one of the possible outputs of $T(a)$ is in $B$ (and conversely, if one output $T(a) \in B$, then $a \in A$). $\mathsf{...
I have been looking at the FPT(Fixed Parameter) algorithm for checking if a vertex cover of size k exists.The algorithm goes as follows: VertexCoverFPT$(G, k)$ if $G$ has no edges then return true if $k=0$ then return false let $uw$ be some edge of $G$ if VertexCoverFPT$(G-u, k-1)$ then return true if VertexCoverFPT$(G...
I have a canvas. On this canvas, I want to position 1, 2 or 3 images. The images can be positioned anywhere on the canvas just as long as they're within the canvas. The images move by their top-left corner. To make sure that the images do not leave the canvas, I am doing this: image_topLeft_x_position = random.randin...
I need to plan an algorithm that decides if a directed weighted graph $G = (V,E)$ has a zero weight cycle. the graph has no negtive cycles the algorithm needs to be in $O(|V| \cdot |E|)$ time my idea was to first add a vertex (called $r$) and connect it to all of the vertices in the graph. and then use the Bellma...
If I have a recurrence equation: $$T(n) = 3T\big(\frac{n}{4}\big) + cn^2$$ It says it splits a problem of size n into 3 subproblems of size n/4. Then it keeps splitting it until the problem size at the leaves is 1 or less. The first part that does not make sense to me is how can you split a problem of size n into 3 pro...
A boolean function $f \colon \{0,1\}^n \rightarrow \{0,1\}$ is symmetric if $f(x)$ depends only on the number of $1$s in $x$. It is known that every boolean function is in $\mathrm{NC}^1$, i.e. there is a circuit of depth $O(\log n)$ computing it. What is known about the constant inside the $O()$ notation? Specifically...
The input: a binary tree and a list $L$ of vertices in that tree. The output: a sublist of $L$ of minimal length that has the same lowest common ancestor as $L$. If there is several sublists of minimal length it is OK to output any one of them. We could just check all the possible sublists of $L$ but that seems ineffic...
I am looking for the answer to the exercise 1-6 in "The Algorithm Design Manual" book. it is stated as follows: 1-6. The set cover problem is as follows: given a set of subsets $S_1,\dots,S_m$ of the universal set $U = \{1,\dots,n\}$, find the smallest subset of $T \subset S$ subsets such that $\cup_{t_i \in T} t_i = ...
I'm building a relevance ranking system for incidents occurrence and prevention. My goal is to use four attributes to establish relevance: tag (About 500 tags), x_coordinate, y_coordinate and time. The final state that I would like to achieve is: to select an object and have a relevance list from the most relevant obje...
Given the root of a binary tree, for instance below, I am running the following tests in Python: 1 / \ 2 5 / \ 3 4 Test 1: cur = root root = None print(root, cur) None, node 1 Test 2: cur = root root.left = None print(root.left, cur.left) None, None In both tests cur and root point to the same mem...
I'm currently learning abstract algebra and the word free appears (free monoid, free vector space) throughout different literatures. Is there a general (and simple) definition of the word (and possibly examples in functional programming) or is it merely a highly overloaded word? Many Thanks!
Let's consider some 128-bit LCG generator mod $2^{128}$, with some random 128-bit multiplier and increment. How fast we can run it using the same tricks like in AES: https://crypto.stackexchange.com/questions/44927/how-long-does-a-good-aes-encryption-take They use there some hardware instruction/hardware acceleration a...
I am trying to make a CNN model on different brands of logos . Firstly , I wrote a CNN from scratch and trained it on which I got 70% accuracy, I have total 40 classes and each class has 100 images . I know it is too short, that is why I am now moving towards pretrained model. My question is that I read on Internet tha...
To prove that SAT-TM (Turing machine emulating the satisfiability problem) is NP-Hard $$\text{SAT-TM}:=\{⟨M,p,1^k⟩ \; | \;∃c,\; |c|\leq p(k), \;\text{such that M accepts c in ≤k steps}\}$$ my professor used the following proof. Suppose $L$ in NP and $V$ is a verifier for $L$ running in polynomial time of power k. $$L ...
Given an undirected graph $G=(V,E)$ and weight function: $ w: E \rightarrow \{1,2,...,10\}$. Describe an algorithm that finds the set of all edges $e\in E$ for which there is a cycle $C$ in $G$ that contains $e$ such that for every $e' \in C, e'\neq e$ : $w(e')\leq w(e)$. I thought maybe because the weights are bou...