instruction stringlengths 35 29.1k |
|---|
Task. Find such natural numbers a1,. . . , am , that none of them would be included in the list of excluded numbers, a1 + · · · + am = N and max{a1 , . . . , am} would be as small as possible. Numbers cannot be reused.
Initial data. The first line contains two natural numbers N and K - desired sum and length of exclude... |
I've been looking for an algorithm which divides an undirected graph into 2 subgraphs.
However, unlike most existing work on graph partitioning out there (like METIS), I don't intend to obtain subgraphs that contain the same approximate number of vertices. Instead, I would like these 2 subgraphs to have similar count o... |
I have this tiny program for finding largest prime divisor (taken from Code Review Stackexchange and written by user Altinak: https://codereview.stackexchange.com/a/74792):
Here is my try to write it in pseudocode:
GLOBAL VARIABLE highest;
// This function takes parameters n and f with 1 <= n and 2 <= f.
// It return... |
In the following video on computer organization:
https://youtu.be/DoR505t8-7I?t=114
the instructor displays the following:
and says that the hex string 0xFFFFFF00 is equivalent to -256. After doing a calculation to see this represented in two's complement, this makes sense to me. For my question below it'll help to ... |
I tested my XSAT solver using the 4 pigeons in 3 holes problem converted to XSAT. The pigeon hole instance I give below had 108 variables and 88 clauses after being converted to monotone XSAT. My solver quickly proved the instance was unsatisfiable. While converting the proof back to SAT I realized some of the reductio... |
We had this problem on our Algorithms final. It threw me off because if $\log$ is $\log_2$ then graphing the function shows this is not true, but if $\log$ is $\log_{10}$ then it looks like it is. How can this idea be formalised?
|
Since I know that the reduction Clique $\leq_{p}$ Vertex-Cover and Vertex-Cover $\leq_{p}$ Set-Cover are possible, I know how to show this using transitivity property of reductions. However is there a direct reduction from Clique to Set-Cover problem possible ? I have not found any reductions on this in the internet. ... |
I wondered if, for a fixed integer $k ≥ 3$, how can I construct a circuit for each $n \in \mathbb{N}$, that takes as input an n-bit integer $x$ and outputs whether 3 divides $k$?
Considering an n-bit integer as input:
e.g. $\ldots10101110$, where $a_0$ is the rightmost bit and $a_N$ the leftmost bit, $\bmod 3$ has a cy... |
A monad is an endofunctor $T:C\rightarrow C$ with natural transformations $\eta:id_C\rightarrow T$ and $\mu:T^2\rightarrow T$.
Being natural transformations mean that $$T(f)\circ \eta_A = \eta_B\circ id_C(f)$$ should hold and $$T(f)\circ\mu_A = \mu_B\circ T^2(f)$$ also. These are the algebraic expressions that the defi... |
As a cryptographic primitive, universal hashing should have somewhat a criterion on its security. How is its (computational) security defined? Or, in other words, what "breaks" a universal hashing?
|
The language $L_1 = \{ a^nb^nc^n \}$ is often given as an example of a context-sensitive language.
I am wondering if the language $L_2 = \{ a^nb^na^n \}$ belongs also to the same category?
|
I found this question in one of our past exams, and I'm not to sure about the correct answer.
I have a language L1 (which i don't know anything about) and another language L2, which is regular, the question is: given that L1L2, L2L1 are regular can i also say for sure that L1 is regular?
At first my answer was no, sinc... |
It's given that the bandwidth-delay product defines the number of bits that can fill the link; while the sender can send (1+(2 * Bandwidth * Delay)) units before getting acknowledged for the first unit. Can anyone help me to realize the practical implication the phenomenon of filling the link will imply? What can be th... |
I’m interested in substitution systems: maps which use a set of rules to transform elements of a sequence into a new sequence.
For simplicity we will consider here only binary 1-D arrays.
Unlike the Wolfram language definition, I suppose that LHS of rule may be any length.
So a set of rules like [[0] → [1, 0], [1, 1] →... |
I have the task to write a program that puts students in classes and that in the best possible way.
We have given the name, the foreign language a student chooses(french or latin), a profile (Music,bilingual or normal) and 2 friends and enemys for every student in a table.
A friend is someone a student should be in a c... |
As I understand that a video file is a binary file, the frames are not really present in a contiguous manner in a video file, so reading the video file by doing a seek and reading it frame by frame wouldn't work until you have loaded the entire file into memory and then go through it frame by frame.
But if you see any... |
Statement of problem
We have two sets of vertices, $V$ and $U$, each of which has a vector of attributes $A$.
The set of edges $E$ is defined such that there is an edge $vu\in{E}$ between vertices $v$ with attributes $[a_1,a_2,...]$ and $u$ with attributes $[a'_1,a'_2,...]$ IFF a function $f([a_1,a_2,...],[a'_1,a'_2,..... |
It's common in machine learning papers to see things like $p(x,z|\theta)$ or $p(x|z)$. Where $x$ is usually the data vector, $z$ the latent vector and $\theta$ the model parameter, like network weights.
However is there a way to make sense of these notations from measure theory's perspective? Perhaps $(x,z,\theta)$ is ... |
If I understand correctly, the first incompleteness theorem says that any "effectively axiomatized" formal system which is consistent must contain theorems which are independent of the axioms. In other words, there are models of the system where the theorem is provably true and others where it's provably false.
This s... |
We are given an array of length $N$ and $Q$ queries (offline) where each query is a value $K$, for each query we need to count number of pairs in array with XOR $K$.
If $N$ and $Q$ can both be upto $10^5$, is it possible to answer these queries better than traversing entire array for each query?
An analogous version to... |
I'm reading a paper that involves an algorithm for RSGD. It's clearly a form of stochastic gradient descent, but I can't find what the R stands for. The authors provide their own implementation of it, and I would like to find its original formulation to compare.
|
How can I prove that BPP is close to Symmetric difference?
I tried to find proof online but couldn't.
Can anyone please provide a quick explanation (if it's trivial and I just can't see it) or a link to proof?
|
I am a math undergrad and we have algorithms as one of our courses. We came across TSP and algos to solve them. I thought of an algorithm and apparently its already known as the Nearest Neighbour algorithm. Could anyone tell why it might lead to longer tours with instances (short numerical examples maybe) ?
Thanks in a... |
For context, yesterday I posted Does the first incompleteness theorem imply that any Turing complete programming language must have undefined behavior?. Part of what prompted me to ask that question in the first place is that, awhile ago, someone on the learnprogramming subreddit told me something about the reason C++... |
Recent research work has shown that transductive learning/inference outperforms standard methods that were used before, where people embed features in a high dimensional space and then use the distance metric in that space to classify objects. This has been found in few-shot learning, other metric learning works, etc. ... |
I want to relate Turing completeness to the Halting Problem.
As far as I know we say something is turing complete (eg: a programming language) when it can compute any function and can do any task. But since Halting Problem can't be solved by any programming language so every programming language should be Turing Incomp... |
According to the book " Operating Systems Concepts " , 9th edition, page 637, we have the following statement :
Rather than associating the columns of the access matrix with the
objects as access lists, we can associate each row with its domain. A
capability list for a domain is a list of objects together with the
ope... |
I believe its true but struggle to prove.
I know NP=union over positive c's of RP(2^-(n^c))
and from here to prove that RP(1/2^n) contained in NP is immediate.
the other side is the problem.
I've tried the following:
Given L in NP and a polynomial verifier V for L with polynomial P, to use a random Turing machine M.
M,... |
I have a confusion related the Lemma 22.1 in Cormen Leiserson Rivest Stein's Introduction to Algorithm book,
Here it is written that delta(s,v) <= delta(s,u) +1 ,where s,u,v are the vertices of a graph G
My question is why <= is used ? Won't that be = only ? I am learning Algorithms and Data Structures.
|
I asked ChatGPT to give me the difference between unrecognizable and undecidable languages, and this what it gave me:
Unrecognizable languages can be accepted by a Turing machine, but the machine may not always halt on inputs outside the language.
Undecidable languages cannot be decided by a Turing machine for all pos... |
In the book Transactional information systems: theory, algorithms, and the practice of concurrency control and recovery there is a theorem stating that Gen(2PL) ⊂ OCSR. Can some one help to guide on how to prove this
i.e; Prove that the histories produced by the basic two-phase locking protocol are Order Perserving Con... |
I understand depth first search on a graph, but I'm having difficulty understanding what it means to do depth first search on only certain edges. If given an undirected graph, with 2 types of edges, ordinary edges, and required edges, then apparently according to the resource below it's possible to do depth first sear... |
I just finished watching both parts of Herb Sutter's 2012 C++ and Beyond talk about atomics. In it he mentions that they initially shipped with a bug where the atomic reference count type only guarded the delete behavior with release semantics when actually it needs to be acq_rel, but to me it seems like actually only ... |
from the book, Speech and Language Processing (3rd ed. draft)
I understand conditioning on <s> will give context about the first word.
From the formula above, aren't we computing
P(i want english food </s> | <s>), instead of P(<s> i want english food </s>)? Do we imply p(<s>) = 1?
The n-gram wiki implies same thing to... |
Let us look at the following 2 cases:
We say a binary search implementation in a sorted array of size n has a time complexity of $O(\log n)$. In detail, $O(\log_{2} n)$ because binary search halves the input space with each iteration.
In a recursive code block as below, We say that the time complexity is $O(3^n)$ as ... |
I came across this question presented in a past exam. I can see why the language is not context free (you can't know what the first w is, hence you are not able to duplicate it, I hope it makes sense), but i would like a more formal way to explain it.
I don't really know where to start, if anyone could give me some adv... |
Why is the Program counter(PC) 12 bits and not 24 bits in IAS computer system? PC is said to have next - instruction pair and an instruction has 12 bit adress and 20 bit opcode, so if it's a pair it should store 24 bits , right ?
|
In his book "Foundations of Computing", professor Allison shows an example of "language of equal numbers of as, bs, and cs, but in any order", formally: $L = \{ w \in \{a,b,c\}^*\ |\ |w|_a=|w|_b=|w|_c \}$, where $|w|_a$ denotes the number of $a$s in a word $w$. This language is a variant of the language $L_1 = \{ a^nb^... |
I am working on an LRA Theory solver for SymPy, an open source python library for symbolic computations. You can find my work here. Currently I'm trying to optimize it to run faster.
My implementation is based off of Bruno Dutertre's and Leonardo de Moura's paper "A Fast Linear-Arithmetic Solver for DPLL(T)". My questi... |
I need to implement simple search on Python package names and I'm struggling with ranking the results. Considered Levenshtein distance, but it would give too low ranking for matches which contain the search term exactly but have a long extra prefix or suffix.
I was thinking of applying Levenshtein to each substring of ... |
I would like to know if there are any computational complexity classes where multiple provers interact with a verifier, but the provers work against each other.
For example, suppose it is a decision problem $A$. The verifier has to check if $x \in A$. There are two provers, $P_0, P_1$. $P_0$ tries to convince the verif... |
I have found two definitions of delta reduction:
Barry Watson defines it as the result of applying a primitive computation to terms in normal forms
But in Coq they define it as the substitution of a variable in a local context for its definition.
Although I wouldn't be entirely surprised if one turns out to be a spec... |
I am looking for an implementation for any of the methods to enumerate all vertices of a convex polyhedron defined by $Ax \leq b$
I have found some papers that talk about the problem, for example this one seems like a good lead. However, it is described at a very abstract level, to facilitate proving correctness, ease ... |
I am trying to find an easy to follow resource on implementing any (reasonable) algorithm to find a V-represnetation of a polytope from its h-representation. I only need this to work for $\mathbb{R}^3$
I implemented one which is very silly. Compute all possible intersections of 3 planes among all the half spaces. Then... |
Assume I have $n$ random variables $x$ which need to obey a set of inequality constraints that are linear and can be written as $Ax \leq 0$. Is there a method to sample effectively from these for large $n$, say $n > 10^3$? The first few that are sampled are e.g. from a uniform or exponential distribution, but those con... |
Can you please help identify if the two following variants of the bounded halting problem are in different deterministic complexity classes?
$$
H1 = \{ (\langle M \rangle, w, t) \mid \text{$M$ accepts $w$ in time at most $t$} \}
$$
$$
H2 = \{ (\langle M \rangle, t) \mid \forall \text{$w$, $M$ accepts $w$ in time at mos... |
Maybe this is an odd question. It has always bugged me that computability problems are written in all caps, and in such an "awkward" way. SAT, 3-SAT, COLORING, 3-COLORING, PARTITION, CLIQUE, VERTEX COVER. Etc. They're not proper titles, just single words which don't mean much on their own.
Is there any reason for this ... |
I have been trying to understand how the language $L = \{a^m b^n c^p d^q \mid m*n=p+q\}$) is context-sensitive?
I first encountered this question here.
Would be grateful if you could provide some intuition for identifying class of such language.
Thank you!
|
How to get an estimation of an O(n) function to modern multi-core CPU time? For instance, how can I find the time it takes to run an algorithm in a 4-core/8-core CPU when I know its O(n) ? I searched on google I find nothing about my question...
|
Is the language $L=\{1^n2^n3^m : n\neq m\}$ context free?
I checked and it satisfies the pumping lemma (Right?). Does it also satisfy Ogden's lemma, or any other test for being non-context free?
|
Consider the problem of finding the shortest-path distances from an origin vertex to all other vertices in a digraph. Normally in Dijkstra's algorithm, we visit the vertex whose shortest distance from the origin found so far is least, and that distance is set permanently as the shortest-path distance to that vertex. In... |
How are you intuitively able to tell the Big-Oh of the functions and what order they are on?
$$f(n)=3^n$$
$$g(n)=5^{3log_3{n}}$$
Note this is $5$ raised to $3log_3n$
$$h(n)=1024^{log_2n}$$
|
I am studying Structural Semantics for programming languages and I have come to this proof that I can not achieve.
Whith these rules plus Splitting and No interference, I am trying to get a proof.
I tried:
s0 in State
<S1,s> =>* s0
Stm0 in Stm
<Stm0, s0> =>* <S2,s'>
And somehow put S2 inside Stm0, but it does not ma... |
I was able to use Heap's algorithm for generating permutations and I was able to solve the duplicates problem by looking at all the results and filtering out duplicates myself using a HashSet in Java.
But I was wondering if there is a way to change the code for Heap's algorithm which handles duplicates while generating... |
probably a couple decades too late to ask this question, but does anyone know anything/have detailed documentation about the hardware/design underlying the ALU unit in the early MIPS R2000 CPU?
Ideally I am looking for a circuit diagram like the following:
I don't need/am already familiar with the information from spe... |
From what I know, the classic way of constructing a KD-tree is with alternating dimensions and finding median at each level. In my dataset, I have a lot of duplicated points, and I want to incorporate the duplicates' filtering inside the creating of the KD-tree. However, I am not sure how to proceed.
Obvious option: j... |
There is an obvious construction of linear codes from graphs, where each codeword is a cycle in the graph. Physical bits are edges in the graph, and constraints are vertices.
This has been used in the construction of good LDPC codes with expander graphs by Sipser and Spielman [1], but their construction uses Tanner cod... |
I have two JFrame windows equipped with various components including JButtons and I want the actionPerformed methods for the buttons to send data between the two windows so that one can update the other. Thankfully, I've already got all the button code and everything figured out. The problem is when I try to send a sig... |
You're given a m by n matrix filled with positive integers, as well as some integer k (0 <= k <= min(m, n)). After deleting exactly k rows and k columns (deleting can be thought of as replacing a row/column with all zeros), what's the maximum sum of remaining cells in the matrix you can achieve?
I recently thought of t... |
We have a graph $G$ with $v$ vertices. In $G$ there is at least a maximum clique with $k$ vertices, with $k\lt v$. Is it true that there is at least a vertex of $G$ such that its degree is less than $k-1$?
|
I need assistance in defining axioms for partial functions in total function theory that is available in Coq.
Specifically, I'm looking for a constructive definition of a partial function that includes a constructor for obtaining a partial function from a smaller finite domain.
My use case involves formalizing the prob... |
I have a Python data generator capable of generating SQL-like relational data with primary and foreign key relationships, composite keys, and partial keys. Currently, I store this data in-memory using a plain dictionary (key-value) structure, where I sort headers every time I need to retrieve data to maintain alphabeti... |
I'm working on implementing a solver for Double-Choco puzzle which published by Nikoli magazine. starting by representing the board cells as matrix containing cells with values 1 or 0, where 1 represents gray cells and 0 represents white cells.
For instance:
[
[0, 0, 0, 0, 1],
[1, 1, 1, 0, 1],
[1, 0, 1, 0, 1],
[0, ... |
In general, the problem of finding a Hamiltonian cycle is NP-complete (Karp 1972; Garey and Johnson 1983, p. 199).
Next, as for determining the existence of long cycles, I don't hold much hope for efficient algorithms. However, what about short cycles? For instance, 3-cycles, 4-cycles, and so on. For a $k$-cycle, at wh... |
In order to group unstructured or sem-structured texts for a timeline construction approach, I consider several types of correlations among such texts. These different correlations induce a weighted multigraph, where the texts act as nodes. All edges have a normalized weight between $0$ and $1$.
I wonder what algorithm... |
Consider a set $S$ of segments in the plane. Split each segment in $S$ into a few pieces, and slightly modify the extremities of each obtained segment (by adding a small random value to their coordinates, e.g.). Then consider the set of all obtained segments and add to this set a number of random segments. This gives a... |
I am trying to solve this proof.
In structural semantics I need to proof that:
If <S1;S2,s> =>* <S2,s'>, then it is not necessarily needed that
<S1,s> =>* s'
I tried many things but I am not able to "break" the No Interference Lemma thay says:
<S1;S2,s> =>k s' means that
Exists an state s0 such that
<S1,s> =>k1 s0 ... |
While trying to get an overview of parameters used in the parameterized-complexity theory, it seems that there are no problems parameterized by some basic graph properties like maximum clique, maximum independent set, and maximum degree. Among other resources, I've used this resource https://www.graphclasses.org/classe... |
I have been studying the assosciative mapping in a cache.Every line in a cache has a unique address which is made of:the index and the offset bits which give the the cache set and the cache line and the tag bits.But which algorithm really decides where to put information from RAM into the cache?
|
I have a conundrum to solve but am not knowledgeable enough about cryptography to know whether it's possible to do, and if so, what method to use.
I am a Provider and my task is to prove to some outside Verifier the existence of a Connection to some device, beyond some reasonable probability $\epsilon$. The Verifier an... |
I'm currently developing a custom UI layout library. At the moment a user of that library should supply strings for UI labels in a format that allow for subsequent shortening of those labels, so that they fit into the available space, without omission or indiscriminate ellipsis. Such a label list might look like this (... |
i have this question where im given a an array that contains the distance of a traveler from a certain destination at the i-th time of the day. ideally the array should be in descending order but the array could contain mistakes where the traveler gets further from the destenation and i should find at which index does ... |
Consider the following step where 'abaab', upon failed mismatch, 'ab' the prefix is followed by aligning at 'ab' the suffix. What confuses me is the reason for being able to discard the possibility of a case where 'ab' may be inbetween the two also that might lead to a correct match. So why is it theoretically impossib... |
My understanding is that recursive definitions are considered second-order since they require the fixpoint operator in order to be formulated as "true" definitions. This is even though they contain no higher order quantifiers eg.
times(x,s(y)) = plus(x,times(x,y))
times(x,0) = 0
needs to be written as times = \mu x. F... |
I'm trying to implement a very crude form of the css grid layout. It's layout algorithm is as documented.
“sparse” packing (default behavior)
Set the column-start line of its placement to the earliest (smallest positive index) line index that ensures this item’s grid area will not overlap any occupied grid cells and t... |
I am struggling to write my own recursive function.I understand how to find the base case but I cant find easily the pattern on the relationship between 2 complicated cases.Do you know any website where I can practice that?
|
Wikipedia and other sources define "asymptotically equivalent" as: two functions $f$ and $g$ are asymptotically equivalent if:
$$
\lim\limits_{x \to\infty}\frac{f(x)}{g(x)}=1
$$
But we regard $n^2$ and $2n^2$ as asymptotically equivalent, and these always have a ratio of 2 between them. Is there a different definition... |
As input we are given a graph $G$ and an integer $k$ and are asked to find a dominating set of size exactly $k$ in $G$. This problem is clearly NP-hard, but does it become polynomial time solvable if we assume $G$ has bounded treewidth? For bounded treewidth graphs you can find a dominating set of size at most $k$ by d... |
I am working on an floorplan application where I save elements on an infinite grid in a sparse manner. Specifically, I have the following Python class representing a sparse grid (basically a dictionary mapping coordinates to elements):
from collections.abc import MutableMapping
class SparseGrid(MutableMapping):
"... |
The circumference of a graph is the length of any longest cycle in the graph. The problem of determining circumference of a graph should be NP-complete. However, for graphs of moderate size, is there also a clever brute-force approach?
I referred to the link, where someone mentioned that the Johnson's algorithm is th... |
I was thinking about the language $a^nb^nc^n$, which is obviously not context free, but if we run it through 2 automata at the same time (the first for $a$ and $b$ and the second for $b$ and $c$ and they both accept, the construction would basically accept the language)
|
I was playing a puzzle game and started wondering how they implemented their undo feature. The game only has five possible moves, and only when the player does a move does the game state change, but the game state can be quite complicated.
The standard undo implementation would be to keep track of a stack of all past g... |
Is there any programming language, by which I can write a code that during run time automatically generates so many other codes and furthermore those codes will be run in parallel?
|
Let HALT be a program that can decide the halting problem for any program and its input. HALT has two inputs, the program and the program's input.
Let OPPOSITE be a program that accepts a program as input, calls HALT with its input as both of HALT's inputs, and then does the opposite of whatever HALT has concluded.
If... |
I can easily convert NFA with multiple start states to NFA with single start state with epsilon transition.
But I want to know how can I do so without epsilon transition
Here's my idea
Suppose s1 and s2 are the start states. Let s0 be the new start state.
If s1 or s2 are final states, make s0 final state.
Duplicate al... |
The following is small-scale example is meant to illustrate the general distribution problem
Consider 4 parks, each with exactly 1 pond. Parks are marked as vertices in the following undirected graph:
Each park has a number of ducks in them, and each pond has a maximum capacity of ducks (the parks themselves do not ha... |
I'm currently studying structural properties of network and control protocols and their relation to testing. I'm specifically interested in state machines. They would not need to cover the full behavior to be useful. For many protocols, prototypical state machines can be found online when specifically searching for the... |
I've read Downfall paper. In the university, I've had an introductory course on computer organization and operating systems. We also studied Spectre and Meltdown attacks there. I understood the interplay of speculative execution and side channels in the case of those attacks.
I understand the general similarity between... |
I am working on building exact algorithms for NP-hard problems. Let's consider an NP-hard problem $P$. The brute force approach runs in $2^n$ time. In order to prove that there is no $2^{o(n)}$ time algorithm for $P$, we provide a reduction from the 3-SAT problem (Assuming ETH holds). I want to prove that no exact alg... |
We are looking for a code to list all maximal bicliques in bipartite graphs efficiently, as we want to run it on (large and sparse) graphs, with up to roughly a million nodes and edges in no more that a few hours.
In the literature, we know this fast implementation which implements the algorithm presented in "Efficient... |
I'm reading Java Concurrency in Practice, and I came across the following sentence (section 2.3.1 Intrinsic locks, pg. 25):
Every Java object can implicitly act as a lock for purposes of synchronization; these built-in locks are called intrinsic locks or monitor locks.
Intrinsic locks in Java act as mutexes (or mutual... |
If I start with a directed graph that is strongly connected, is there a straightforward way / algorithm to find the smallest set of edges to remove, such that the result is a directed but acyclic graph?
To be clear, the result is neither necessarily a tree (could have more than one way from A to B), nor is the graph st... |
Let $G = (V, E)$ be an undirected graph such that every $v\in V$ has $\deg(v) \geq 3$. We must create an algorithm that outputs a cycle of length O(log(n)) if it exists. This algorithm must return in linear time. If such a cycle exists return True, if it doesn't return False.
I had a couple ideas of where to start, but... |
Suppose we have a bipartite graph with $N$ vertices on either side.
In the full bipartite graph, the number of edges is $N^2$ and the number of possible matchings (i.e. assignments) is $N!$.
Now suppose a few known edges ($O(1)$ edges) are missing from the full bipartite graph.
How can we find the number of matchings?
... |
Is there an oracle $A$ with $P^A = NP^A$, but $EXP^A \not= NEXP^A$ ?
I found a proof with padding arguments (wikipedia), that
$$ P = NP \Rightarrow EXP = NEXP $$
If an oracle $A$ exists with $P=NP$ and $EXP\not=NEXP$ relative to $A$
then the padding technique would be a proof methode, that circumvents the
Relativizati... |
I'm reading a text book on CPU architecture and I have something that confuses me: The text book defines 4 different instruction execution models in CPUs, Stack (where a CPU only has a stack and is able to perform operations on the first and second elements of the stack and push the result back), Accumulator (the CPU l... |
I looked through Java's Random class and saw that the initial seed is created using:
public Random() {
this(seedUniquifier() ^ System.nanoTime());
}
But every consecutive seed is derived from old seed using:nextseed = (oldseed * multiplier + addend) & mask;
Why is that? Why not use system time everytime?
|
I am reading "An Introduction to the Analysis of Algorithms" by Robert Sedgewick and Kevin Wayne. In this book, Exercise 1.4 asks to develop a recurrence for $C_{N+1} - C_{N}$ and use it to prove that
$$C_N = \sum_{1\leq k < N}{(\lfloor\lg{k}\rfloor + 2)}$$
where $C_{N}$ is the number of compares of mergesort.
Any idea... |
The following code is from GeeksForGeeks
void deleteN(Node** head, int position)
{
Node* temp;
Node* prev;
temp = *head;
prev = *head;
for (int i = 0; i < position; i++) {
if (i == 0 && position == 1) {
*head = (*head)->next;
free(temp);
}
else {
... |
Let $V$ be a set of vectors over $\mathbb{R}^l$, $l\ge 1$, $\pi_i(V)$ be the permutation of vectors in $V$ such that they are ordered by their $i$th component (descending) in order for $\pi_i(V)(\mathbf{v})$ to be the rank of $\textbf{v}$ by component $I$: then define
$$
\operatorname{top}(V, k) := \sum_{i=0}^l \sum_{\... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.