instruction
stringlengths
35
29.1k
Is it possible to transform RSA to SAT during polynomial time? (Polynomial number of variables and clauses of logical formula and polynomial time of creating logical formula). The size of the task is obviously the number of bits $n$.
Why is average case analysis considered more difficult than both best and worst case analysis? Specifically, how do you approach and complete best and worst case analysis as opposed to average case? Thanks!
Assume a function $T(n)$: $$T(n)=\log{\log^{*}{n}}$$ Let's define: $$\log^{*}{n}=\min\{i\ge{0}:\log^{(i)}{n}\le1\}$$ and: $$\log^{(i)}{n}=\log{(\log^{(i-1)}{n})}$$ Is the following $f(n)$ function an upper bound or a lower bound of $T(n)$? $$f(n)=\log^{*}{\log{n}}$$ To see if $f(n)$ could possibly be an upper bound, I...
I've been trying to create my own random number library(in java). I've searched for randomization and Blum Blum Shub algorithm looks good. It needs a start value, it is not actually random. So i get unix timestamp mod(10) for first value. Now i can generate random numbers. My question is; how can i modify my structure ...
I have encountered a problem in class, tried solving it and faced a problem, I will include my ideas, and the problems i faced. Assume F is a PRF, 1.denote $P_k(x) = F_k(x) ⊕ F_k(1^n)$ for any $n ∈ N, k ∈ \{0,1\}^n$ and $x ∈ \{0,1\}^n$. Is P necessarily a pseudorandom function? 2.denote $P_k(x) = F_k(x) ⊕ 1^n$ for any...
Do there exist a set of inductive rules and a fixed point of these rules but is neither the least nor the greatest fixed points?
A set of n points and m line segments is given. We are given two disks of radius r. We need to place the disks in such a manner so that maximum number of points are covered. A disk covers a point only if its center and the point can be directly connected, i.e, the line joining the center of the disk and a point should ...
My problem looks like a secret sharing problem. That’s to say: We have N people. Each of those owns a word to share to other people. The aim is that all people know all the words of other participants. People can only discuss in houses. There are H houses. Each of those may only accept a limit of L members. In a house,...
Does a PDA only move states when both the input symbol matches and the symbol on the top of the stack matches? In other words, is it possible to have two different transitions that both take the same input character but pop different stack symbols? For example if we have a state Q0 with the two following transitions: a...
How exactly do you track the exact amount of iterations? I know its probably basic but can't figure out how so was hoping someone could explain to a complete beginner how you arrive at an answer. def f(n): i = 4 while i < n: print(i) i = i + 1 ( The answer should be max(n−4,0) )
Let a directed graph $G = (V, E)$ be given, plus a constraint map $c: E \rightarrow V$ and a set $T \subseteq V$ of initial token locations. A valid move consists of sliding a token from $v$ to $w$ if: $v \in T$ — to slide a token, it must be there. $w \not \in T$ — to move a token somewhere, the new place must be em...
I have a project where I should write the following algorithm : Let an integer function $f\colon\{1,2,3,\ldots,n\} \to \mathbb{Z}$ be monotone and suppose that $f(1) > 0$ and $f(n) < 0$. We would like to find the smallest integer $i$ with $f(i) < 0$. Design an algorithm for this purpose that run in time $O(\log n)4. ...
How exaclty do you determine this specific codes runtime is theta(n^2)??I can see theres two while loops which go from i and j to n but would like a more precise way of determing this? If someone could explain is simple terms as I am very new to this I would appreciate it. def f(n): i = 0 while i < n: j = 0 ...
When I read introductory textbooks I get contradictory answers. In some cases efficiency and complexity are treated the same and the big-O notation is used to indicate that (for example) for an O(n) algorithm the time to execute is linearly proportional to the input dataset size. From other sources I have read that eff...
Prove that PTIME has no complete problems with respect to linear-time reductions. I know that PTIME means all these problems that we can solve them in polynomial time. I suppose that I should use here time hierarchy theorem - I know it. However, I have no idea how to solve it. I am beginner at this subject so I as...
I am looking for a sorting algorithm to help me in my work. My objective is the following: after receiving an input of this kind: 5 4 1 2 2 3 3 4 4 5 The first line tells me how many ids I have, and the second number tells me how many connections. The following lines tell me the connections, and tell me that the first...
Since I don't have CS background I will most probably ask this question the wrong way. I need to choose a node from a tree, where I include all beneath this node leafs in a validation. I have a data set from a big web directory that categorized websites. I already wrangled the data around so the root of every category ...
Imagine a Fibonacci heap with 1 tree: a root node, 4 child nodes (to that root node), with 2 of them being leaves and the other 2 having 1 child each (7 nodes total). Is this a legal Fibonacci heap? In other words, does there exist a series of actions that lead to this sort of heap structure. My intuition tells me no...
What algorithms/heuristics exist for efficiently determining the relative order between two elements in a partially ordered set? In my case, the PO-set is stored as a directed acyclic graph where an edge is an happened before relation and I am streaming live data into this PO-set. Nodes usually have less than 5 backwa...
For the problem described in Ex. 15.9 about breaking a string a) Prove optimal substructure b) Write the recursive definition for defining the least cost solution c) Write the algorithm (either the memo-ized version or bottom-up version) If you could help me get started on any of the above three questions (or all thre...
Bin packing: Given a set of $k$ items where item $j$ has size $s_j$ and a set of bins of capacity $C$ each. Use the minimum number of bins to pack all items while respecting the capacity of the used bins. If I select one bin arbitrarily and put in it the maximum possible number of items and repeat this until no item is...
In un-directed graph it is easy to find cut vertex and bridge but in directed graph removing cut vertex/bridge must increase number of strongly connected componenets.
We know that if a $\#P$-complete problem has a deterministic reduction to $FNP$ version of an $NP$-complete problem then polynomial hierarchy collapsed to first level. Is there a consequence if we had a randomized reduction? By a randomized reduction here I mean a reduction that works for permanent of $\frac1{n^c}$ for...
Treewidth : 1) By chordal graphs : size of the largest clique $(\omega (G))$ - 1 in a chordal completion of the graph $G$. 2) By tree decomposition : A tree decomposition of $G = (V , E)$ consists of a tree $T$ (on a different node set from $G$), and a subset $V_t ⊆ V$ associated with each node $t$ of $T$. (We will c...
I have read TONS of articles about context free grammars and Pushdown Automata but I think there are things that I dont seem to understand. I am not studying computer science but I am really interested in many of the topics and I hope you can help me realign my knowledge about the CFG and PDA. So my question is: could ...
I am stuck on a problem in which I have to print sum of 2Pi mod 1000000007 for all i where Pi is sum of numbers in ith subset of a set X. Length of set can be upto 100000. Value of element in the range [0,1012]. Here's the link of the Problem. Problem Statement I could not find any approach other than Brute-Force whic...
I want to write an algorithm that takes an $n \times n$ grid and a number $L$, generate a random walk of length $L$ on the grid that doesn't visit the same cell twice. One simple solution would be keep randomly choosing a neighbour of the last cell to add to the path. I found that for small density (i.e. $L < 0.625n^2$...
I cannot solve this exercise: "If a processor has a cache hit rate of 99.5% and a cache miss penalty of 160 core processor cycles, what will the average CPI be for 1,000 instructions?" how can i do this?
I have $x$ uniform machines that are identical, except that each runs at a different speed; machine $j$ runs at speed $s_j$. I have $n$ identical jobs. Each machine can handle one job at a time. The time to complete a job on machine $j$ will be $1/s_j$ seconds. I want to prove that the optimal schedule that minimize...
The original question was "Do all non-regular languages have an uncountable number of strings?". How can someone prove that..? I am squeezing my head but I can't figure it out. And the other side of the coin: is a language always regular, if it has a countably infinite number of strings? A bit more generally: is rep...
How to show that PSPACE and PTIME are closed under Kleene star ? I can only show that NP is closed, but it is easy because we can use non-determinism to guess partition of word. In these two cases I don't have idea how to attack it.
I am new in the ML. I know that overfitting is memorizing the data while training. Like in Neural Network, if we make lots of layers and lots of hidden nodes, we can memorize all the data, but it can be bad because train data would not cover the whole space. Like this, is there any way to overfit in SVM and Logistic Re...
I want to know how the first programs to be able to execute more than one programs within a common time span were like . I went through the history of the topic and it seemed like Strachey was the first one to work on multi-programming . Hence , i thought of reading his paper "Time sharing in large and fast computers" ...
In the context of computability and turing machines Let $L_1$ be an undecidable language and $L_2 = \{n \in \mathbb{N} | \exists x \in L_1 |x| \geq n\}$ How can I prove if $L_2$ is decidable or not? I guess $L_2$ is not decidable in general and it depends on $L_1$ but still nothing proved. \
In my opinion it is uncountable since we can think every natural number as a member of one alphabet like $\quad0\in\sum_0 ,1\in \sum_1, ... \quad$ And there are also other symbols than natural numbers in alphabets. So there is no possible 1:1 and onto mapping from set of all alphabets to natural numbers. Thus they cann...
I'm trying to to create an algorithm (working in polynomial time) to solve the following problem: What maximum number of knights that any two of them don't attack each other can be placed on a 3✕n chessboard with holes (knight can't be placed on a hole). Width of the chessboard (n) and positions of holes are given. Bes...
We have defined two complexity classes which have a close relation with the notion of infinity. The first one is: We say that a language $L$ belongs to $UP_{\infty}$ if there exist an infinite sequence of languages $L_{1}, L_{2}, L_{3} \ldots$ where for each $i \in \mathbb{N}$ every language $L_{i}$ is in $UP$, has an ...
In Introduction to Formal Languages by György E. Révész a polynomial time algorithm that can convert a left linear grammar to a right linear one is presented. Trying to understand when it is useful I read that left linear grammars are generally harder to parse than right linear grammars. Is this statement true? I'm a...
I'm trying to use the concept of DFS traversal to go through a cycle, and attempt to get a balance of 0 in the end. Each student either owes or is owed some money, so I'm trying to go through all of said students and make sure each one can pay the other. The input for your algorithm consists of two lists $owing$ and ...
I am implementing the dynamic programming algorithm for computing tree alignment distance as described in "Alignment of trees — an alternative to tree edit". But I got stuck in lemma 3 on page 141 (page 5 of pdf). The notations are given at the beginning of section 2. The last case in lemma 3 says However, there is no...
I've been straggling a little proving the argument "a hamiltonian directed acyclic graph has a single topological sort". This is pretty much the idea of what I've come along: lets prove by contradiction. so lets assume a hamiltonian DAG has at least 2 topological sorts. If there're few topological sorts - it means one...
Recall the fold function for lists: $fold(f,z,[x,xs]) = fold(f,f(z,x),xs)$ $fold(f,z,[]) = z$ I want to formally proof that if $f$ is associative, commutative and idempotent (meaning $f(x,y) = f(x,f(x,y))$ and we have to lists $l_1$ and $l_2$ such that their contents are equal then $fold(f,z,l_1) = fold(f,z,l_2)$. Wha...
I am building a parser generator, not for any project in particular, just for fun to improve my understanding of parsing, grammars, languages, etc. I am at the point where I have lexer generation down pat. That is, I have defined a way to specify token definitions from regexes and split an input string into tokens base...
Given a large collection $\mathcal{X} = \{X_1, X_2, \dots, X_n\}$, where each $X_i$ is a set of integers, what's a fast algorithm to identify all pairs $(i,j)$ with $i \ne j$ such that $X_i \subseteq X_j$? The best I can think of is the following (rather naive) algorithm: Sort each set $X_i$. Sort $\mathcal{X}$ by car...
Let's say I have three functions and each gives true/false answers. The first one gives 2 booleans, the second 6 and third 4. Are they written like this: 01 110010 1000? Do they get spaces between the functions? If so, do the spaces count as data? What I wanna know is, if you send an encryption key using RSA, how does ...
Now, I have the following conjecture. $\text{MOD}_{2017}(x_1, \ldots, x_k)$ is computable by a bounded depth polynomial size circuit in the basis $\{\neg, \text{MAJ}\}$. However, I am at a loss at how to realize/see this. Could anybody help me out?
Consider a self-stabilized distributed system based on shared memory and the processor $p_{i}$ be connected to the processor $p_{j}$. Suppose we are going to solve a problem like finding a maximal independent set or minimal dominating set and we need to break symmetry. For breaking symmetry, we use id of processors. My...
I am interested in experimenting with machine learning on the ASTs of programming langauges (e.g. some Java code). I would like to develop an algorithm that determines if a given AST satisfies some predicate. I have a training set of programs that do and do not satify the predicate. The machine learning techniques th...
I was reading in Papadimitriou's "Computational Complexity" book Chapter 14, about Oracle Machines. Papadimitriou defines, in definition 14.3, page 339-340, Oracle Turing Machines with oracle a language $A \subseteq \Sigma^*$: The computation of $M^{?}$ with oracle access $A$ in input $x$ is denoted $M^A(x)$. So far ...
First of; this is my first computer science problem, so bear with me. That said: I'm trying to create a planning application for my summer camp (sailing school) with the goal to put everyone with different people every day (when possible). Variables defaults Group size: 4 (max. people per boat) Total people: 20 Days: ...
Column S contains the check sums of the values given in columns R and Xc. Does anyone here have an idea about how to find the corresponding algorithm to calculate the check sums? Thanks in advance R Xc S 647 72 218 441 47 618 594 67 188 581 55 517 497 58 865 553 65 661...
I want to generate a random connected simple labeled graph with $n$ vertices and $m$ edges, selected uniformly over all connected graphs with such $n$ and $m$. I found this approach. It says: build a random spanning tree using a loop-erased random walk (also called Wilson's algorithm); then add remaining $m-n+1$ edges ...
What is the exact number of loop iterations here and how do you find out? def func(n): i = 4 while i < n: print(i) i = i + 1 The solution says max(n-4,0) which is theta(n), but I am confused about how they reached this. I see it starts from 4 and can guess that this relates to the n-4, but would like to be...
Of course, whenever the Pumping Lemma for Regular Languages (or CFLs) is applied to a language $L$, only a single string $w \in L$ and $|w| \ge p$ needs to be picked (to eventually show that $w$, when pumped, leaves the language). Is there a non-regular (or non-context-free) language $L$ for which every string $w \in L...
I'm taking an Advanced Computer Architecture course and I've come across the term "outstanding" a few times and I've searched online about what it means in the context of computer science/architecture but I can't find anything relevant. For example, on my notes there are some references such as: "IBM Power5 allows 8 o...
I am building an application (RoR framework) that can help to match a tutor and a student based on their subjects, budgets, locations and freetime. I have done the first three parts(subjects, budgets, locations). Now, I am getting stuck at the most difficult one which is freetime matching. The student's sample freetime...
In the proof of TQBF-complete, it says if the input size is i, then the TM for the input has at most 2^i numbers of configuration. Can someone explain why? The proof is from: http://zoo.cs.yale.edu/classes/cs468/fall12/TQBF-complete.pdf
This is a question related to a homework assignment so I guess I'm asking for hints, if that's ok? Basically, I'm wondering if there is some way to use Tarjan to compress the nodes in every SCC found into one single node, essentially producing a DAG. The problem I'm faced with is that every SCC is obtained as a set but...
as part of my homework assignment I have to proof that the following language is not regular using the pumping lemma: $L = \{w\in \{a,b,c\}^* \; | \enspace z(a,w) = z(b,w) + z(c,w)\}$ The function $z(x,w)$ denotes the number of symbols $x$ in word $w$. I started my proof by assuming that the language is regular. That m...
A few years ago Warren Buffett started offering $1 billion to anyone who could correctly predict the winner of every game in the NCAA men's basketball tournament. A 64 team (we won't count the first four play-in games) single-elimination tournament bracket like "March Madness" has 2^63 possible bracket combination, put...
I have noticed that some applications or algorithms that are built on a programming language, say C++/Rust run faster or snappier than those built on say, Java/Node.js, running on the same machine. I have a few question regarding this: Why does this happen? What governs the "speed" of a programming language? Has this ...
This question is motivated from the question $\mathrm{SPACE}(o(\log\log n)) = \mathrm{SPACE}(O(1))$. I am wondering, how is it possible to decide a language without reading the entire input. I have seen the similar situation in space complexity ( L and NL ,where we define new model of computation). My model of comput...
I want to solve the following problem (This is a homework problem. Not looking for definite or complete answers): Maximum One Third Cut: Input: An undirected graph G=(V,E) where V={1,2,...,n}, such that |V| is divisible by 3, and a positive integral weight function w:E to N (on edges). Goal: Fin a subset of vertices U...
Programmers prefer accessing a 2D array in Row-Major Order rather than Column-Major Order, Why? Are there some advantages/benefits of accessing a 2D array in row-major as compare to column-major? Like in C programming, programmers prefer row-major rather than column-major due to the way memory is being allocated to a 2...
I have a couple of Python scripts that calculate various network measures. Given a graph (G), the first script calculates the average shortest path from each node to all other nodes and stores this in an Nx1 matrix (L). An implemntation of Djikstra's algorithm from the NetworkX Python library is used for this: for i in...
I need to prove the following asymptotic relation for the purpose of cacluating a recurrence relation: $$n^3log^4n=O(n^4)$$ I tried and failed to do it with induction, which, if possible using basic Calculus 1 level math, I would like you to help me with. I am not required to do it with induciton or anything, I just wo...
The project I'm working on has a number of objects arranged in overlapping sets. I need to classify them by whether they have a trait or not, using pre-classified objects that they are connected to (through shared set membership). I.e., the objects within the same set are likely to share whether they have that trait. T...
I am trying to align two objects based on the notion of points and their correspondence, but struggling to find a solution. I have two objects A and B. However, they are rotated in a different direction, and therefore I would like them to align. I have a notion of some correspondence between the points in object A and ...
I know that the lanuguage of all strings of odd length {a,b} can be expressed as: (a+b)((a+b)(a+b))^*. But what about an odd length over (a,b,c}?
The above is an MCQ from an online quiz given by my Algorithm lecturer. The available options are 6secs, 4secs, 12secs and 20secs. The answer I selected was 12secs and it was rejected. The lecturer said the answer should be 4secs and then I started to prove that the answer is greater than or equal to 8secs in the follo...
I'm working through a few chapters on algorithms from the Discrete Math text by Rosen. In the solutions manual there is an algorithm (specified in pseudocode) for finding the mode within a list of non-decreasing integers. Here is the algorithm: procedure find a mode(a_1, a_2, ... , a_n : non-decreasing integers) modeco...
For the worst case of a red-black tree, what would a tree with 10 nodes look like?Since there can not be 2 consecutive red nodes and there is rotation is it safe to say that it balances out the trees leveling it I tried this attempt at creating a tree with 10 nodes:
Is there a Turing-Complete-ish programming language without runtime errors? Like segmentation faults, memory leaks, race conditions, deadlock/livelock/starvation, etc.? With strongly typed languages, the compiler can detect null pointer exceptions and refuse to compile code. How much can we statically check? Everything...
I've been working on a developing a product selection network for my workplace. I work with lots of chemicals and the clients don't always know what they want/need so most of the time I have to ask a bunch of question, collect useful/ignore useless information, then make a selection from there. Discussions take place o...
I have 10,000 sequentially numbered items I wish to characterize. For each item, I created a list of the other items I think might have a similar characteristic. i.e. Item 1: [2,4,7,8,9,...,9489] (list contains 250 items) Item 2: [1,4,13,23,...,9424] (list contains 12 items) Item 3: [1,2,4,7,...,9489] (list contains 1...
How would you go about proving that this Language is Context free. I'm having issues with drawing the PDA for this. I need to prove Prove that the language L = {w | number of 11s in w is more than the number of 010s} is context free. I so far assume that when a string of 11s occur add x to the stack and when 010s add ...
Breadth first graph search adds states that have already been visited to an explored set to avoid getting stuck in loops and cycles. This is fine since breadth first search needs exponential space to keep all the nodes in memory. One of the main reasons for using iterative deepening depth first search is to avoid the e...
I would like to construct a LL(1) context-free grammar for a formal language $A$ = "strings where the amount of character b is exactly triple compared to the amount of character a" for $\Sigma = \{a,b\}$. I've tried to figure it out so that if we consider a string $w$ to have one a, then the acceptable presentations fo...
Consider the following problem. The input is a Directed Acyclic Graph. Each vertex $v_i$ may have exactly 0 or 2 incoming edges with associated vertices $v_{i1}$ and $v_{i2}$. If it has 0 incoming edges, it is considered an input vertex. The input of the problem specifies with each input vertex exactly two numbers out ...
I want to ask the acceptance problem: Whether a particular deterministic finite automaton accepts a given string can be expressed as a language, $A_{DFA}$. Show $A_{DFA}$ is decidable. The proof in the textbook (Siper page 195) uses two steps: $M$ = “On input $\langle B,w\rangle$, where $B$ is a DFA and $w$ is a strin...
Find $f\colon \Bbb{N}\to\Bbb{N}$ such that $f = n^{o(1)}$ and for every $c\in\Bbb{N}$, $f(n)=\omega(\log^c n)$. It looks like I need to find a very small growing function $g$ that will satisfy $$\lim_{n\to{\infty}} \frac{1}{g} = 0 $$ and also $$\lim_{n\to{\infty}} \frac{\log^cn}{n^{\frac{1}{g}}} = 0 $$ My first attem...
I just read an article "Statistical approach for figurative sentiment analysis on Social Networking Services: a case study on Twitter", which provide an algorithm to analyze tweets, and this article includes 2 formulas which I don't really understand. Link to the article I hope maybe someone here can help me. The fir...
I'm working on a paper about model checking on cryptographic protocols and many of the papers I have read, base their approaches in the Needham-Schroeder protocol. I undestand this was one of the earliest security protocols for authentication and that Lowe's findings makes it an interesting protocol to talk about, I ge...
By abstract machines I mean things like the SECD machine, Krivine's machine or more generally machines with states/memory/registers/stack/accumulator... According to Wikipedia page of the Curry-Howard isomorphism, we have a correspondence with the Sequent Calculus where the left/right introductions rule matches with th...
In Girard's Proofs and Types we can read : From an algorithmic viewpoint, the sequent calculus has no Curry-Howard isomorphism, because of the multitude of ways of writing the same proof. This prevents us from using it as a typed $\lambda$-calculus, although we glimpse some deep structure of this kind, probably ...
Below is a question based on CLRS, about using an algorithm to reach a balance between a group of friends. I figured the best way to do this, is through the use of a DFS algorithm. Below the question is some psuedocode I wrote using the formal algorithm of a DFS search. My question is, how do I get the algorithm to bal...
Do networking ports come from "port-mapped I/O"? I was watching a hardware basic video by Brian Will: https://www.youtube.com/watch?v=9-KUm9YpPm0 And they brought up this concept at 18:15 Initially, I thought it makes sense that networking ports come from the implementation of port-mapped I/O, but it's strange that the...
I'm trying to implement L-BFGS but I can't quite figure out how to do step sizes. I tried small fixed step sizes, but for some reason the iterates always explode whenever memory < variable size (which is kind of the whole point). So I thought I'd try some back tracking line search. My issue is, I don't want to re-evalu...
There are possibly several min-cuts for the source and target nodes of a graph. I think I can determine the same min-cut for the same graph by putting the following restriction "if there are several min-cuts, then I select the min-cut consisting of edges closer to the source atom. By saying close to source atom, I mea...
I am trying to solve a string matching problem using Rabin-karp algorithm. I made use of Horner's method for calculating hash function, but I forgot to use modulo operator. It's like this now. (this is for starting pattern length of the big string) 1 for(i=0;i<l1;i++) 2 { 3 unsigned long long int ...
I was given this function: $T(N) = 3N\log^2 N + 5N^2\log N + \log N + 17N + 2$ and was asked to find the average Big O complexity. If the Big(O) deals with an upper bound, would this algorithm be $O(N^2\log N)$ on average? But, because Big O is an upper bound, couldn't this also be $O(N^3)$, $O(N^4)$, etc.? Basically, ...
There is the following theoretical computer science, namely: For a particular monotone formula $M$ of size $n$, there's an equivalent formula of depth $\text{O}(\text{ln}\,n)$. (I am reading the original paper in my library, if I have time later I will scan it and add scans of it to this post. My apologies for being ...
I have to prove that the language $L=\{a^ib^j:2i=3j+1\}$ and the CFG G with the following rewrite rules: $S\rightarrow a^2Tb$ $T\rightarrow a^3Tb^2 |\epsilon$ are equivalent to each other. I'm going to prove this by saying $L(G)\subseteq L$ and $L \subseteq L(G)$. I was able to prove the first one. I should be able to ...
What is Architecture, microarchitecture and ISA in processor. How do they relate to each other and what is the difference between them. Elucidate their differences with examples so that it is clarified. Also, clarify, do the word computer architecture and processor architecture mean the same thing?
If I have m lists with n elements each, how would I go about finding duplicates in them (i.e. an element is in more than one of the lists)? My idea is to use hashing on the elements inside the list, which involves a O(1) hashing call on each of the elements and checking for collisions inside the buckets. However, on to...
Got this question in an exam. In a graph where all edge weights are positive, if a subset S of the edges connects all vertices and has minimum total weight, then the edges in S form a tree? True or false? This seems to be the definition of a MST, but since it doesn't state anything about cycles I'm not 100% sure.
From my basic understanding of computer architecture, a computer understands instructions and a computer program written in a high level language is converted to a set of such instructions for the computer to understand. Also, that given a set of rules are satisfied, any programming language can do what any other can ...
Please help me find the time-complexity of below recursive algo. I have guessed for first two return statements.Please correct me if I am wrong. But I can't find time-complexity of third return statement because it will loop till we get a factorial of NUM contining 0 and 7. public class Check { static long N...
Suppose that in an enterprise there is a section specialized in data prediction problems, and to make easier the software maintainance, the next decision is taken: it will be used only one algorithm and only one class of functions to approach solutions for any future problems. Will this decision benefit the enterprise?...
The problem is IV-3 of this pdf: potential function. Defining a potential function as $\Phi(i) = 2i - 2^{\lfloor{\log_2i}\rfloor+1} + 1$ The solution states that if $i$ is not an exact power of $2$, we have: $$\Phi(i) = 2i - i + 1 .$$ This means that $2^{\lfloor{\log_2i}\rfloor+1} = i$. I'm having some trouble underst...