New York has more coronavirus cases than the whole country of Germany — and more than twice as many deaths. In January, Germany developed its own reliable test for COVIDー19 and began mass testing. In February, Trump was demanding New York drop its investigations into him.
Tag: Question
Why does this BFS solution work for this question about euclidean distance and what’s its complexity?
Given a matrix of 1s and 0s where 0 represents houses and 1 represents stores, find the square of minimum Euclidean distance of every house to nearest store. Return it as a vector of vector.
[[1, 1, 0], [0, 0, 0], [0, 0, 0]]
should return
[[0, 0, 1], [1, 1, 2], [4, 4, 5]]
Basic BFS: ( approach1)
If there are N elements in the matrix, one could do BFS starting every house to solve this. The worst case complexity of this approach is: Worst number of BFSes * O(E+V), where E is the number of edges in the matrix and V number of nodes = N * O(N + 4N) as number of edges is a constant factor of 4N. Time complexity: O(N*N)
multisource BFS (approach2)

Initialize the queue with all nodes (i, j) where i is the row number and j is the column for all stores. For each node (i, j) in the queue also store its corresponding (si, sj) node for the store that gives it the minimum square of euclidean distance (call it sqDist). For each store node (i, j), (si, sj) would be same as (i, j)

Initialize the distance answer that we are looking for each house with 1

During multisource BFS, for a node (i, j) and it’s best store (si, sj) in the queue, look at each of 8 adjacent nodes (since it’s euclidean distance, we need to consider all 8 nodes not only 4 of left, right, top, down). If the current distance value for any of those nodes (nexti, nextj) is > the sqDist if (si, sj) is chosen as the best store for (nexti, nextj), then
 update distance of (nexti, nextj) with the lower value
 add (nexti,nextj) along with its best store as (si, sj) to the queue

Keep doing this until queue is empty
My question:
1) why does this work? Since we’re looking at euclidean distance it’s possible that (nexti, nextj) may not be added to the queue (or have their distance updated) for a certain (si, sj) but that (si, sj) node may still update the distance for nodes that are farther to it than (nexti, nextj) due to nature of euclidean distance. So (si, sj) may still need to be in the queue. How does this solution work inspite of this issue or what’s the intuitive conceptual idea of why this works despite this issue as it’s not obvious?
2) What’s the time complexity?
it seems in the worst case you could add a node in the queue N times. So it becomes N * O(N *4N) where 4N is the number of edges in the matrix. So is it not any better than doing BFS individually for each house?
[ Politics ] Open Question : Should the rest of the world go by Sweden’s example of “do nothing” about the Coronavirus?
Lockdown, what lockdown? Sweden’s unusual response to coronavirus https://www.bbc.com/news/worldeurope52076293
[ Politics ] Open Question : Do you think America’s coronavirus cases is weeks or months away from its peak?
With the lack of medical equipment/ventilators and testing kits. Many more people still needs testing. Only 12 days ago the U.S is at 3,400 cases
Can someone in Cyber Security or IT help answer this basic question on the change of today’s malware? [closed]
1.) Before the most common types of malware were usually trojan horses and various other types of viruses derived from one’s own email on a desktop. Given the timespan since those days, the game has changed. Today ways of breaching a user’s data have changed drastically. What are the most prevalent methods that an average person should be aware of today?
A question regarding the stacking of temporary HP
Right now I am playing a Mystic (UA), and I have chosen the Order of the Immortal as my discipline. One of the abilities I have acquired gives me 5 temporary hit points at the start of my turn, as my intelligence is a 20.
If I have gained temporary HP in one turn and I haven’t been hit, do I continue gaining the HP or do I have to expend the Temporary HP before gaining more?
Question about unity paint game
I want to make a paint game using unity 2D, such like “mix & paint” mobile game. Basically player needs to brush colours into shape, then the game will complete when it is fullycoloured.
I’ve tried to achieve it using particle system for the brush & sprite mask for the shape that works quite well. Then for checking it is fullycoloured i am using sampling method, it is also works but i does not feel comfortable with it.
So my question is: what is the best way to achieve this? or how will you guys approach this problem? Also, any idea or material is appreciated as answer! thanks
[ Gender Studies ] Open Question : Is it Tara Reade’s fault that Joe Biden raped her?
She says she was wearing a short skirt and no stockings. She also said Biden said to her that he thought she liked him which means she was sending him the mixed messages. If she didn’t want to get raped, she should have dressed appropriately and covered up.
[ Politics ] Open Question : Is the death rate from Coronavirus overestimated?
https://www.wsj.com/articles/isthecoronavirusasdeadlyastheysay11585088464 We actually KNOW that these death rates of 13% are overestimated due to the fact that we know that not everyone or even close to everyone with the disease has been tested. The REAL question is how much. This virus MAY be less deadly than the flu or 10 times more deadly.
Time Complexity of this Question
Complexity of primeNumber function. int sqrt(int N) { int d; for(d=0; d*d<=N; d++) { }
return d1; } bool primeNumber(int n) { bool isPrime = true; int lmt = (sqrt(n)); for (int d=2; d <=lmt ;++d) { if (n%d==0) return false; } return true; } What is time complexity of this question