instruction
stringlengths
35
29.1k
I've been looking through research papers and the internet and found many claims that "compiler optimizations can cause irreducible control flow". However, I was not able to find a single example of how that can happen. In particular, in [1], there is written that tail recursion elimination in combination with inlining...
Given a decimal number N (which has at most, 10^6 digits, actually we should look at it as a string!) and another decimal number M (which has K digits, 1 <= K <= 10^6 ), we are asked to find all number in range (1, N) where K first digits and k last digits of that number looks like M. I try the following method (on pap...
Question: Find an algorithm which returns the weight of a lightest path between all paths with a weight divided by three in a graph with natural weights of the edges. My instructor has given me a hint of doing calculations modulo three and creating a new graph and applying Dijkstra's algorithm on it. I have no idea how...
I'm solving problem 13.17 of What can be computed?, which is asking to prove $\text{SubsetSum} \equiv_{P} \text{SubsetSumWithFives}$. Here is the definition of SubsetSumWithFives. SUBSETSUMWITHFIVES: it is identical to the decision variant of SUBSETSUM, except that we may use up to 10 extra packages with weight 5 when...
Right now I am learning about Fibonacci heaps for the first time. After the minimum Node of a Fibonacci heap is extracted you consolidate it, to give it a better structure and execute future operations faster. But why don't you consolidate the Heap more often, like after the insertion of 10 nodes with no consolidation ...
I'm solving Problem 14.4 of What can be computed?. 14.4 Define the decision problem SAT-5CLAUSES as follows. The input is a Boolean formula B in CNF. The solution is “yes” if it is possible to simultaneously satisfy at least 5 of B’s clauses. Is SAT-5CLAUSES NP-complete? Give a rigorous proof of your answer. Is there...
Please Note: I forgot a small detail which caused the algorithm to be incorrect, please read the new version and thanks for pointing that. I am stuck on this question for a week and hope to get some help: Algorithm: Given 2 sided Graph ie bipartite graph G(L,R,E), a weight function and a root vertex s: Define E1 as ...
Any directed graph (including a directed cyclic graph or DCG) has a complexity measure. We know that NOR is a universal logic gate, in the sense that a DCG whose nodes are n-input NOR gates can represent any computable number. We also know that Pi is computable. Hence there are an infinite number of NOR DCGs that co...
For 3CNF-SAT problems exists a lot of algorithms that still have exponential complexity, but work faster than brute force. The complexity of this algorithm based on a number of variables or the number of clauses (they can't differ a lot because polynomially bounded to each other in 3CNF). But for CIRCUIT-SAT size of th...
I have a red black tree, $T$, and I need to write an algorithm to find 2 nodes $x$ and $y$ so that $key[x] + key[y] = 2 \cdot key[p(x, y)]$, where $p(x, y)$ is the lowest common ancestor of $x$ and $y$, i.e $x$ is a node on $p(x, y)$'s left subtree and $y$ a node on the right subtree (or the other way around) My origin...
My case is a directed graph with $n$ nodes with $(n-1)^2+1$ edges. I have done the following till now. We know that the maximum number of edges for a directed graph $K_n$ on $n$ nodes is $n(n-1)$ edges. The graph in my problem statement is $G(V,E)$ with $|V| = n$ and $|E|$ = $(n-1)^2+1$. Now, $n(n-1) - ((n-1)^2 + 1) = ...
I'm trying to separate people from a pool into several smaller groups. The group-size should always remain the same. People can be part of several groups - but no two people can be part of more than one group. members = [A,B,C,D,E] group1 = [A,B,C] group2 = [A,D,E] There aren't anymore valid groups possible. A can't ...
Lets say I have 6 point name A, B, C, D, E, F. Distance between a point and it's nearest 3-4 points are known i.e the displacement. Now I want to assign x and y coordinates to them assuming one point as (0, 0). The origin point can be taken as input from the user. But nothing more than that. Sample input : Distance bet...
I want to show that $Primes \in NP$ an I've seen multiple proofs that use facts from number theory, like this one. But isn't it much easier to proof $$Composites=\{x\in \mathbb{N}\cup\{0\}:x=1 \vee\exists p,q>1: x=pq\} \in NP$$ first and then doing a polynomial reduction on $Primes$? Because I can make a simple Turin-M...
The maximization problem of the 3-way number partitioning reads as follows: given $n$ positive integers, partition them into 3 subsets such that the smallest sum is as large as possible. It is known to be NP-hard, but does it have an FPTAS? I found answers for some related problems: There is no FPTAS for MSSP (Multipl...
// Linz Turing machine H --- H applied to ⟨H⟩ H.q0 ⟨H⟩ ⟨H⟩ ⊢* H.qy // H applied to ⟨H⟩ halts H.q0 ⟨H⟩ ⟨H⟩ ⊢* H.qn // H applied to ⟨H⟩ does not halt Do you halt on your own Turing Machine description ? Of the infinite set of implementations of H every one that transitions to H.qy derives an answer consistent with ...
Consider the following operation on strings: pick a (not necessarily contiguous) subsequence, remove it and then append all the characters in the same order at the end. This operation preserves the length of the string. For example starting with $S=abc$ this operation can get you all the permutations of $a, b, c$ excep...
After a bit of surfing, I have found that Schönhage–Strassen (without taking in consideration recent optimizations) seems to be the base algorithm to perform the requested operation. Anyways, this algorithm is focused on "raw" multiplication of two integers $a$ and $b$, if a sufficiently large $N$ is chosen (the multip...
Imagine you have a noise-free NOT gate, and an AND gate with the usual truth table 00 0 01 0 10 0 (*) 11 1 but such that the case (*) is wrong 1/3 of the time, i.e. it gives 1 with probability 1/3, and 0 with probability 2/3. Is this gate family universal, in the sense that one can write a logic formula with these ...
Given an integer $d$, I need to devise a data structure $S$ with the following actions: BUILD(S): build the data structure $S$ from $n$ elements in $\Theta(n\lg{n})$ INSERT(S, k): insert a new element to $S$ with the key $k$ in $\Theta(\lg{n} + d)$ DELETE(S, k): delete the element in $S$ with the key $k$ in $\Theta(\l...
I cannot think of a PTIME algorithm to find a rejecting input of an NFA. While it is possible to efficiently find a rejecting input for a DFA, converting an NFA to DFA is too expensive. The algorithm should have the following behavior: Given an NFA $A = (Q, \Sigma, \Delta, q_0, F)$, if $L(A) = \Sigma^*$, then return th...
The task is to make data structure with the following operations: query: takes two arguments s and t and returns true if they are in the same set and false otherwise. union: takes two arguments s and t and creates a union of the two sets that contain s and t such that if s is in S and t is in T it removes S and T and r...
What is the relations between $\mathsf{DTIME}(2^{O(n)})$ and $\mathsf{DTIME}(n^{O(\log n)})$? Is one contained in the other?
I have a regex $R=\epsilon+1+(\epsilon+1)(\epsilon+1)^*(\epsilon+1)$ which has to be simplified by algebraic operations. As we can do, $\epsilon+1+(\epsilon+1)(\epsilon+1)^*(\epsilon+1)=\epsilon+1+(\epsilon+1)^+=(\epsilon+1)^+$ but the answer is $1^*$. Can anyone please help me to find this with step by step solution?
Suppose one has a large sparse symmetric positive definite matrix $A$ and wants to multiply it by a vector $x$. Only the lower triangular part of matrix A is stored/known. The multiplication $Ax$ should be as efficient as possible, as it has to be performed many times and $A$ is large (millions of rows and columns). Is...
I am trying to think of an algorithm such that giving a graph $G(V,E)$, and a weight function $w\colon E \to \mathbb{N}_+$ (which means giving every edge in the graph a positive weight), and a source vertex $S$, the algorithm finds the shortest path between each $v \in V$ and $S$, such that the weight of the path is di...
I am considering the following problem $\mathcal{P}$. $\mathcal{P}$: Given an undirected graph $G$, and an integer $k$, find a set of vertices $S \subseteq V(G)$, with $|S| = k$, such that the number of edges in the subgraph induced by $S$ is minimized. which is clearly NP-hard, as the answer is 0 iff there is an indep...
In the following paper : Czopik, J. (2019) An Application of the Hungarian Algorithm to Solve Traveling Salesman Problem. American Journal of Computational Mathematics,9, 61-67. In the Introduction, the author claims that the problem is NP-hard. They proceed to give a exact solution in polynomial time. My problem is ...
There is an exam and the marking pattern is - 0 marks - Unattempted 4 marks - Correct Answer -1 marks - Incorrect Answer And total number of question is 30. Find the total marks ( in integer ) which are not possible to obtain in the exam. eg.,119 , 118 , 117 etc are the marks that I can think of. Is there any way t...
I designed a program to create a map in my 2D game program. And I have three questions... algorithm: step1: create a cell in (0,0), and select it as first cell, and mark the step1 is round 0 step2: in round i (start from 1), for every cell created in i - 1 round : for adjacent index in up, down, left, and right: ...
I created a grammar which accepts all arithmetic expressions consisting of $+,-,*,/, (, )$. I created the following grammar: $S \rightarrow M+-M$ $+-M \rightarrow +M+-M$ $+-M \rightarrow -M+-M$ $+-M \rightarrow \epsilon $ $M \rightarrow E*/E$ $*/E \rightarrow *E*/E$ $*/E \rightarrow /E*/E$ $*/E \rightarrow \epsilon$ $...
The question is: The language L contains $DFAs$ which can accept languages equal to $\Sigma$* prove this language is decidable. I'm new to the Decidability topic and I don't know where should I start proving this? reduce? Rice theorem? or we don't need things like reducing and...I would appreciate it if someone teache...
Given $n$ images placed in indexes $x_1 < x_2 < ... < x_n$ and an endless number of guards, where each guard if placed in index $y$ can protect $[y-0.5,y+1]$. I want to protect all images with minimum possible number of guards. My suggestion for an algorithm: Place a guard at $x_1+0.5$ then loop from $i=2$ to $i=n$, ...
I wondered about the following quote from NC (Wikipedia): $NC^i$ is the class of decision problems decidable by uniform boolean circuits with a polynomial number of gates of at most two inputs and depth $O(\log^i n)$, or the class of decision problems solvable in time $O(\log^i n)$ on a parallel computer with a polyno...
I'm taking the Design and Algorithms Part -II course in Coursera by professor Tim Roughgarden. In one of the classes, he mentioned that the running time for Dijkstra is $O(m \log n )$ using the heap data structure where $m$ is the number of edges and $n$ is the number of vertices. Also, he mentioned that using an exoti...
Suppose a rectangle $R$ is partitioned into more than one smaller rectangles of positive area. What is the fastest algorithm to find the largest rectangle strictly within the all-enclosing rectangle $R$ that is a union of the partitioning rectangles? Of course the dumbest algorithm is simply taking all distinct pairs o...
I'm interested to know what is the biggest known $0\le \epsilon\le 1$ such that the $gap-EQUALITY$ problem that is defined by: $$f_\text{GEQ}(x,y)=\cases{1&$x=y$\\0 & $x$ and $y$ differ in at least $\epsilon\cdot n$ positions\\\text{undefined}&otherwise}$$ Still requires $\Omega(n)$ communication bits? Thanks!
Assume we have weighted DAG (directed-acycle-graph), source s and target t. Define the number of edges as $E$. Given $0<\alpha<1$: Choose $\alpha*E$ edges to cut their weight by half so that the longest path from s to t is minimized. Personal note: We've been asked this question by our professor. I assume the problem i...
Stable matching problem and $STCONN$ can be solved using comparator circuits (refer https://arxiv.org/abs/1208.2721). What is the depth of the $CC$ circuit necessary for stable matching? Is it in $CC^1$ or in other words $O(\log (n))$ depth comparator circuit? What is the depth of the $CC$ circuit necessary for $NL$?...
The standard circuits $AC^i$, $NC^i$ are constructed using $AND$, $OR$ and $NOT$ of various fan-ins, fan-outs and depths. What is the comparator gate constituted from? Structurally why is it believed $NC^i$ is not in any $CC^j$ if $i\geq 1$ and why is it believed $CC^i$ is not in any $NC^j$ if $i\geq 1$ (refer https://...
Given two arrays of integers, please write a function that returns all elements present in one of the two arrays but not both. E.g. f([ 1, 3, 5 ], [ 1, 2, 4, 5 ]) -> [ 2, 3, 4 ] I know I can do this with two for loops that is O(n^2) but is there any better way ? Please help
There are n cities [1, 2, 3, .... n] and k available hospitals. k < n. We need to place hospitals into the cities. How to place these hospitals to minimize the average distance from each cities to the closest hospitals.? Right now my thought is using dynamic programming with a 2D array of size n * k. Then I know optima...
Given a rectilinear polygon, what is an run-time efficient algorithm that finds the largest inscribed rectangle the sides of which either parallel or perpendicular to the sides of the rectilinear polygon? A dumb algorithm to form all the rectangles formed from unordered 4-tuples of the edges, for each of the rectangle ...
Let K players be among N towns in a circular position. On each turn, only one player can move. A player cannot move if he is the one who moved in the previous turn. A player can only move clockwise to the next town, ex from town 0 to town 1, from town T to town T + 1, from town N - 1 to town 0. Each town at any point ...
If we know that $n = 1363$ and $φ(n) = 1288$, how can we factor $n$?
This question is a simplification of the one about finding the shortest path in a grid with turnstile and waypoints. Since this simplification has dramatic consequences, I think it deserve its own question and answer. Here's a reminder of how the turnstile tiles work. A turnstile tile has two bars on adjacent sides of...
Just to be clear, I am aware that you can define an accepting DFA for every regular language. My problem is a bit deeper. Let's say we have a language L which consists of a random half of all binary strings of length at most k. This language is finite, so it is regular. We can of course create a DFA for it, by represen...
I'm trying to make an algorithm that finds the first 10 or so terms of a function's Taylor series, which requires finding the nth derivative of the function for the nth term. It's easy to implement derivatives by following the definition of the derivative: $$f'(x) = \lim_{h\to0}\dfrac{f(x+h)-f(x)}{h}$$ implemented here...
I want to prove that the following language is decidable: $$\mathit{SEQ}_{\mathit{CFG}} = \{⟨G⟩ \mid \text{$G$ is CFG and $L(G) ⊈ L$}\}, \text{ where } L = \Sigma^* - \{\epsilon\}$$ So, I think about the relationship between equality and substrings. for example, I saw in different questions that when we have $L(G) = L(...
I recently asked this question and got an answer from Yuval Filmus stating that we can build a solution using error-correcting codes. More specifically, I'm looking for error correcting codes (for binary alphabet) with constant $R>0$ non-zero relative rate, and as high as possible relative distance $\delta$. I know tha...
I need to calculate the expected height of a randomly built binary search tree, BST, with 4 different keys: $x < y < z < w$ According to Catalan numbers, there are 14 possible trees, 8 with height 3 and 6 with height 2. So let $X$ be a random discrete variable that holds the tree height, $P\{X=2\}=\frac{6}{14}=\frac{3}...
i have a pretty basic question, but for example a cpu clock at 3ghz, does that mean it can do 3 billion cycles per second, or does it every second always will make since 3 billion cycles?
What is the asymptotic bound? How do you get to the result? $$T(n)= 3 \cdot T(\sqrt[3]{n})+n^3$$
I am aware that when we have a linear problem subject to OR constraints, the LP would be a non-convex optimisation problem. For example, ${x = 0}$ OR ${1<=x<=2}$. My question is in such a situation, is it possible to check if an LP is feasible/infeasible, bounded/unbounded or if it has an optimal value or not I could n...
I'm trying to solve a scenario where I need to find the smallest number of time steps to reach a location in 2d space, where I can manipulate the velocity with an acceleration at each time step where the acceleration has a maximum magnitude of $n$. This sounds vague, so let me clarify: I have the following scenario: W...
Let $G=(V,E)$ and denote $d=d(G)$ its maximal degree and $a=a(G)$ its arboricity. My question is: what is the smallest amount of colors $f(a)$, such that a $f(a)$-coloring is guarenteed to exist? For example, $f(d)=d+1$, because a $d+1$-coloring always exists. My assumption is that $f(a)=2a$. Because each forest can be...
I was asked this problem recently in an interview however, I failed to provide an optimal solution to it. Given an array $A$ of $n$ numbers, the magic factor of $i^{th}$ element is equal to the greatest prime factor $G$ where $G$ is the count of elements in the array strictly less than the element $A[i]$. Now, the mag...
I asked a similar question here, except I forgot to specify that the final velocity must be 0. I have 2 points in 2D space, start = $s$ and target = $t$, and a starting velocity $v_0$. At each time step $k$, the current point $p$ (which starts as $s$ and is incrementally updated) has the velocity $v$ added to it, so $p...
How to prove that in any tree, all longest paths cross one another in one vertex?
In terms of the arithmetical hierarchy, the halting problem is known to be $\Sigma^0_1$-complete, and the so-called universal halting problem, is the problem of determining whether a given computer program will halt for every input, is known to be $\Pi^0_2$-complete. Is there a natural $\Sigma^0_3$-complete variant of ...
I know that the average access time for systems with level 1 caches is: Average Access Time = Hit time + (Miss Rate x Miss Penalty) How can this be generalized for n level caches?
The Galvin OS text says that on older systems, there used to be a method, where the entire running process (when in idle state) was moved from the main memory (when main memory ran low) to the disk which acted as a backing store. The text says that whatever processes we swap out are placed in the "swap space" of the d...
A zero-sum game for two players allows a player to take no action during a turn. Can I reach optimal play (where both players always choose the best possible action in each turn) by the following scheme? Randomly choose move orders $A_{1}$: $O_{A1}, O_{A2}, ...$ for player A over turns $1,2,...$ Find player B's optima...
Our professor talked about the "two" types of embedded systems in today's lecture, listing these. 1.) Baremetal 2.) Full-featured Now I found out what he means by baremetal, but I can't find anything about "full-featured" in the whole WWW. What do both terms mean exactly, and how do I distinguish between them? In which...
I'd like to know if there is any video courses that relate information theory and thermodynamics, e.g. courses cover laws of thermodynamics, Shannon's entropy, Kolomogorov Complexity, Landauer’s Principle, and anything related to them in one course. Thank you!
I made this grammar: $S \rightarrow ASa$ $S \rightarrow c$ $A \rightarrow a|b$ And I want to check that it accepts words like $aacaa$, $abcaa$, $babcaaa$, I formed the grammar by thinking about the typical $ a ^ nb ^ n $,but I added what is necessary for my interest.
We define the triangle factoring problem as in Triangle Factors in Random Graphs, which is, given a simple undirected graph of $3n$ nodes, find if there's a subset of edges dividing vertices into $n$ vertex-disjoint triangles. I've seen some papers discussing about the probability of such a factoring exists, but I'm un...
Minimization of any expression of 4 variables through K-map, in which there are more chances of errors (like error in grouping) and the same expression with Quine-McCluskey Method there are less chance of errors but it should be of 4 variables. And I know that Quine-McCluskey Method gives accurate result as compare to...
I can't figure out how to solve this problem: Let $b_1,b_2,\ldots,b_k$ be positive integers with sum less than $n$. Prove that $$b_1!b_2! \cdots b_k! < n!.$$
Does $NP^{SAT}=NP^{NP}$? We can see easily that $NP^{SAT}\subseteq NP^{NP}$, because $SAT \in NP$. But is the other side $NP^{NP}\subseteq NP^{SAT}$ also true? If yes, how can we prove it?
I am confused about an aspect of the definition of first normal form in relational database model. Codd 1970 ("A Relational Model of Data for Large Shared Data Banks") defines normalization (implicitly to first normal form) as "eliminating nonsimple domains", where nonsimple domains are domains which have relations as ...
Given the following DB and query : Now if we need to simplify the query qualification, here is the answer from the book (Principle of distributed database systems, third edition) : My question is in the highlighted bracket, I think this should be (p1 OR (p2 AND (Not p2))) instead of the one written because we have t...
Consider the computational problems in which the input is a set of $n$ integers with maximum magnitude $M$. According to Erik Demaine's lecture notes, assuming $P\neq NP$, the following are true: If a problem is strongly NP-hard, then it does not have a pseodupolynomial time algorithm (an algorithm with run-time $\tex...
Given a graph G and an integer k , recognize whether G contains dominating set X with no more than k vertices. And that is by finding a propositional formula ϕG,k that is only satisfiable if and only if there exists a dominating set with no more than k vertices, so basically reducing it to SAT-Problem. The solution to ...
I am trying to create a DPDA that accepts words from the following Language: $$ L = \{wx \; | \;w \in \{a,b\}^*, \#a = \#b \} $$ My intuition was to initially put an $x$ on the stack and then write an unlimited amount of $a$ or $b$, while both operations put an $B$ or $A$ on the stack. Then, in the second last state we...
Consider a multiset of $n$ integers, where each integer is between $1$ and $3 M$. The sum of all integers is $3 S$. There are three bins. The capacity of each bin is $C = S + M$. Is there a polynomial-time algorithm to decide whether all integers can be packed into the bins? To explain why this specific case is special...
According to google, a system of boolean equations is defined as follows Essentially, a Boolean equation system is an ordered sequence of fixed point equations over Boolean variables, with associated signs, µ and ν, specifying the polarity of the fixed points. The equations are of the form σx = α, where α is a positiv...
I was reading a paper for learning graphs (paper is GraphRNN) and it says in section 2.2 (emphasis by me): Vector-representation based models. One naive approach would be to represent G by flattening $A^π$ into a vector in $R^{n^2}$, which is then used as input to any off-the-shelf generative model, such as a VAE or G...
Any decision problem algorithm can be represented as a boolean expression. The rules of boolean algebra (De Morgan's law, distributivity, etc.) can be used to manipulate and simplify that expression, similar to normal algebra. Can any boolean expression be derived to its most simple form (i.e. has the least number of ...
Given any multivariable expression in Lambda Calculus (LC), e.g. for an arbitrary LC expression "op" for some non-commutative operation: E = (\x (\y ( op x y ) ) ) Does there exist an LC expression which will transform E into the expression: F = (\y (\x ( op x y ) ) ) -? If so, how can such an expression be generaliz...
I'm working on a suite of DSP tools in Rust, and one of the features of the library is a collection of windowed statistics (mean, RMS, min, max, median, etc) on streams of floating-point samples. For instance, if the window size is 7, then the windowed min is the smallest of the last 7 items in the stream (the window),...
I know this problem is related to the greedy algorithm and max edges incomplete graph but can't come up with a solution. Problem You are given two numbers n and k: n >= k n is the total # of vertices k is the maximum number of vertices that can form a complete graph per second There are no edges initially how many seco...
Is $(\log n)^c = O(n)$ for any constant $c$? For example, is $(\log n)^5 = O(n)$?
I'm solving Problem 14.14 of What can be computed?. 14.14 Consider the computational problem HALFSAT defined as follows. The input is a Boolean formula B in CNF. If it is impossible to satisfy at least half of B’s clauses, the solution is “no”. Otherwise a solution is a truth assignment that does satisfy at least half...
This is one of my homework assignment questions, that are quite difficult for me. The question states: Show that $L$ is not semi-decidable where $L = \{w\#x \mid w,x \in \Sigma^*, T(M_w)\neq \{x\}\}$ So I just need a better understanding of $L$ in order to solve this homework. My question now is: Is the complement o...
Let $\Sigma = \{c_1, c_2, R(\cdot,\cdot) \}$ be an alphabet in first-order logic without $=$, where $c_1,$ $c_2$ are constant variables and $R$ is binary relation. Let $\varphi$ be a formula without quantifiers such that $FV(\varphi)=\{x\}$. Prove or disprove: if the first-order sentence $\exists \,x\,\varphi(x)$ is ...
While reading about 0/1 knapsack problem on the Internet, many tutorials considered value/weight ratio to solve the problem and I was wondering will it always contain the element with the greatest value/weight ratio to find an optimal solution to a 0/1 knapsack problem or is there any example where we find the optimal ...
I am studying a certain theoretical optimization problem related to scheduling, and I am confused by the different terms used in the literature for such problems. In particular, I found the following terms: Job scheduling Machine scheduling Process scheduling Processor scheduling Multiprocessor scheduling Task schedul...
How do I describe the following automaton in plain English? The only thing that I can think about when explaining in plain English would be the states, alphabet, start, accepting state, but I think there is more to when explaining about automata. How do I answer that? The states are as follows: Q = {q1, q2, q3, q4} Th...
I'm having a hard time solving the problem below: In Claw-free problem, we are given a graph $G$ and $k$, and the objective is to decide whether there exists a subset $S \subseteq V (G)$ of size at most $k$ such that $G \setminus S$ does not contain any $3$-star (known also as a claw) as a subgraph. Design an $O(k)$-ve...
Is the following line true? Consider three problems A, B and C. If $A$ $<p$ $B$ and $B$ $<p$ $C$ and $B$ is NP-complete problem, then $C$ is also NP-complete. If B is NP-complete, then C would have also been NP-complete if it was in NP but it is not given here. Can we consider it false? Or is there any other reason?
Trying to understand how compiler/static-type-checker checks for subtyping, I run into 2 problems. 1. Reachability in DAG Since both Python/C++ support multiple inheriatnce, the types can be represented as a DAG. A C | / \ B D |\ | E F / | x | / \ G H Now is_subtype(A,B) -> bool becomes the problem of reach...
if a lexical grammar has multiple token which start with the same character like > >> >>= and their longest length is 3, does it have 2 character lookahead? Or is it implementation defined. Does the number of character required to produce a fixed size token like a keyword - 1 also count. What is the formal definition o...
We are given a synchronic undirected tree shaped network, with $n$ indexed nodes. We know that there is at least one node with at least $\log_k n$ neighbors, $k>1000$, and $k$ is given. We need to divide the network into $\log_2 n$ distinct groups, with at least one link between any two groups, and each node has no mor...
I need to give a parallel algorithm which finds the minimal element of an unsorted array. Moreover, I need to show that $T_1 = Θ(n)$ and $T_∞ = Θ(\log n)$. As I read $Θ(\log n)$, I thought about some sort of divide and conquer algorithm, like MS: parallelMin(A, l, r): if l ≥ r: return min(A[l], A[r]) m ...
I was recently learning about Binary Search Trees(BSTs) and thought it could be made even more efficient by making some changes. As binary search trees have numbers greater than the root node on the right and the numbers lesser than the node on the left, we can further divide the tree into odd and even numbers to make ...
This is an intriguing question given by my friend for which I want to find an optimal solution: Each week, you can choose to work ONLINE $(ON)$ or in person $(WR)$ in your department's office. If you attend work online in week $i$, you will spend $ON_i$ hours; otherwise, if you attend work offline in the department, y...
Out of pure curiosity, if I have a Doubly Linked List, what would be the fastest way to return the elemenmts of the List in the correct order as an array? For example, would it be more efficient to create an empty list an append the elements or create a list with the length of the Linked List and insert each element?
I have doubts regarding a proof of the following theorem: 'Set of all problems' is larger than the 'set of all algorithms' (or set of all C programs). Put rhetorically, the theorem says that there are more problems than there are solutions. The proof is by cardinality comparison of the two sets and has the following st...
We all know that: Every graph has an MST. The MST need not be unique, but it is unique if all the edge weights of the graph are distinct. But if the weights of the edges in a connected graph are not all distinct, does it mean that there is more than one minimum spanning tree?