instruction
stringlengths
35
29.1k
The Wikipedia description has way too much math.
Its kind of a weird question to ask but I have been asking myself this: Is there a limit to number of ways to find a solution to a particular problem. Take the simplest problem: sorting a sequence of numbers. Now there are a lot of algorithms to sort. Is there a limit to such algorithms? Technically, you can always fli...
Consider a group of five processors implementing three-phase commit protocol. During the execution of the protocol, the coordinator and one other process crash. Two of the remaining processes are waiting in "READY" state for the coordinator while the third process is in "PREPARE COMMIT" state. Can they continue and com...
On wikipedia's page on P vs NP it says that think that of 151 researchers surveyed, their thoughts were as follows: "126 (83%) believed the answer to be no, 12 (9%) believed the answer is yes, 5 (3%) believed the question may be independent of the currently accepted axioms and therefore is impossible to prove or ...
If $\qquad\displaystyle L_p = \{ \langle M \rangle : p \in P(L(M)) \text{ s.t. } p \text{ is a specific trivial property} \}$, where a trivial property is a property that is shared by all recursively enumerable languages or is not a property of any recursively enumerable language, is it implied that $L$ is decidable?...
So I fully understand the how the RSA algorithm works, but now I am trying to reason with the formula. I want to know: why the public key e and the private key d in the RSA encryption have to satisfy the equation ed = 1 mod (p − 1)(q − 1)? Is it because of the standard modular arithmetic rule where 1 mod anything ...
I am having trouble giving the description of a Turing machine that goes for $L = \{0^n 1^m 0^n 1^m \mid m,n \geq 0\}$. What I have so far is: If we start with a blank, the string is empty and it should accept, if not, start reading $0$s and I thought marking the $0$s with $X$ and the $1$s with $Y$ would be OK. After w...
In Sipser's Theory of Computation book, it is stated while reducing ATM to REGULARTM We let R be a TM that decides REGULARTM and construct TM S to decide ATM. Then S works in the following manner. S = “On input , where M is a TM and w is a string: Construct the following TM M2. M2 = “On input x: If x has the form...
I'm trying to design an algorithm for the following optimization problem. Suppose that $G=(V, E)$ is a digraph where $V$ and $E$ are sets of vertices and edges of $G$, respectively. $|V| = n$ and $|E| = m$. $c$ is the cost vector; $c_{ij}$ is the cost of edge $(i,j)$. Costs can be negative and $G$ may have cycles (nega...
I am helping design a CS-related activity for a Let's Talk Science competition, which promotes STEM amongst high school students. In the competition, teams of six students will move from station to station, trying to complete each as quickly as possible. One station might give the team a metre stick, then ask them to m...
I studying the related question. https://stackoverflow.com/questions/13500560/number-of-ways-to-create-an-avl-tree-with-n-nodes-and-l-leaf-node but it's not so general. In-fact, We want to know with N keys, how many different AVL Tree, we can make? we know with N=1 key is 1 AVL Tree. with N=2 key we have 2 different ...
What is a bicriteria approximation algorithm? This keeps coming up in the case of data stream clustering. Is this related to multi-objective optimization? This is where I came across it: cis.upenn.edu/~sudipto/mypapers/datastream.pdf. The paper is about a streaming version of the k-means algorithm. There are references...
Unrolling an iso-recursive μ-type expression such as, say, one isomorphic to natural numbers: μα.1+α using unroll : μα.T → T[μα.T / α] by three steps, for example, gives: μα.1+α μα.1+(1+α) μα.1+(1+(1+α)) ... If I instead have a polymorphic list, such as: λα.μβ.1+αβ is there a necessary relative order to the expansi...
It's hard to look up the meaning of a symbol if you don't know what it is called in the context that it is written. That apostrophe-type symbol in the sequence notation - what is that?
All decision problems (i.e.language membership problems), which are verifiable in polynomial time by a deterministic Turing machine are called NP problems. Further, these problems can be solved by a non-deterministic Turing machine in a polynomial time and in exponential time by a deterministic Turing machine. Do we ha...
I need help with the following: Let $k\in \mathbb{N}$, define: $L^k=DSPACE(O(log^k(n)))$ $NL^k=NSPACE(O(log^k(n)))$ and: $PolyL=\bigcup_{k=1}^{\infty}L^k$ $PolyNL=\bigcup_{k=1}^{\infty}NL^k$ I need to prove, disprove or to determine if it is an open question: 1. For every $k\in \mathbb{N}$ it holds that $NL^k\subsete...
Given an undirected and connected graph $G=(V,E)$ and two vertices $s,t$ and a vertex $d \in V- \{s,t\}$, we would like to define a legal path as a path from $s$ to $t$, passes through $d$ (at least once) and is of even length (regarding number of edges). We need to find such a path that is the shortest in $O(V+E)$ t...
Alan Turing proposed a model for a machine (the Turing Machine, TM) which computes (numbers, functions, etc.) and proved the Halting Theorem. A TM is an abstract concept of a machine (or engine if you like). The Halting Theorem is an impossibility result. A Carnot Engine (CE) is an abstract concept of a heat engine and...
My professor has asked this (exam) question and it actually makes no sense to me: TCP offers a reliable, bidirectional byte stream over the best effort packet delivery in IP. For reliability, a sender in a TCP connection re-transmits a possibly lost packet. One of the methods with which TCP guesses the loss of a packe...
It is rather easy to see that every cellular automaton can be simulated by a Turing machine: We can simulate a cellular automaton with an appropriate C program and every C program can be simulated by a Turing machine. But how would a concrete TM look like which simulates a CA?
We are given an initial set of tuples $S_0=\{(x_i,y_i)|i\in [n], \forall i:x_i,y_i\in \mathbb{N}\}$ and a number $B\in \mathbb{N}$. At time $t$ we are allowed to remove ($S_t := S_{t-1} \setminus \{(x_i,y_i)\}$) a pair $(x_i,y_i)\in S_{t-1}$: if $$x_i + \Sigma_{j:(x_j,y_j)\in S_{t-1}, j\neq i} y_j \geq B$$. (That is ...
I'm currently reading about functional dependencies. I've read Armstrong's axioms about: Relexivity: $if$ $B\subseteq A$ $then$ $A\to B$ Augmentation: $if A\to B$ $then$ $AC\to BC$ Transitivity: $if A\to B$ $and$ $B\to C$ $then$ $A\to C$ and also about: Union Rule: $if A\to B$ $and$ $A\to C$ $then$ $A\to BC$...
I'm doing a course in Computational Number Theory and am currently looking at algorithms such as Euclid's algorithm, Square-roots modulo a prime, LLL reduction algorithm, McKee's method, Pollard's $p-1$ method, the elliptic curve method and a couple of others. In an assignment, I'm asked the following question: Which o...
In the late 1990s, when I was in graduate school, the paper JH Saltzer; DP Reed; DD Clark: End-to-end arguments in system design. ACM Trans. Comput. Syst. 2(4):277-288, 1984. DOI=10.1145/357401.357402 was pretty much required reading in every operating systems class at every university, and it still seems to be one ...
What is the best demonstration that show that "Every finite set is computable"? thanks
Context: I have 100 speech sentences that I asked my friend to speak. The vocabulary in the sentences are same but only the order of words are changed. My friend says that he spoke exactly what was asked for each sentence. But I don't know whether he spoke exactly that sentence or something else. What I have here is th...
I want to train a support vector machine with some features. The problem is, one of the features is 1-dimensional (only an angle) and the other is an LBP Histogram, an 58-dimensional vector. Therefore if I concatenate them, like this (in MATLAB) : f = [lbp_histogram; angle]; I got a 59x1 vector, I can train SVM with ...
I'm trying to prove that the following recurrence relation has a runtime of O(n): fac(0) = 1 fac(n+1) = (n + 1) * fac(n) I think that I can use induction in the following manner: Base case If n=0 then fac(n) = fac(0) = 1 Inductive case Assume that fac(n) has a runtime of O(n) fac(n+1) = (n + 1) * fac(n) Therefore...
Hi I have two question about this language: L = {a^i b^j c^k | i = 2*j OR j=2*k } 1)Finding a CFG 2)If in condition part we put AND instead of OR , is this language remains CONTEXT FREE or not ?? thanks.
I am a bit confused on the theory of the pumping lemma. As I know is used to decide if a language is regular or not. This is what I have understood so far though For a regular language $L$, there exists a $p > 0$ such that for all $w ∈ L$ where $|w| ≥ p$, there exists some split $w = vxu$, for which the following holds...
A Boolean function is a function $f:\{0,1\}^n\rightarrow\{0,1\}$. The boolean basis $(\vee,\wedge)$ is known to be Turing complete as it allows any sequence $s\in\{0,1\}$ to be flipped or to be left unchanged. The same can be said of $\mathrm{XOR}$ gates. In this sense we can start with an initial machine configuration...
So every process has its own Page Table, the page table references the frame where the page is in physical memory and also has a valid-invalid bit that tells whether it is in physical memory or in secondary memory. But how does the S.O. knows exactly where the page is saved when the valid-invalid bit it's off? Is the...
Question: If an AVL tree has height h (assume h ≥ 2), what is the maximum possible difference between the number of nodes in its two subtrees? Prove your answer. Your answer should not use big-Oh or big-Theta. I drew six trees and drew the max number of nodes I could on one tree and the min number of nodes on the other ...
Say we have two proposers (P1, P2), one acceptor (A), and two learners (L1, L2). What would prevent this sequence of events from occurring? P1 initiates a round numbered 1. A agrees to participate, and reports that is has not voted on any proposals. P2 initiates a round numbered 2. A agrees to participate, and reports...
I am struggling with understanding the proof of shortest-paths optimality conditions. Let $G$ be an edge-weighted digraph. Then values in $distTo[]$ are the shortest path distances from $s$ iff: For each vertex $v$, $distTo[v]$ is the length of some path from $s$ to $v$. For each edge $e = v \rightarrow w$, $distTo[w]...
In my programming languages course we are reviewing type inference, i didnt get very well how to make this task. I all ready search at the bibliography of my course (PLAI by Shriram krishnamurthi) which actually sucks big cock since he jump lots of steps in the few examples he expose. Does anybody know how to make the ...
I am having a lot of trouble simplifying my circuit using boolean algebra. I am very new to this and any explanation would be greatly appreciated. I have y'+z+w'x+wx' I feel like I could use DeMorgan's law and somehow omit the last 2 terms but when I run my circuit I cannot seem to get the same result. Also for clarifi...
I have a language DPATH that I'm trying to complete is NP-complete. DPATH = {<G, a1,...,an>|G is a digraph with a directed path that covers the sequence a1,...,an} All of the nodes in the sequence has to be visited exactly one time, but it doesn't matter in which order they are visited. I am trying to show a reducti...
The language of all words over the alphabet {a,b,c} such that the number of as in the word minus the number of cs in the word is divisible by three. How is this language regular? Lecturer notes says that it is, and then provides no explanation at all. I tried drawing a DFA for it, but it just seems that the long...
I've read in a few places (like here that the throughput - that is, the amount of good useful messages relative to capacity - of the ALOHA protocol for networks is roughly 0.18%. But its not clear how we arrived at that number. Can someone explain it?
I've read that the throughput - that is, the amount of good useful messages relative to capacity - of the Slotted ALOHA protocol for communication networks is roughly 0.36%. But its not clear how we arrived at that number. Can someone explain it?
Suppose the L1 cache is filled up with data from some process. Now CPU loads another process. Does the new process share cache contents? Or the cache has to be invalidated completely in each context switch?
The length of the shortest program in a given (fixed) programming language that produces a given output is that output's Kolmogorov complexity, which is not a computable function on the set of possible outputs. This is a classical result and is easily proven; a proof outline appears in the Wikipedia article on Kolmogor...
It is obvious that the representational power of graphs are huge. Is there a problem that cannot be represented using graph? I have recently asked this question to my students and no answers came up. I could not answer this either. For instance: Problem: Finding the shortest path between two given cities in a country. ...
The longest common substring (LCS) of two input strings $s,t$ is a common substring (in both of them) of maximum length. We can relax the constraints to generalize the problem: find a common substring of length $k$. We can then use binary search to find the maximum $k$. This takes time $\cal O(n \lg n)$ provided that s...
Here is an experiment I came up with (I don't have sufficient material to make it): Say that, you have a list of $n$ numbers $L = \{l_1, l_2, ..., l_n\}$. And you have bars representing those numbers like so: Say that, width of every bar is $w$. Imagine a line, thatis made up of $n$ line segments, each of them are $w$...
I don't consider myself very good at math, but nevertheless I enjoy solving optimization problems like the ones often asked in ACM ICPC (a college programming competition). I recently came across an issue while trying to solve one of such problems. I'd appreciate any help to find a linear algorithm (something better th...
I have, lets say, 8 bits mantissa and 4 bit exponent. Then, -1=1111 1111 there are no 0s so how can I normalise -1 in 2's complement form?
I wonder why people assume the domain of a computable function is $\mathbb N$? For example, in Wikipedia. Can its domain be any countable set rather than $\mathbb N$? Can its domain be an uncountably infinite set?
For a formal language, I wonder what differences and relations are between its syntax and its formal grammar. A formal grammar is a set of formation rules that describe how to generate the strings that belong to the formal language. Wikipedia says that syntax is "the study of the principles and processes by which s...
I am currently working with a very large Social Network and I want to recreate this graph with a smaller dimension, using the original Degree Distribution and Clustering Coefficient Distribution. The degree distribution is the relative frequency of vertexes in the original graph that have a certain degree. The cluster...
How can you specify the "inverse" of a word, so: let's say a word consists of a's and b's the language is: $ww^{-1}$ the second word is the same as the first but every a is replaced by b and every b by a
I have already asked a similar question here, but since I have not got an acceptable answer, I decided to ask a simpler version of the question here. Let $M|\mathbf w$, where $M$ is a matrix and $\mathbf w$ is a subset of the column indices, denote the matrix formed by selecting columns $\mathbf w$ from $M$. Problem:...
It can be shown that the logical preposition [ :- (~A->A)->A ] is a theorem (always true). I want to know if anybody knows a real life description for the preposition above? I mean an expression in computer, economics, mathematics, politics or anything that fits in that preposition.
When I first heard of these things I was very fascinated as I thought it sets really a limit to mathematics and science in general. But how practically relevant are these things? For the Halting Problem: Are there more than some artificially constructed cases, where one can't decide whether the algorithm will terminate...
The $G(n,p)$ random graph model creates graphs with $n$ vertices and each possible edge exists independently with probability $p\in (0,1)$. Much is known about the (expected) size of a largest clique in these graphs, and it has been shown that the expected number of maximal cliques of size $d$ is $${n\choose d} p^{d ...
If I store a directed graph $G$ in adjacency list format, one can find all the out-neighbors $j$ of a given vertex $i$ in $\mathcal O(d)$ time, where $d$ is the max degree of the graph. These are all the vertices $j$ such that $(i,j)$ is an edge of $G$. On the other hand, if I want to find all the in-neighbors of $i$, ...
I am working through the following paper "Data Structures for Storing Small Sets in the Bitprobe Model" by Radhakrishnan et al. and am confused regarding one of their arguments about a lower bound. In particular, they are trying to show that $s_A(2, m, 2) \in \Omega(m^{4/7})$. That is, the goal is to store a set $S$ of...
There are several online quantile estimation algorithms, but I haven't seen any that supports deletions (i.e. unobserve elements observed in the past). Are there any such known algorithms? To motivate my question: I'd like to maintain some quantile estimation data structure from the start of time (t0) and take a snapsh...
I'm studying for my Computer Architecture exam next week, and I'm having problems understanding how a set associative cache works and how to solve related problems like this one : "A set-associative cache memory uses a set of 8 words. A replacement procedure based on FIFO algorithm is implemented by means of 3-bit coun...
I read this paper: http://www.sciencedirect.com/science/article/pii/S0166218X04001131?np=y (you can check the PDF online for free), and I translated section 4's Fun-sort algorithm (correct me if I'm wrong): binary-search(A,x): A[0]=-∞ A[n+1]=∞ //|A|=n l=0 h=n+1 m=⌊(l+h)/2⌋ while (h != l+1) ...
I am self-learning about formal languages. I learned that the family of the regular languages can be defined inductively, in terms of the operations they are closed under (namely the smallest fix-point). This definition doesn't rely on regular grammars or finite state machines. I wonder which other families of formal l...
I'm trying to describe a TM through denotation of the transition function. Given is a TM that recognizes the language $$ L ={\{w\#w} \mid w \in {\{0,1}\}^*\} $$ over the input alphabet: $$ \displaystyle\sum = {\{}0,1,\#\} $$ My guess is first to place a word $$ w \in {\sum}^* $$ on the tape, and in every cell a symbo...
I want to find the worst-case running time of an algorithm, which follows the following recurrence equation: The worst-case running time is $\Theta(n^2) + T(n, 2, n)$, where $T(x, i, y) = \begin{cases} 1 & \textrm{if $(x=0)$ or $(y=0)$ or $(i > n)$} \\ x+y+ T(x-a,\quad i+1, \qquad b)\\ \ \qquad+ T(x-a,\quad i+...
I'm looking at the following problem: Given $n$-dimensional vectors of natural numbers $v_1, \ldots, v_m$ and some input vector $u$, is $u$ a linear combination of the $v_i$'s with natural number coefficients? i.e. are there some $t_1, \ldots, t_m \in \mathbb{N}$ where $u = t_1 v_1 + \dots + t_m v_m$? Obviously the rea...
I am looking for standard math courses (Calculus 1, Calculus 2, Linear Algebra, etc.) that were developed specifically for computer scientists, and use computer-science examples for motivation. For example, the pagerank algorithm can be used to motivate eigenvectors and eigenvalues.
I'm reading about Multiset Size Verification Problem and in the following paper - http://www.skynet.ie/~sos/mapviewer/docs/Voronoi_Diagram_Notes_2.pdf - I got stuck just on the first lemma. However, since my concrete problem is rather specific, I'll describe it as self-contained, so that no background in terms of what ...
I apologize if this question is already answered and appreciate any pointers to existing answers. I'm not familiar with statistical or data mining terms so my search was limited to basic words used in the title of this question. I did look at some algorithms but could not decide if they serve the purpose. I'm looking ...
In class, we saw the Miller-Tucker-Zemlin formulation of the Travelling Salesmen Problem (TSP). MTZ is a way of formulating the TSP as an integer linear programming instance. I understand how MTZ works, but I'm confused why MTZ is considered a better algorithm for checking for sub-cycles and rejecting them as answers ...
I am continuing with my self-study of formal languages. Given two alphabets $\Sigma$ and $\Delta$, a string substitution is a mapping from $\Sigma$ to $\mathcal P(\Delta^*)$, which induces a mapping from $\Sigma^*$ to $\mathcal P(\Delta^*)$. In case that a string substitution is a string homomorphism, it is a mapping...
Wikipedia says, the context-free languages are closed under the cyclic shift of $L$ (the language $\{vu : uv \in L \}$) So I am looking for the definition of the cyclic shift operation on formal languages. From the quote, what are required on $u$ and $v$? Are they in $L$, or in $alphabet(L)^*$? Thanks.
does a good known algorithm exists for this problem? On input I have two series of timestamps "when the event was observed". Theoretically the recorded timestamps should be very well aligned. Visualized ideal situation on two time lines "s" and "r" as recorded from the two devices: but more likely they will not be so ...
I noticed that the most convenient way to deal with quotient structures (like the rational numbers or other equivalence classes) within ZFC is to select a unique representant from each equivalence class, which is possible due to global choice. Then I noticed that this strategy also seems to work quite well in practice,...
Input: A max binomial heap $H$, and a pointer to a node $V$. Output: A max binomial heap, where all the children of $V$ are multiplied by 2. I have tried solving this by taking out the node $V$ together with it's sub-tree, multiplying all the children of V by $2$, rearranging the heap to close the hole, and adding V's ...
I want to search from a given set of elements. Along with that I also want to remove that searched element. The problem is that the number of these queries is $q=O(n)$, where $n$ is the number of total elements. Which data structure should I use. Also, I want to avoid hashing.
I have a tetrahedron $t$ and a polyhedron $p$. $t$ is constrained such that it always shares all its vertices with $p$. I want to determine whether $t$ lies inside $p$. I would like to add one detail to the problem in case it may contribute to the solution: $t$ is a Delaunay tetrahedron and faces of $p$ are triangular ...
From Wikipedia: The prefixes of a string is the set of all prefixes to a string, with respect to a given language: $$ \operatorname{Pref}_L(s) = \{t \mid s=tu \mbox { for } t,u\in \operatorname{Alph}(L)^*\} $$ here $s\in L$. So is it equivalent to $$ \operatorname{Pref}_L(s) = \{t \mid t \mbox { is the f...
Is there a software algorithm can generate a non-deterministic pattern or sequence? In Chaos theory, simple processes can create deterministic patterns, and psudo-random number generators can generate deterministic numbers with the same seed. Is there a software algorithm that can create completely non-deterministic pa...
Suppose I have an algorithm that works as follows when invoked: it calls itself recursively with probability $0 < p < 1$ and terminates with probability $1-p$. Does this algorithm terminate? On the one hand you can show that $\lim_{n \to \infty}p^n = 0$, so it must terminate at some point before infinity. On the other ...
I was watching the videos from Skiena's Computational Biology Lectures, which is also available at youtube. In those videos, the professor made a statement that, most of the problems posed to computer scientists by biologists were proved to be NP-Complete. My questions are the following ones: ( Please forgive me, if I ...
The Wikipedia summary of the Kosaraju-Sharir algorithm is as follows: Let G be a directed graph and S be an empty stack. While S does not contain all vertices. Choose an arbitrary vertex v not in S. Perform a depth-first search starting at v. Each time that depth-first search finishes expanding a vertex u, pu...
Let's say that we want to design a semi-definite programming approximation for an optimization problem such as MAX-CUT or MAX-SAT or what have you. So, we first write down an integer quadratic program that solves the problem exactly. For example, in the case of MAX-CUT we would write: $$ \max \sum_{\{u,v\} \in E}{\fra...
Consider the following problem: $$A=\left\{ (G(V,E),s,t)\mid\text{conditions 1, 2, 3 and 4 hold} \right\}$$ $G$ is a directed graph. $s,t\in V$. There is a simple path from $s$ to $t$ (a simple path is a path that visits every vertex not more than once). $\forall v\in V: \deg^+(v)\leq 2$ (in words: every vertex in ...
Input: 2 RB Trees A B, so that both values in a certain range, so that B's range is smaller than A in both sides. Ex. B's range can be [100...200] and A's range is [0...1000] Output: Unite A and B to one RB Tree AB. How can I unite these 2 trees in $O(log(n))$ time and with additional space $O(1)$? I have tried splitt...
From a paper An AND-compression is a deterministic polynomial-time algorithm that maps a set of SAT-instances $x_1,\dots,x_t$ to a single SAT-instance $y$ of size $poly(\max |x_i|)$ such that $y$ is satisfiable if and only if all $x_i$ are satisfiable. My question is: Is $t$ treated as constant? Another paper gives ...
I am unable to find a clear definition of term "size of the instance" when considering some algorithmic problem. I came accross a definition that said, that "Size of the instance corresponds to the size of the input array of numbers (in case the input is numeric) or size of the representation of the input." Is the size...
For a connected undirected graph $G$, given a particular vertex $v$, is there a known (efficient) algorithm to find all simple cycles in $G$ that contain $v$? In my case, I have weights for every edge. Ideally I'd like to be able to compute, for every $v \in V(G)$, the product of the edge weights over all cycles that ...
An imaginary processor has the following hardware specification: 8bit data bus 12bit address bus 32 × 8bit general purpose registers e.g. S0 – S1F Briefly describe what bit fields are required within an instruction to encode the following functionality: 56 different instructions Register addressing e.g. ADD...
Huffman encoding will perform best when the distribution of symbols of an alphabet that the string to be encoded uses is dyadic. Given an arbitrary bit string S, how can we find the best alphabet for encoding? Suppose S is an ASCII file. Then given the regularity of 1-byte characters that such files exhibit, we would e...
A producer wants to arrange couples of boys and girls for a dance. There are n boys arranged in a row [A1...An] in some certain order and n girls arranged in a different row [B1...Bn], also in some certain order. Only a couple in which there is a boy and a girl with exactly the same height can dance. The height of ever...
Input: A binary heap of size $n$. $n$ is even. Output: 2 binary heaps of size $n/2$ each. I found this question in a solved algorithms test and the solution said: "There is no better solution than to build 2 completely new heaps using BuildHeap() - $O(n)$ time." I have thought about taking out the root out of the origi...
I have a homework question which I would appreciate some help with: Let there be a DAG $G=(V,E)$ with positive weights. For every two different vertices $v_1, v_2$ we will define $D(v_1, v_2)$ to be the maximum length between $v_1$ and $v_2$ in the graph. For every two disjoint sub-sets of vertices $V_1, V_2 \subset V...
When we implement dynamic array via repeated doubling (if the current array is full) we simply create a new array that is double the current array size and copy the previous elements and then add the new one? Correct? So to compute the complexity we have 1 + 2 + 4 + 8 + .... number of steps? Correct? But 1 + 2^1 + 2^2...
If I have a sorted array of size $n$, can I build a Red Black tree out of it in $O(n)$ time in a different algorithm rather than splitting the tree in half every time or the straightforward way that was mentioned in one of the answers?
Suppose a person states the following: $n^2 = (n * n), \forall n > 0$. One can check such equality by saying, via proof by induction, that: for $n := 0:\ 0^2 = (0 * 0)$; for $n := 1:\ 1^2 = (1 * 1)$; and for $n := n + 1:$ $\ (n + 1)^2 = ((n + 1) * (n + 1))$ $n^2 + 2n + 1 = n^2 + 2n + 1$ As far as I understand, this s...
Wikipedia says, the regular languages are closed under arbitrary finite state transductions, like quotient K / L with a regular language. I wonder what kinds of operations "finite state transductions" are? Btw, It links to finite state transducer, an automaton. Thanks.
If one were to show that an NP-complete problem had $2^{n^{O(1)/\log{\log{n}}}}$ circuit complexity, what would the consequences of this be?
I have an algorithm similar to this: i=1 while(i < n) { //something in O(1) while(i < n && cond) { //something in O(1) i++ } i++ } Where "cond" is some condition which can be checked in $\mathcal O(1)$. It is clear that this algorithm is $\mathcal O(n^2)$. But is it also $\mathcal O(n)$? I'd say yes be...
Given: n variables in X, and m sets of variables where each set, Ci contains a subset of X. I am trying to generate the graph G = (X, E) by picking the edges in E given the following constraints. Variables in each set Ci must be connected by a spanning tree (no extra edges). The graph should prefer spanning tree confi...
If $B$ is a complexity class, then the class $P^B$ (for example) is defined as the set of problems that can be run in polynomial time, given an oracle to every problem in $B$. That's what they told me in my Theory of Computation class, anyways. Per this definition, it seems to me that $P^P$ captures every decidable la...