instruction
stringlengths
35
11.4k
Given a string of size n consisting of 0s and/or 1s.you have to perform k queries and there are two types of queries possible. "1"(without quotes): Print length of the longest substring with all '1'. "2 X"(without quotes): where X is an Integer between 1 to n.In this query, you will change character at Xth position to...
As regards the topic. Here is an example of such a graph:
I heard about a technique today which is sometimes used in the classification of 2D images of handwritten glyphs. It goes like this: Find the highest activated pixel of the image, the lowest activated pixel of the image, and average their heights. This creates a horizon at the "geographic" center of the image. You then...
I have an expression in DRC $\{\langle a,b,c \rangle \mid \langle a,b \rangle \in r \land \langle a,b \rangle \in s\}$, where $r = (A,B)$ and $s = (A,C)$. I want to convert it onto relational algebra and got this: $π_{A,B,C}(σ_{r.A = s.A \land r.B = s.C}(rxs))$ and I am not sure if it is correct... Can someone explain...
I'm following this paper titled "Coverings and colorings of hypergraphs" by Lovasz 1973, which is referenced in Garey and Johnson's Computers and Intractability, for the Set Splitting Problem. In this paper, the author tries to reduce graph chromatic number to hypergraph 2-colorability (same as set splitting). You can...
In the following 2 statements - 1. Anyone who eats any pumpkin is a nutrition fanatic. &forall x ((&exist y (PUMPKIN(y) &and EAT(x,y))) &rarr FANATIC(x)) 2. Anyone who buys any pumpkin either carves it or eats it. &forall x &forall y (PUMPKIN(y) &and BUY(x,y) &rarr CARVE(x,y) &or EAT(x,y)) In the first case any pum...
IRL as I understand is where the AI is given a policy from an "expert" and needs to solve for the reward function which best fits the policy. And Apprenticeship Learning via IRL was explained as an expert demonstrating a skill and the reward function also has to be derived using the expert behavior. I don't necessarily...
The regex /^(abc)$/ matches abc but why not abcdabc, abcdabc also begins with abc and ends with abc. I am not sure about the semantics of this regex. Any explanation is welcome.
Given a simple graph with $n$ vertices, show that you can remove all edges in $O(n\log n)$ rounds, where in each round you are allowed to remove all edges of any (single) path.
Given $T$, an MST of $G(V,E)$ connected and undirected. Assume we add an edge $e'$ with weight $w(e')$. Suggest an algorithm which takes $T$ as input, and outs $T'$ MST of $G'(V,E\cup\{e'\})$.So i thought about adding $e'$ to $T$ and removing the heaviest edge in the cycle that was formed. Can anyone suggest how to go ...
A unit disk graph is an intersection graph $G = (V,E)$, such that given $n$ disks on the plane with identical radius. Each disk $d_u$ corresponds to a vertex $u \in V$, and there is an edge $uv \in E$ if, and only if $d_u$ and $d_v$ intersects. In 1990, Clark, Colbourn, and Johnson showed that the problem can be solved...
In my assignment I find these symbols: $|w|$ where $w \in L \subset \Sigma^*$ I believe it means the lexikografic value of a word, but I am not 100% certain. Let me phrase my question this way: could this notation have any other meaning ?
I am given a set of pairs of dates and would like to extract features I can put into an machine learning algorithm. Thus far I have already written two different metrics, however I didn't find much literature on that topic. I know there is a lot of literature about on computing the distance or similarity of strings. ...
Let's say we are working with a system that has 40 physical address bits. The total physical address space (assuming byte-addressable memory) is $2^{40}$ bytes, or 1 TiB. And if virtual addresses are 48 bits in length, that means there are more addresses available to virtual memory than there are locations in physical ...
Robot in a grid: Imagine a robot sitting on the upper left corner of a grid with $r$ rows and $c$ columns. The robot can only move in two directions, right or down, but certain cells are off limits and the robot cannot step on them. Design an algorithm to find a path for the robot from the top left to the bottom right....
I have been asked to prove that: Being C an infinite set. Prove that C is semidecidable if and only if exists a total computable function that is injective and whose image is C. I've read the wikipedia articles of computable function and recursively enumerable set and I saw these properties are true. But I have no ide...
I am trying to apply BFS to the following problem, but I'm not sure how to do it Input: directed graph $G$ defined by the array of adjacency lists with n vertices and m edges, and a vertex $v$ in $G$ Output: $true$, if $v$ is a part of a cycle, $false$ otherwise Can someone explain in pseudocode or in words how to do...
Does anyone know how I should approach this algorithm? It needs to have $O(n^3)$ complexity and I can only come up with an algorithm that has $O(n^4)$ complexity (of doing a n^2 min path from each vertex to $n-1$ other vertexes, and since I need to do this n times, it will be $n^4$ or so I think... Input: Array $A[1.....
Let A = {(B,w) | B is an NFA that accepts w}. To prove that N is a decidable language, M = "on input (B,w) where B is NFA and w is a string, simulate B on w. If B accepts w, accept. Otherwise, reject" Is this a false proof? The proof from the textbook says that I have to convert NFA into equivalent DFA but I'm not sure...
i have researched it on wikipedia and it produces me an unusual example and stories about Turing,so what i understand is if an program run in loop,an electronic device in cpu or in computer structure would stop that program,or an code will be processed by the input to decide if the program will be executed or will be h...
In the introductory chapter of $\textbf{PCP}$ in Arora and Barak, I read the proof that why a $\textbf{PCP}(\log n, 1)$ of completeness 1 and soundness 1/2 for an $NPC$ language $L$ will imply that there exists a $\rho$ for which $\rho$-approximation algorithm for MAX-3-SAT does not exist unless $P = NP$. But in the pa...
I got confused with deterministic and probabilistic algorithms. Am I right by assuming that algorithms are called probabilistic once they use some sort of randomness? Initially, I thought only algorithms outputting random numbers are called probabilistic. They are obviously non-deterministic. However, what about the f...
The problem I wish to solve is the following: Given a set $V \subset \mathbb{Z}^2$ find the set $S \subset V$ such that $|\sum_{v \in S} v|$ is maximal. By simply enumerating subsets we can solve this problem in $O(2^n)$. This problem feels a lot like the euclidian traveling salesmen problem to me but I can't quite mak...
I know how to find a regular expression when given a FA. But how do I find a regular expression given just a language and its rules? For example, for the language $L \subset \{ a,b\}^* $ which accepts all words that contain exactly one $aa$. How do I find a regular expression in this case? I know that I would be able t...
I am trying to solve the following exercise: Let $G = (V,E)$ be a graph. Show that the following two problems are NP-hard: $G$ has a spanning tree where every node has at most $k$ neighbors, and $k$ is part of the input. $G$ has a spanning tree where every node has at most 5 neighbors. It's written that 1 is supp...
I was looking through my notes on domain relational calculus, and noticed an interesting result in a question about finding the most expensive pizza(s), given a pizza table with schema $\text{pizza}(\underline{id}, size)$. The first idea that came to me was: $$\{id1\ |\ \exists size1, \forall id2, \forall size2 \ (\te...
Intersection of CFL and regular is always CFL. But according to Chomsky hierarchy diagram, regular languages lie completely inside CFL. So, as regular set is completely inside CFL set, their intersection should be regular right ? Am I interpreting Chomsky diagram wrongly ?
This is a pretty naive question, but I would like to better understand the basics of information storage on a computer. I am not concerned with the detail of how any one operating system achieves this. I know there are different ways to identify which bits in memory make up a given file (on a given machine at a given ...
Hello all I am kinda confused on how to solve the above recurrence since the masters theorem would not work with the above equation. Could anyone please help me solving this and showing me the steps? Requirement is to find asymptotically tightest bound. $$T(n) = 4T(\frac{n}{2})+n!$$
Let $n = -13, \ k = -24$ How do I find the 4-digit 5's complement of each number? What would be the result of $n + k$ in complement representation? I understand how to calculate $n$-digit, 2's complement. I convert it to base 2, invert and add one. Also, with positive numbers, let's say $n = 13, \ k = 24$, the 4-digit...
Does an algorithm exist to check for the existence of a Real-Time Multiprocessor Schedule for aperiodic hard tasks(all of which have the same Release time)? Assumptions: The processors are Uniform parallel machines Job preemption is permitted Job migration is permitted Job parallelism is forbidden EDIT: Let there be ...
Let $L_1,L_2$ be any $\Sigma$-Languages, with $l_1\in L_1, l_2\in L_2$ If I have a regular Language $L(l_1(l_2l_1)^*l_2)$ would the word $\omega=l_2$ be recognized? I'm confused because if $\epsilon \in L_1$ then $l_1$could be $\epsilon$, then $L(l_1(l_2l_1)^*l_2)$ would recognize the word with $(l_1 = \epsilon) *((l_2...
I am trying to find all mother vertex in a directed graph. A mother vertex in a directed graph G = (V,E) is a vertex v such that all other vertices in G can be reached by a path from v. My Approach: Do DFS on each vertex and check if all the vertex are reached on each start node. Time complexity : O(V*(V+E)). I am loo...
Yes, this is a quiz question. It's from a self-paced course, but the answer just isn't correct to me no matter how I look at it. There isn't really an active community to consult. My Regular Expression experience is profoundly in JavaScript and I'm concerned that it poisoned my thinking of Regular Expressions. For the...
Our professor explained that all programs can be thought of as the set of natural numbers, while decision problems can be thought of as the set or rational numbers. Our notes say a decision problem can be represented as a function which takes a natural number as input and maps it to either 0 or 1. That the range is 0 ...
I'm studying for my operating systems final, and one question that my professor asked that I can't seem to find the answer to is the following: "Why does virtual memory use non-contiguous memory allocation?" The textbook only talks about virtual memory in the context of non-contiguous memory allocation, but never expla...
I have a graph and I'm trying to enumerate all paths that start at node $S$, end at node $E$, uses each edge, and minimizes the number of edges used (i.e. it can only re-use an edge if strictly necessary). What I am wondering is that if I have a solution path, e.g. $SADBCABE$, can I find all other valid paths that use ...
I am trying to understand how to work out time complexities given certain recurrence relation, however I know that in certain recurrence relation some numbers can be omitted since they make no difference when $n$ gets very large. The problem i'm having is being able to identify the numbers that can be omitted. For exa...
One statement of Rice's theorem is given on page 35 of "Computational Complexity: a Modern Approach" (Arora-Barak): A partial function from $\{0,1\}^*$ to $\{0,1\}^*$ is a function that is not necessarily defined on all its inputs. We say that a TM $M$ computes a partial function $f$ if for every $x$ on which $f$ is de...
There is a definition for kind of actions that only care for outcome. Classic example for such an action is remove from collection: When you try to remove an item that doesn't exist in collection, there are two possible outcomes: failure with item doesn't exist or success (because the outcome is that the item doesn't e...
Is the set of all countably infinite strings over a finite alphabet that contains more than one letter countably infinite?
Can an ambiguous context-free grammar be converted into Chomsky normal form? I think the answer is yes.
I've been trying to solve the following question: Show a polynomial algorithm for the following problem. Let $G = (V, > E)$ a graph. The goal is to decide if there is $E' ⊆ E$ , such that for every vertex $v ∈ V$, $v$ meets or exactly $k$ edges from $E'$. (Namely, for $k = 1$ you get the perfect matching problem)...
Let L1 be a language generated by a CFG. Let L2 be a language generated by a regular grammar. Is L1 = L2 ? Is the above problem decidable or undecidable ? If L1 = L2 then L1 $\cap$ L2' = $\phi$ So the above problem can be written as CFL $\cap$ RL = $\phi$ or CFL = $\phi$ which is decidable. So the answer should be...
I'm interested in the maximum number of intersections that a line and a triangulation on $n$ points could have. More specifically, given $n$, we are interested in the worst-case (maximum) number of intersections that any line could have with any triangulation on any point set. There is an upper bound of $2n-5$ on the n...
I am reading dis, It reads: The dis module supports the analysis of CPython bytecode by disassembling it. The CPython bytecode which this module takes as an input is defined in the file Include/opcode.h and used by the compiler and the interpreter. In wikipedia In computer science, an interpreter is a computer progr...
The diameter of an undirected, unweighted graph can be found in $O(n^3)$ with e.g. the Floyd–Warshall algorithm. However, there is an idea how to improve the runtime: Pick a vertex $v$ Find $u$ such that $d(v,u)$ is maximum Find $w$ such that $d(u,w)$ is maximum Return $d(u,w)$ This idea fails; for instance, when sta...
I'm currently stuck at the following task: Consider a point set $S = \{ p_1, p_2, ..., p_n \}$ in the plane in general position (i.e., no three points of $S$ are collinear). The points of $S$ have pairwise different $y$-coordinates and are sorted in increasing order of them, i.e., $y(p_i) < y(p_j) $ if and only if $i <...
Disclaimer: This is a homework question. I would like to reduce vertex cover problem to the following problem: $$L = \{G \mid G\text{ has a vertex cover of size } |V(G)|/2\}\,.$$ I have divided the problem into three parts: $k = n/2$: This case is trivial. $k > n/2$: Yes in vertex cover problem does not necessarily me...
(NOTE: This is not a homework question at at all. Rather, this was something that I thought that I understood (at least on the surface), but now appear to have no clue about, and am not currently finding any resources helpful. I know that we typically like to see what people have tried, but I am honestly discombobula...
Say I am given a rectangle of width $W$ and length $L$. I now have to fit as many regular shapes of area $A$ into this rectangle as possible. For example, if the shape is a circle, I need to fit as many circles of area $A$ into the rectangle as possible. All the shapes trying to be packed in a given instance are identi...
Suppose that we have numbers between $1$ and $1000$ in a binary search tree and want to search for the number $363$. Which of the following sequences could not be the sequences of nodes examined a) 924,220,911,244,898,258,362,363$ b) 925,202,911,240,912,245,363 c) 2,399,387,219,266,382,381,278,363 d) 935,278,347,621...
The general term for folds is a catamorphism. The general term for unfold is an Anamorphism. Is there an equivalent term for map? I know that a map is a type of fold however restriction is significant. Also it would be useful to have an alternative term to use when the word “map” is ambiguous.
Is "Given a CFL L and a regular language R, is intersection of L and R an empty set?" decidable? What if we replace L with the complement of L? One of them is decidable and the other is not. For the one that is decidable, give an algorithm. For the other, give an undecidability proof. For the first part "Given a CFL L ...
After coming across the assertion that given $$ x^2 = y^2 \pmod n \\ x \neq \pm y \pmod n $$ we can then conclude that n factors into $$ n = \mathrm{gcd}(n, x-y) \mathrm{gcd}(n, x+y). $$ in this article, I attempted my own example but it doesn't seem to work. I think there's a missing hypothesis, but more...
My textbook states that CIRCUIT-SAT is in NP because you can guess an input and verify it in polynomial time. My textbook also states that a problem is in NP if and only it has a polynomial-time verifier V(I, X) such that: if I is a YES instance, then there exists an X s.t. V(I, X) = YES if I is a NO instance, then fo...
I've been studying the skiplist analysis from the open data structures book here: Open Data Structures I've understood the first 3 lemma's, (after looking at how they use indicator variables in the section 1.3.4 of the book). However, Lemma 4.4 seems pretty vague. Especially, how is $$\sum_{r=1}^{\lfloor\log n\rfloor}1...
I am reading dragon book for compilers. I am not able to understand in which phase does syntax directed translation actually happen. A CFG can have set of semantic rules attached to it which is evaluated. For example, we can have semantic rules attached to a CFG which adds the type of identifier in the symbol table. D...
I have a data type that accepts and returns byte arrays. However, the input is from a network callback or loading a huge file in piecemeal and the output is CRLF-terminated lines. The internal storage isn’t groups of bytes, but a single packet of bytes where the partitions extracted don’t have to match the ones inserte...
Let $L\subseteq \Sigma^*$ a Language $R_L$ is the Myhill-Nerode-Relation of $L$ $\equiv_L$ is the Syntactic Congruence of $L$ $R_L$ and $\equiv_L$ are equivalence relations and are defined as follows : $x\:R_L\:y \:\Leftrightarrow \: [\forall w\in\Sigma^* : xw\in L\Leftrightarrow yw\in L] $ $u\:\equiv_L\:v \:\Leftrigh...
The proof of theorem 27 in http://www.math.ias.edu/~avi/PUBLICATIONS/MYPAPERS/IKW02/IKW02.pdf suggests 'If $NEXP = MA$, then $NEXP ⊂ P/poly$". However looking at it seems it is close to stronger 'If $NEXP = EXP$, then $NEXP ⊂ P/poly$". Can $NEXP\not ⊂ P/poly\implies NEXP\not = EXP$ be plausible?
Suppose that I want to get the size of the biggest palindrome in a string s, and I am restricted to do it using suffix trees what is the best complexity I will get and why? I checked other answers but I find them highly confused. EDIT: I tried create a suffix tree with the string and the inverse of the string and use a...
In automata theory, we all read automata as finite automata, from the very beginning. What I want to know is, why are automata finite? To be clear, what is it in an automaton that is finite - the alphabet, language, strings made with regular expressions, or what? And are there (in theory) any non-finite automata?
I've already done some research on this topic, but it still isn't quite clear to me. According to this post patricia trees are radix trees with $r = 2$. Every patricia tree I've seen so far is used to store alphanumeric symbols. Assuming that there are used 8 bits to represent one symbol, $r$ is the number of bits comp...
I am not very into computer science theory but i feel like people are defining nondeterministic polynomial time as if it is another name of exponential time. I would be happy if you clarify it. thank you
The problem says: Given an undirected simple graph G such that each node has at most d + 1 neighbors, color each node with one of d + 1 colors so that for each edge the two nodes have different colors. Hint : don't think too hard. just color the nodes. what loop invariant do you need? I was trying to solve this.. but q...
Assuming that ATM is decidable, how to build a TM S that uses a TM R that takes as input and decides if M accepts w, to decide HaltTM, which we already know is undecidable, hence ATM isn't decidable. So how exactly do we go about this?
given an unweighted graph, does the graph diameter equal to the maximum DFS tree depth? and the same about BFS? regarding both directed and undirected graphs. thanks :)
I'm working on the following exercise: Consider a point set $S = \{ p_1, p_2, ..., p_n \}$ in the plane in general position (i.e., no three points of $S$ are collinear). The points of $S$ have pairwise different $y$-coordinates and are sorted in increasing order of them, i.e., $y(p_i) < y(p_j) $ if and only if $i < j$...
I've been trying to solve this problem for two days. This problem is from Vazirani's book Approximation Algorithms (pg 23). Given an undirected graph $G = (V,E)$ with nonnegative edge costs, and an integer $k$, find a partition of $V$ into sets $S_1,\dots, S_k$ so that the total cost of edges running between these se...
If there is a proof that an NP-Hard problem which is not NP-Complete can be solved in P time, it does say that the verification time is polynomial too. Why doesn't it then mean that all NP-Hard are NP (i.e. NPC)? But, if there is something with exponential verification i.e. outside NP and since it can be reduced to an...
Let $L\subseteq \Sigma^*$ a Language $R_L$ is the Myhill-Nerode-Relation of $L$ $\equiv_L$ is the Syntactic Congruence of $L$ $R_L$ and $\equiv_L$ are equivalence relations and are defined as follows : $x\:R_L\:y \:\Leftrightarrow \: [\forall w\in\Sigma^* : xw\in L\Leftrightarrow yw\in L] $ $u\:\equiv_L\:v \:\Leftrigh...
I'm trying to prove that $n\log n$ is space constructible. I've already managed to prove that $\log n$ is space constructible, but I cannot figure out how to prove the same about $n$. I assume, that if both $n$ and $\log n$ are space constructible, $n\log n$ will be space constructible as well. I'm using Sipser's defin...
Goal: Find a simple path in G, that visits the maximum number of vertices in Z and prove it is NP-complete. G = (V , E) Z is a subset of V How would I go about doing this?
If I have a scheduling problem, is it possible that Hall's theorem can be applied? I was thinking that the graph representation of the scheduling problem can be the preferences of the people / workers getting scheduled. Is there any such result or counter-claim?
I have to find computational complexity of an expression for Euclidean distance d(x,y)= {(x1-x2)^2 + (y1-y2)^2}^1/2 But I have certain confusion because of which I am unable to proceed. Firstly there are two variables. Secondly since there is a root ,what will be its effect? If there were no roots, I can understand...
I have a question Given a 16-bit register A holding a number in 2’s complement form, use a single gate (e.g., AND, OR, XOR, NAND, NOR, NOT) with an arbitrary number of inputs to implement a circuit that produces an output 1 if the number is divisible by 16, and an output 0 otherwise. The bits are labelle...
I thought of some mixed algorithm: binary + interpolation search. While first has $O(\log n)$ runtime in both worst and average cases, second has $O(n)$ worst case runtime and $O(\log \log n)$ average case. However, I think, if such algorithms can exist, there are more than one of them. Anyway, what I want to know if t...
Let $S_{n}$ be an input set whose elements are length $n$, namely $S_{n} = \Sigma^{n}$. For every probabilistic polynomial-time algorithm $A$ and any $u \in \Sigma^{*}$, there exists a function $f^{A}$ such that $f^A(u) = \mathrm{Pr}[A(u) = 1]$. And let $f^{A}_{n} = \left.f^{A}\right\vert_{S_{n}}$ be a function from $S...
General problem Given a space $S$ which is $N$-dimensional, bounded, and quantized Given a set $P$ of unique points Find the set of collinear subsets of $P$, each containing at least 3 points One point can exist in multiple subsets Specific problem I am creating a 4D, 5 by 5 by 5 by 5 tic tac toe game. Each dimension...
Let $G$ be multipartite directed weighted graph with $k$ independent sets (we will call them "layers"). We select exactly one node from each layer and form the induced subgraph $H_k$. That is, $H_k$ has exactly $k$ nodes (one from each layer) and contains all edges from $G$ that have both endpoints in $H_k$. Our goal ...
I am working on the problem of finding cycles in an undirected graph. I made up my solution by first detecting if any cycles are present with a DFS algorithms and detecting any backtracking, and second, recursively explore all the found backtracked edges until I find the starting vertex. The problem I have is that this...
I'm reading right now Computers and Intractability by Garey and Johnson. I've found the definition of PTIME complexity class a little strange. This is how it looks: Let $\Sigma = \{ 0,1\}$. By $\Sigma^{*}$ we denote the set of all finite strings created from symbols from $\Sigma$. If a computation on a Deterministic Tu...
In << Data Structure and Algorithm Analysis >>, turnpike reconstruction problem is given for demo of backtracking. Suppose we are given n points, p1 , p2 , . . . , pn , located on the X -axis. Xi is the x coordinate of pi . Let us further assume that X1 = 0 and the points are given from left to right. These n points d...
$k = \Theta(n)$ The arrays consist only natural numbers $1$ to $n$ The sum of the length of all arrays = $\Theta(n)$ It should return the $k$ original arrays, each sorted on its own. The running time should be at worst $\Theta(n)$. How is it even possible? There's something I must be missing because I have no idea how ...
Given positive numbers $x_1,x_2,\ldots,x_n$, a positive integer $k$, and a positive real number $D$, determine whether we can divide the numbers (according to the ordering) into $k$ parts so that each part has sum at least $D$. A simple greedy algorithm works here: Find the least $i_1$ such that $x_1+x_2+\ldots+x_{i_...
I read following here: Unambiguous grammars do not always generate a DCFL. Example: For example, the language of even-length palindromes on the alphabet of 0 and 1 has the unambiguous context-free grammar S → 0S0 | 1S1 | ε. An arbitrary string of this language cannot be parsed without reading all its letters first, ...
Suppose I have a sequence of elements $a_1,\ldots,a_n$ in a group and I want to compute, for varying $1\leq i\leq j\leq n$, the product $b_{i,j}:=\Pi_{i\leq k\leq j}a_k$. Then I can do a precomputation of all $b_{1,j}$ and later determine each needed $b_{i,j}$ as $(b_{1,i-1})^{-1}b_{1,j}$. The cost is $O(n)$ group oper...
how would you prove if this language is regular/irregular? question given: Decide for each of the following languages whether it is regular. If so, design a DFA/NFA for recognizing it, and if not, give a formal proof(based on the Pumping Lemma). i) {a^i b^j c^k|i ≥ 0, j ≥ 0, k ≥ 0 are three integers}; I have construc...
Is the following a familiar problem ? Given a graph $G = (V, E)$ and a capacity function $c:V \to \mathbb{N}$ find a spanning subgraph $H$ of $G$ such that $1 \leq deg_H(v) \leq c(v)$ for every vertex $v \in V$. I would like to know if this is an NP-hard problem so any pointer to a similar problem (NP-hard or not) will...
Given a graph $G = (V, E)$ and a natural number $k$, consider the problem of determining whether there is a way to color the vertices with two colors in such a way that at least $k$ edges are polychromatic. Prove that this problem is NP-complete. I thought about reducing it to the 3-colorability problem, but I can't ...
This was a question that came up in a past exam paper in my computer science course, it states: "There are two simple, un-optimised sorted data structures, each storing n numbers. The first is a list; the second is an array. What is the worst-case complexity of extracting the median number from each data structure? Are...
As merge sort and quicksort both have the same average time complexity of $O(n \log(n))$. In which scenarios would merge sort be preferred over quicksort when sorting data?
The theorem that "all languages are undecidable" offers the self-referential program as evidence in its proof, assuming that there exists a decider that decides L. The goal is to disproof this proof as it is not true that all languages are undecidable.
Suppose I have an algorithm $A$ that is known to halt before $f(n)$ steps for some function $f: \mathbb N \rightarrow \mathbb N$, where $n$ is the size of the input, and output is always either zero or one. Is it a decidable problem to determine whether $A$ always outputs zero?
I'm trying to understand how type safety is preserved for value types and for reference types, specifically in languages with managed memory (such as C#). I understand that reference types (i.e. classes) have data allocated onto a managed heap, with a reference to that data allocated on the stack. Is there metadata a...
We're given two positive integers $t$ and $s$ of length $n$ in binary representation. Suppose we divide the numbers into ${n \over k}$ blocks of size $k=\lg n$ using FFT algorithm. Suppose that the multiplications that occur during recursive calls do not increase the length of the resulting numbers (not necessarily ...
The maximum number of nodes in a binary tree of depth k is defined by $2^{(k+1)}-1$, but the same rule doesn't appear to work for heap trees of different degrees. Let's say I have the following tree of degree 3 1 / | \ 2 3 4 Here the depth of the tree is 1. So according to the formula, it will be $3^{(1+1)}-1=8$...
Are there any problems where there is no smallest time complexity, so there is a big-$\mathcal{O}$ but no big-$\Theta$? More formally, I am looking for any problem $p$ where for any algorithm that solves $p$ in time $f(n)$ there provably exists another algorithm that solves $p$ in time $g(n)$ where $g(n) = o(f(n))$. ...
I have a floating point number x from [1, 500] that generates a binary y of 1 at some probability p. And I'm trying to find the x that has highest p. I'm assuming there's only one maximum. I know we can do this with simulated annealing but I don't think I should hard code temperature because I need to use the same algo...