instruction
stringlengths
35
29.1k
what's the prerequisite topics needed for understanding computational complexity theory and analysis of algorithm ...including big-O and Big-theta notations and these staff. I want a mathematical background and good book suggestions for each topic ... thanks
In mathematics, the greatest common divisor (gcd), also known as the greatest common factor (gcf), highest common factor (hcf), or greatest common measure (gcm), of two or more integers (at least one of which is not zero), is the largest positive integer that divides the numbers without a remainder. For example, the GC...
I have finished developing an app for Android and intend to publish it with GPL -- I want it to be open source. However, the nature of the application (a game) is that it asks riddles and has the answers coded into the string resource. I can't publish the answers! I was told to look into storing passwords securely -- b...
This question is related to formal model checking theory, but I cannot find a tag for it. Let $P_{safe}$ be a safety property. $BadPref(P_{safe})$ is the set of bad prefixes for $P_{safe}$ A Safety property $P_{safe}$ over Atomic Proposition $AP$ is regular if its set of bad prefixes is a regular language over $2^{AP}$...
I've looked around the net for an answer to this question and it seems as if everybody implicitly knows the answer except me. Presumably this is because the only people who care are those who have had tertiary education on the subject. I, on the other hand, have been thrown in the deep end for a high school assignment....
This is the question: By definition of the IEEE754 standard, 32-bit floating point numbers are represented as follows: S (1 bit) E (8 bits) M (23 bits) S: Sign bit E: Exponent M: Mantissa Which of the following is the correct “mask bits” in hexadecimal to be used for extracting only the exponent part o...
Here is the description of the data structure I am looking for: Initial Original Data Index | Frequency | 1 3 2 1 3 7 4 2 5 6 Now it should be kept Sort-ed by their frequency inside the data structure like this, Index | Frequency | Cumulative Frequency | 2 ...
The subnet mask for a particular network is 255.255.31.0. Which of the following IP address belongs to this network? 172.57.88,62 & 172.56.87.233 10.35.28.2 & 10.35.29.4 191.203.31.87 & 191.234.31.88 128.8.129.43 & 128.8.161.55 Little bit confuse about 3rd octet of SM ( i.e .31 ) But got the point that 5 bit was hi...
In the model of (functional) programming languages as a category where the objects are types and the arrows are functions, I'm trying to really understand what's really the identity arrow. Barr-Wells "Category Theory for CS" says you need the id function, but I wonder: it really has to be the "do nothing" function? For...
Here is a proof that $0^*1^*$ is not regular, even though it is regular. I'm having a hard time figuring out what is wrong with the proof. Assume $0^*1^*$ is regular. Let $p$ be the pumping length as defined by the pumping lemma. Let $s = 0^{p-1}11$, then $|s| \ge p$ and $s \in 0^*1^*$. According to the pumping lemma, ...
I'm studying for an exam called Computer Fundamental, and started taking some previous exam but the given documents i had is way inadequate to solve all the question mentioned, like this one : Which of the following is the correct combination of variousaddressing modes? Here, X1 is an address which is stored in ...
I struggle with understanding why the satisfiability in the first-order logic is undecidable. Could you explain it with some examples? I've also seen that satisfiability in some first-order formulas are decidable. Please explain it with as much as many examples.
In a graph tree, is there any "smart/existing/efficient" algorithm to find linear segments of defined length? For example given a tree graph: g = {1 -> 2, 2 -> 4, 3 -> 6, 4 -> 8, 6 -> 12, 1 -> 3, 2 -> 5, 3 -> 7, 4 -> 9}; TreePlot[g, VertexLabeling -> True] How can one find all linear segments of length 4. In thi...
I needed help finding the context free grammar of this string $$ 10^{n}10^{n}1 $$ So far an idea I have is $$ S\rightarrow 1S1S1\mid 0S \mid \varepsilon $$ Any assistance you can provide would be greatly appreciated!
I am reading Frigo's "Cache-Oblivious Algorithms" paper and I need help understanding his cache complexity expressions for the base cases. He starts on page 3 with "An $s \times s$ submatrix is stored on $\Theta (s + s^2/ \mathcal{B})$ cache lines. I can see the reason for $s^2/ \mathcal{B}$ is because we have $s^2$ n...
this may seem to be a pretty basic question, but it is something i have been puzzling over for some time. when calculating the activations of nodes in a hidden layer in an ANN using sigmoid neurons for use with the backpropagation algorithm - should the output of the neuron be thresholded or not? say the activation vec...
I understand how I would do this if the problem were as such $8n + 5$ is $O(n)$ $c>0$ and an integer constant $n(not 0) \geq 1$ such that $8n + 5 \leq cn$ for every integer $n \geq n(not 0)$ we could let $c= 13$ and $n(not 0) = 1$ or we could let $c = 9$ and $n( not 0) = 5$. I'm just not sure how to go about $6n^2 +12n...
Also, is n O(n lg n)? I'm trying to understand this notation to better understand Big O. (Apparently they ask you questions about Big O in interviews, so I wanted to learn). I found a few formulas that I didn't understand.
I am trying to show the following problem is NP-hard and would like some help. Inputs: Integer $k$, and unordered set of $N$ numbers, $O$ Output: the $\max \sum\limits_{S_i \in S} \operatorname{mean}(S_i)$ where $S=\{S_1,S_2,...,S_k\}$, $O=S_1 \cup S_2 \cup \dots \cup S_k$ and elements of $S$ are disjoint. In simpler...
According to this chart, DCFLs are closed under reversal. However, I am not convinced as the intuitive proof (reversing the arrows of the controlling finite state machine and switching the pushes and pops) for this seems to depend on non-determinism in choosing the null transition to take from the initial state (since ...
I've found an heuristic algorithm[scatter search] that solves the common version of MDMKP(MultiDemand Multidimensional Knapsack Problem)[the one that maximizes] but what about the minimize version? is there any algorithm for that kind of problem? is it possible to obtain the solution to the minimum MDMKP from the maxim...
Asked this at programmers Stack Exchange, was recommend to ask here : What would be the big o for the algo: for (i=0; i < n*n; i++) for(j=0; j<i*i; j++) As per my understanding 1st loop will loop upto n^2 times. 2nd loop will go around n^2 times. Am I right or is it a O(n^6) representation. Also is there a easy way ...
I'm a teacher assistant in my university and my next topic is recursion. what way is the best to teach recursion so that the student can grasp the concept easily and can think recursively? I was thinking about explaining the stack structure to teach recursion but I'm worried that they get stuck in tracing the process. ...
I was reading this article about types, and started wondering how static type checkers could enforce other properties in programs. For example, say I wanted to create a language which would allow checking at compile time that a particular function was only called at most once every 300ms. How would I go about specifyin...
This may not be strictly a computer science question but is related. Whenever there is some function that computes more than two elements, is it possible that all elements are computed at once? Or is computing in composite/series a required limitation of the brain? For instance, to add three numbers, we add two and the...
For every rational function $p(x)/q(x)$ where $p$ and $q$ are polynomials with non-negative integer coefficients, does there exist a polynomial function $h$, such that, if you input a reduced fraction $a/b$ of length $m$ into $p(x)/q(x)$ and the output is of length $n$, then $m\leq h(n)$? The length can be taken as the...
Just as the question asks, I am trying to understand the relationship between the number of accept states a DFA has (not necessarily the total number of states) and the languages it can accept. I understand that the pumping lemma can be used to show that if a language has a length greater than the number of states, wh...
I was working on a project and I needed to display N squares inside a rectangle area and I want them to be as large as possible, no rotations. More formally: Problem: Given N equal-sized squares and a rectangle with width W and height H, find out the maximum size of the squares L such that the squares fit inside the re...
Could someone explain this proof to the following question? Lemma 22.1 from intro to algorithms Let $G=(V,E)$ be a directed or undirected graph, and let $s\in V$ be any vertex. Then, for any edge $(u,v)\in E$, $$\mathrm{dist}(s,v)\leq \mathrm{dist}(s,u)+1\,.$$ Proof. If $u$ is reachable from $s$, then so is $v$. In th...
I have problem that is reducible to the following: From a collection of stacks, find all items whose "keys" are on all stacks. My current solution to this problem is to just pop things off as quickly as possible store the items in the language's set type, compute the intersection every once in a while (the stacks are r...
Assuming i have 4 blocks of cache memory, Using the LRU (Least Recently Used) replacement algorithm on this following sequence of access to memory blocks: 1 2 3 4 5 2 5 4 1 5 2 3 : 1 2 3 4 5 2 5 4 1 5 2 3 1 1 1 1 5 5 5 5 5 5 5 5 2 2 2 2 2 2 2 2 2 2 ...
The elements of $\mathbb{Z}$ can be enumerated as $0, 1, -1, 2, -2, 3, -3, \ldots$. Similarly, the points of the lattice $\mathbb{Z}^2$ can be enumerated $$(0,0), (1,0), (0,1), (-1,0), (0,-1), (2,0), (1,1), (0,2), (-1,1), \ldots$$ I would like to extend this algorithm to $\mathbb{Z}^n$. Is there a simple way to do tha...
@Babou's answer to a recent question reminds me that at one time I think I read a paper about the equivalence (in terms both of the facts that can be inferred or proved and the time complexity of running the inference algorithm) of data-flow analysis, abstract interpretation, and type inference. In some sub-cases (like...
I'm trying to figure out a good (and fast) solution to the following problem: I have two roles I'm working with, let's call them players and teams having many-to-many relationship (a player can be on multiple teams and a team can have multiple players). I'm working on creating a UI element on a form that allows a user ...
Let A be an fixed array of size n. Q(i,j,k) is number of elements from A[i] to A[j] which are less than k. Currently I am using segment tree with each node containing sorted array of leaf elements. This answers the query in O((log n)^2) with O(n*log n) space and per-processing. Is there a way to answer this in O(log n...
Tarjan's off-line least-common-ancestors algorithm is given as follows: LCA($u$) Make-Set($u$) Find-Set($u$).$ancestor$ = $u$ for each child $v$ of $u$ in $T$ $\quad$ LCA($v$) $\quad$ Union($u$,$v$) $\quad$ Find-Set($u$).$ancestor$ $= u$ $u.color = $ BLACK for each node $v$ such that $\{u, v\} \in P$ $\qua...
I would like to begin by apologizing. I am not a computer scientist, so my use of terminology will be off. I came across an interesting problem, which I believe to be pretty hard and would love to get references or any other advice to know what to search for in the academic literature on this topic. Consider a standard...
I am learning the Haskell programming language. From what I am reading, Input/Ouput (IO) raises challenges for Haskell's purity, since by definition we are interacting with the outside world. From Wikipedia: In a purely functional language, such as Haskell, functions cannot have any externally visible side effects a...
when we are trying to solve a problem with dynamic programming. we have to follow some general steps characterize the solution structure Recursively define optimal solution compute the value from bottom up fashion Can anyone briefly explain the steps for this problem scenario. we need a 444 meter rope. but we have on...
If A and B are regular, then prove that $A@B = \{xy \mid x \in A \text{ and } y \in B \text{ and } |x|=|y|\}$ is always context free. So I'm trying to come up with the proof that looks something like this. Knowing that $A$ and $B$ are regular, we can conclude that there exists NFA for $A$ and $B$ respectively. Then, we...
You have n coins — they all look identical, and all have the same weight except one, which is heavier than all the rest. You also have a balance scale, on which you can place one set of coins on one side, and another set of coins on the other, and the scale will tell you whether the two sets have the same weight, and i...
As I am comparing between two algorithms, I was wondering which is the best approach to use to compare between the both. Big-O seems not the perfect metric for me, as the it's based on the worst-case, while most of cases in the area that I am working on is optimized. The second though is, I am using "Python-Maps" (and...
I am working on an online course on AI and I am now working to understand A* better. Basically, right now I am working on a problem where: we live on a tropical island and we're trying to navigate between areas, starting from d and heading towards q. I am trying to find: the cost used between d and q using A* search ...
In the literature, the terms of "process calculus" and "process algebra" are often interchangeable. Meanwhile, it confused me. My questions are: Are there formal, standard, and widely-accepted definitions of "calculus" and "algebra"? What are the significant distinctions (maybe informally) between "calculus" and "al...
Consider the Mergesort algorithm on inputs of size $n = 2^k$. Normally, this algorithm would have a recursion depth of $k$. Suppose that we modify the algorithm so that after $k/2$ levels of recursion, it switches over to insertion sort. What is the running time of this modified algorithm? I know that MergeSort has w...
I approached this problem where I have to write an add(key, value), insert(key, value), delete(key,value) and partial_sum(value) which reports the sum of all the elements in the structure that are larger than 'value'. This was my attempt at the solution, which works! But sadly it runs at O(nlogn) instead of O(logn).. I...
A* search finds optimal solution to problems as long as the heuristic is admissible which means it never overestimates the cost of the path to the from any given node (and consistent but let us focus on being admissible at the moment). But why does it always find the optimal solution if the heuristic underestimates? F...
I have been going through the description of the backpropagation algorithm found here. and I am having a bit of trouble getting my head around some of the linear algebra. Say I have a final output layer $L$ consisting of two visible units, and layer $L-1$ consists of four hidden units. (this is just an example to illus...
I have to find a bridge edge in a graph but have to find it efficient time complexity. Is there an algorithm that is better than Tarjan's Bridge-finding algorithm?
SAT solvers are getting more and more efficient in solving large instances and are being used as back-ends in various contexts. Every time one wants to use them to solve a problem in a specific domain, he/she has to come up with an ad-hoc encoding that not only has the right set of solutions but also puts the constrain...
I have an array of $N$ objects, each appearing exactly once. I also have a list of $M$ pairs of the objects. Each pair has a "non-adjacency cost" that must be paid if the two objects are not adjacent in the array. Is there an algorithm that orders the object array to minimize the total cost? The costs will change from ...
Given that $L_2$ is regular and infinite and $L_1 \cdot L_2$ is regular, then $L_1$ is also regular. I need some help on getting started on proving this is the case. My intuition is that if $L_1 \cdot L_2$ is regular there exists a DFA for it, in which case you can just remove the states that correspond to the $L_2$ ...
We have a clustering algorithm where the number of clusters isn't known to the algorithm - it iteratively creates clusters out of similar-looking data points. The evaluation metric we're currently using is: for each pair of elements in the dataset: if both elements belong to the same class: if both are in t...
I am having trouble with the regularity of the two following languages: i) $\{0^{n}1^{m}|n,m>0,n-m=0\,mod\,3\}$ ii) $\{0^{n}1^{m}|n,m>0,n+m=0\,mod\,3\}$ To clarify this is stating that the (#(0's) - #(1's)) mod 3 = 0. I know how to prove that the first language is regular without the n,m > 0 restriction but with it I ...
You are given an array $A$ of size N $(N\leq 1\,000\,000)$ containing all integers $1..N$ exactly once. You are required to answer query in $O(\log^2 N )$ and to preprocess in $O(N\log^2N)$: How many elements are there between indexes S and E, that are less than X? $( |L| : \forall l \in L \leftrightarrow A[l] < X \b...
I have to be able to perform insert, delete, range-value-sum, and range-2-max-values with a data structure. Range-value-sum(xl,xr): with a range [xl,xr] (for a range query), it reports the sum of values of all elements whose keys are in the range of [xl,xr], where xl and xr are real numbers and xl ≤ xr Range-2-max valu...
I am trying to show the following problem is NP-hard. Inputs: Integer $e$, and connected, undirected graph $G=(V,E)$, a vertex-weighted graph Output: Partition of $G$, $G_p=(V,E_p)$ obtained by removing any $e$ edges from $E$ which maximizes $$\max \sum\limits_{G_i \in \{G_1,G_2,...,G_k\}} \frac1{|G_i|}\left(\sum_{v_...
Given words $w_1,\ldots,w_n$ in binary alphabet and another word $w$, decide if $w$ can be written as a product $w = w_{i_1} \cdots w_{i_n}$ (in the monoid $\{0,1\}^\ast$) for some permutation of indices. Is this a known problem? Is it NP-complete? Details: The words $w_1,\dots,w_n$ are part of the input. Therefore, ...
What is the difference between machine epsilon and least positive number in floating point representation? If I try to show the floating point number on a number line .Is the gap between exact 0 and the first positive (number which floating point can represent) ,and the gap between two successive numbers, different? wh...
ANN when compared to biological neural systems have this common concept of reducing error in prediction over time (training) and becoming more good at predicting correctly. But there is one behavior of biological neural system where the prediction do become good over time but it also becomes fast and uses less energy, ...
U(n,x) is Gödel universal function, and we need to show {n:U(n,x) is defined for all x} is not enumerable. I do not have any clue right now. Anyone can give me some hint about this question.
I was reading chapter-1 The Foundations: Logic and Proofs from this book. The chapter gives example of translating English sentence : "There is a woman who has taken a flight on every airline in the world." as follows: Introducing variables : w for women, f for flight, a for airline Let P(w,f) : “w has taken f” Let Q(...
I am trying to find order of an bellow algorithm but I have no idea about, the problem like below we have an array of $n$ element name $T[1...N]$ and we have that $0\leq T[i] \leq i$ and $T[i] \in \mathbb{Z}$ then if we have that $\sum_{i=1}^{n}T[i] = s$ what will be the order of following pseudo code K := 1 for i = 1 ...
From Bash Reference Manual, a parameter: A parameter is an entity that stores values. It can be a name, a number, or one of the special characters listed below. A variable: A variable is a parameter denoted by a name. Is a variable is a parameter A, denoted by a parameter B which is also a name? How do you underst...
From Bash Reference Manual Expansion is performed on the command line after it has been split into tokens. There are seven kinds of expansion performed: brace expansion tilde expansion parameter and variable expansion command substitution arithmetic expansion word splitting filename expansion From the programming...
Consider an arbitrary undirected graph $G = (V,E)$. Suppose you have a collection of $|E|$ positive integers and each integer must be assigned to one edge. Let us denote the collection of integers assigned to vertex $v$'s edges as $w(v)$. How would one assign the $|E|$ integers to the $|E|$ edges so as to maximize: \...
I submitted a paper regarding hard real-time systems to an engineering journal. But the referees generally agreed my task model is too limited. My task model is a frame-based real-time application where all the tasks in the application have a common deadline D and are independent from each other. In the following Figur...
I am wondering what it takes to develop a game in assembly language. For example, what are the limitations or advantages from using assembly language in game development? Also, are there any programs/softwares to aid the development of games in assembly language?
I have a project that I am doing. The specification requires specific methods on a graph class. Two of the methods requires this: numberOfTrianglesIncidentToVertex(), calculates and returns the number of triangles incident to vertex v. The algorithm below calculates the number of triangles incident for all graph vert...
This is the first time we have to do recursive/closed form expressions WITH code in class and I really have no idea how to approach this. My course notes that the prof put up don't really help as he put up a basic example, but this one has lots of recursive calls in it. I know that the first part len(lst)$ \leq 1$ will...
Given a tree with N vertices numbered from 1 to N. The vertex 1 is the root of the tree. Each vertex is assigned with an integer weight. A remove operation can remove sub-tree rooted at an arbitrary vertex u. We must use at most K remove operations (possibly zero) so that the total weight of the remaining vertices is ...
I am working on 0-1 knapsack using greedy method, I have some problem in it. It's already proved that solution generated by greedy method for 0-1 knapsack is may or may not be optimal. If solution generated by greedy method is not optimal then Please tell me how i can improve solution so that solution generated is opti...
This is an interview question: Given a pile of cards, how to program to get card combinations whose sum is closest to 21? Example: input: Array : 2, 3, 4, 5, J, K output: 2, 4, 5, J 2, 4, 5, K I have a naive solution: check if two cards' sum is 21; check if three cards' sum is 21; check if four cards' sum is 21; chec...
When a virtual memory address outside the range of loaded into physical RAM is referenced and a page fault occurs, does the Memory Management Unit rely on DMA (Direct Memory Access) to swap the referenced page into RAM, or is an interrupt routine that uses the CPU to copy in the memory in some more mundane way occur? P...
Is there a class of formal grammars that generate Recursive Languages only? (ie with which it is not possible to generate non recursive languages.) If so what kind of production rules/restrictions do they have? And why are they not a part of Chomsky Hierarchy?
I have the following problem: I need to generate $\ell$ random permutations each of length $n$ from a list of $m$ elements ($m \ge n$) by a predefined probability matrix $P$ of size $n$ x $m$. Distribution probability matrix $P$ = {$p_{i,j}$} describes the probability that i-th position is occupied by $j$-th element ($...
I'm so far a self taught programmer who's mostly been working on simple web and app development. But now my teacher wants me to enter a school competition in programming. Of course the competition is based on problem solving and such, areas I'm guessing counts as computer science. Even though I don't have much experien...
I'm reading a paper about Constraint Satisfaction Problems, specifically "A Characterization of Strong Approximation Resistance", Subhash Khot, Madhur Tulsiani, Pratik Worah (ECCC TR13-075). The following sentence appears in the third paragraph of the very first page: "... the fraction of satisfied constraints is at l...
How does one show Lovasz theta of even $n$-cycle ($n$ is even) is of form $\frac{n}{2}$? Why is the Lovasz theta of such cycles not of form $\frac{n \cos(\frac{\pi}{n})}{1+\cos(\frac{\pi}{n})}$. Could someone provide a derivation for even cycle Lovasz theta number. It is clear that the Shannon Capacity is $\frac{n}{2}$...
I use Princeton's WordNet in NLP applications. I always read that it is "human-curated." But how is it curated? Who decides that words belong in a synset? How does the process work? Wikipedia does not give many details. How does it work?
In the binary tree shown below, which of the following trees is created after conversion into a (max) heap? There are 4 anwsers to choose : By definition, a max heap is a complete binary tree in which the value in each internal node is greater than or equal to the values in the children of that node., so a, c, d a...
When updating the weights of a neural network using the backpropagation algorithm with a momentum term, should the learning rate be applied to the momentum term as well? Most of the information I could find about using momentum have the equations looking something like this: $W_{i}' = W_{i} - \alpha \Delta W_i + \mu \D...
Say I have a set of sample measurements of a one dimensional curve in the image plane $f(x)$. What is the purpose of minimizing the following functional $$E(S) = \int \left[\lambda(S''(x))^2 + (f(x) - S(x))^2 \sum_k \delta (x - x_k)\right]dx$$ I believe it has something to do with energy minimization and snakes.
What are the open activation records of a recursive algorithm ? Edit: Activation records are the number of times that we call a function that is not finished yet. Correct? So we can find the number of activation records only when we are given a specific input array and we cannot say something for a general array with d...
I am a novice programmer and very weak in complexity calculation. I have learnt to write a program for creating all possible subsets from a set of elements, i.e. knapsack algorithm. Now I would like to know how to calculate the complexity of the algorithm. Can anyone help me with better clarification. Here is my code:...
If you can make no assumptions about the hash function, how can you find the expected number of slots of certain size k in a hash table? Looking more for a theoretical proof type of answer than a programming answer.
I'm stuck on an excercise in my maths class. How can I find an explicit lower bound for the harmonic series sum: $$\sum_{x=1}^{2^m}\frac{1}{x}\,?$$
I understand the basic but what I dont understand is this: so base 16 to base 10 357/16 = 22.3125 but on this example im looking at says remainder 5?
This question: Solving the recurrence T(n) = 3T(n-2) with iterative method has a pretty straightforward step-by-step for solving this particular recurrence. But, I'm having trouble understanding two things. 1) How dos OP arrive at this general form? If we know T(n)=3T(n−2) and T(n−2)=3T(n−4), then my substitution giv...
a minimum heavyweight spanning tree is a spanning tree in which the heaviest edge is as light as possible. Formally, input : given connected undirected weighted graph, $G$. output : a spanning tree $T$ for $G$ with property that every spanning tree $T'$ for $G$ has some edge $e'$ such that $w(e')\ge w(e)$ for every ed...
I'm looking for an effective method to simulate a program. Why I am needing this is because sometimes I can only have the program's description, code, and all I have left is pen and paper when I want to calculate the result at the end, or the n-th loop, or step n-th ..etc.. For example : Declare @i int While @i < 1...
I have been playing around with artificial neural networks lately, specifically with the prospect of trying to replace the contrastive divergence algorithm with some type of evolutionary metaheuristic technique (i have been working with PSO) to do unsupervised pre-training, but I have come up against some issues when t...
Last time, I was asked to solve a concurrency problem involving 100 similar processes constrained to fit into 5 buffers. (I'm talking about the Dining Savages problem.) I thought that it was alright to use a semaphore with value 5 (Semaphore x=5) for constraining the 100 proceses. As it turned out, the solution given u...
I read some note about Automaton Course. i see this note, that following all is the same. but i think the L(g) is not equal to NFA and regular expression. anyone could help me with defining the language of this figures (nfa, regular expression and grammar):
I am studying data structures and the book "How to Think About Algorithms" by Jeff Edmonds (pages 46-47) claim that: "Hopefully, all the elements that are in your set happen to be placed into different entries in the table. In this case one can determine whether or not an element is contained in the set, ask for an a...
I am having a hard time figuring out if $$\sum^n_{i=0} O(1) =O(n)\,.$$ I think it doesn't but I am unable to find a convincing explanation for that, does anyone have an intuitive yet mathematical answer for that?
There are some algorithm or solving a simple maze on the web; but what I am trying to solve is a bit more complicated. Here is an example: #################### #S #D # # # # ## ## ###D### # # # # # ## # # # ## # # ### ##### # # # # D# # ### # ### ### ## # ##### # # # ...
Lets have an arbitrary complexity class $C$. Does $C$-complete = co-$C$-complete imply that $C$ = co-$C$? I think that the answer is yes, but I am not sure whether my reasoning is correct. I tried to prove it like this: Let $L$ be a $C$-complete language, so all problems in $C$ are polynomially many-to-one reducible to...
Let $\Sigma = \{0,1\}$, and suppose that $A$ is a regular language. Define $$A' = \{ u \mid \exists a, b \in\Sigma: abu \in A\}$$ i.e., $A'$ is obtained from $A$ by taking every string in $A$ and removing its first 2 characters. Show that $A'$ is regular. My solution so far is: $ab \in \Sigma^*$ which is regular. $A$...
What is the asymptotic runtime of fthe ollowing piece of code in terms of number of updates to S in worst case. Void foo( int n) { int S = 0; for ( i=1 ; i<= n ; i++) { for( j = 1 ; j<= i*i ; j++) { if(j % i == 0) { ...