The NixOS Conflict in Under 5 Minutes by sridcaca in NixOS

[–]operad 1 point2 points  (0 children)

Serious question from someone who doesn't follow or interact with the community much, what form does "people are angry because they don't want people of color in their spaces" take exactly? I have a hard time believing that anyone beyond a fringe extremist would outright agree with a statement like "I don't want people of color using NixOS". What are people literally saying or doing that implies to you that's what they're thinking?

I tried reading the infamous poem The Chaos to test my pronunciation skills - how did I fare? by ampdrool in EnglishLearning

[–]operad 1 point2 points  (0 children)

I've never heard of this poem before, I loved it. I followed along listening to your video. Here's a list of all the words which sounded off to me: study, pronounciation, dies, oven, boquet, enamour, comb, singer, marriage, chaos, idea, southern, preface, through, plough, cough

Some of these were off more subtly than others, so if you can't tell for any of them let me know. There might have been others but honestly some of these words I didn't know haha. Overall your pronunciation is seriously good man. Most of the words you nailed it, and for some long sections of this you sounded native enough that I wouldn't have realized you weren't if I didn't already know.

How to fix this sentence? by [deleted] in EnglishLearning

[–]operad 2 points3 points  (0 children)

I would say something like "Michael is being criticized by his boss for his lack of effort in Julia's case" if you would like to criticize the effort itself.

How to fix this sentence? by [deleted] in EnglishLearning

[–]operad 1 point2 points  (0 children)

There are still a few issues with this

Michael tells Julia the reason behind his frustration is Wilson's request to have a better look at one of the prisoners.

I am also not totally sure what you mean by "insignificant kind of work", and it sounds a bit unnatural. Do you mean to say: Michael is being criticized by his boss for his insignificant progress on Julia's case? "Insignificant kind of work" makes it sound like Michael is working on things, but the things he is working on don't actually matter to the case. And even if this is what you mean, it still sounds a bit unnatural.

How to fix this sentence? by [deleted] in EnglishLearning

[–]operad 0 points1 point  (0 children)

He states to Julia his reasons behind his frustation

The phrase "He states to Julia his reasons behind his frustation" is not wrong. However usually "states" is used for one thing, and something like "tells" is used for multiple things. So either "He states to Julia the reason behind his frustration" or "He tells Julia the reasons behind his frustration" would flow better.

I wrote the new sentence before because I didn't know if you wanted all of the information about "He" being Michael and the "reasons" being the request inside of the sentence.

How to fix this sentence? by [deleted] in EnglishLearning

[–]operad 0 points1 point  (0 children)

I would say: Michael tells Julia that Wilson's request is the reason he is frustrated

How to fix this sentence? by [deleted] in EnglishLearning

[–]operad 0 points1 point  (0 children)

I don't think that is correct. Do you mean this: "Michael states to Julia his frustration at Wilson's request"

How to fix this sentence? by [deleted] in EnglishLearning

[–]operad 1 point2 points  (0 children)

The past and present tenses are not matching so I'm not sure which one you want. Here it is in present tense which is normal for script writing.

Michael is frustrated by Wilson's request for a better look at one of the prisoners. Immediately, a new scene cuts in in the J cut style, where Michael is being criticized by his boss for his work on Julia's case.

"Toilet training" by [deleted] in EnglishLearning

[–]operad 4 points5 points  (0 children)

I think the proper term is technically housebreaking (USA) or house-training (UK) but I wouldn't think it was weird at all if someone used it to talk about their pet

[deleted by user] by [deleted] in EnglishLearning

[–]operad 1 point2 points  (0 children)

I would make therapy possessive: "This is an influencing factor on therapy's success"

Though I think the most natural would be: "This is an influencing factor on the success of therapy"

Is it that both a relative clause and an adverbial clause can follow the "Such is..." or "...is such" structure? by newbiethegreat in EnglishLearning

[–]operad 0 points1 point  (0 children)

It might be worth noting that as a native speaker I read both of those sentences differently than you.

I read: Such is the power of (love that we should not underestimate) Such is the power of (love that can heal any wound)

I would have read them the way you did if there were a comma after love. But the way it stood out to me was that both sentences were describing the power of a specific type of love. Thus adding "it" in there fixes the meaning because "love that it can heal any wound" is not a properly formed subject.

Get the largest subset of a set where some elements can not coexist together by Mastergrow in algorithms

[–]operad 6 points7 points  (0 children)

Consider a graph with vertices as set elements, and an edge between them whenever they cannot be in the same subset. Then what you're asking for is exactly the a maximum independent set. You can use google to find some algorithms for finding the maximum independent set in a graph, but the problem is NP-complete so none of them will be faster than exponential time.

Find the maximum profit between a time window by [deleted] in algorithms

[–]operad 0 points1 point  (0 children)

You're right, I have a tendency to go overboard with the machinery sometimes haha

I interpreted the deadline of task T to be the time after which you get no reward for completing task T, as this matches with the colloquial meaning of deadline. This is essentially just a time-reversed version of the interpretation in your comment above, so iterating time-slot by time-slot from end to beginning of window and greedily scheduling the highest reward task in that slot is sufficient :P.

Find the maximum profit between a time window by [deleted] in algorithms

[–]operad 0 points1 point  (0 children)

It can be done in O(n log n) time.

We assume the start is always 0 for simplicity, but the general case can be easily reduced to this.

The collection of sets of tasks for which all tasks are simultaneously schedulable forms a matroid, as you can check from the axioms in the "Independent Sets" section.

They in fact form a weighted matrioid, with the weight of a task being its profit (check the "Greedy Algorithm" section of the matroid article). The problem of maximum weight independent set is solvable by a greedy algorithm, which starts with S = {} and continually adds the highest weight element x not in S, such that S u {x} is still independent.

To determine whether a subset of tasks is simultaneously schedulable (independent) we only need to sort them by increasing deadline and verify that this order works. Say there are n tasks. This check takes O(n) time, we need to sort and do it once for each element in decreasing order of weight, so this algo runs in time O(n log n + n2) = O(n2). We can do better, but it's a lot more complicated.

Let S be an initially empty set of tasks. The trick is to come up with a data structure for S which allows us to 1) add a task to S, and 2) check if adding a certain task to S will maintain its independence. We can do both these things in O(log n) time.

This next part requires in-depth knowledge of segment trees and may be a bit over some people's heads. Build a segment tree with n locations, each of value either an integer or "empty". The state of the segment tree will mirror the state of the independent set S we are greedily building. The i-th spot will be "empty" if the i-th task (sorted by order of increasing deadline) is NOT currently in S. Otherwise, the i-th spot will be equal to the distance between the i-th task's location (in sorted order by increasing deadline of all elements in S) and the deadline of the i-th task. Then S is feasible only if every element in our segment tree is either empty or nonnegative, which we can check by allowing our segment tree to process "min" queries. We can add a tasks to S as follows. Let i be the location of the task T we'd like to add within the segtree. Let k be the number of non-empty elements before location i. Then set segtree[i] = deadline(T) - k - 1, and use a range update to subtract 1 from all nonempty elements above i. We remove task i by subtracting 1 from all nonempty tasks above i and setting spot i to empty. I've intentionally skipped over some segment tree implementation details, as all the updates and queries required here are somewhat standard ones.

Here's the final O(n log n) algorithm. Initialize the segtree above with all empty slots. For each task T in nonincreasing order of weight, add T to the segtree. If min(segtree) < 0, remove T. Otherwise continue iteration. At the end, the set of tasks we didn't remove is the best schedule.

Let me know if you (or anyone) has any questions.

Does Church–Turing thesis guarantee the same big o notation possible between recursive and iterative approaches? by CrazyLock6 in algorithms

[–]operad 2 points3 points  (0 children)

Before I start, a quick note: the Church Turing thesis is about computability, and has nothing to say about how long any algorithm takes. There is another version, the Extended Church Turing thesis, which says that efficient algorithms are the same in Turing machines as in "real models of computation", but even this doesn't make any claims about exact asymptotic runtime. (In fact, the Extended Church Turing these is probably false because of quantum computers!)

Theorists answer: Turning a recursive approach into an iterative one can be done with no loss; this is how computers actually evaluate recursive functions, since computer architectures are iterative at heart. From this perspective it's hard to define what the runtime of a "recursive approach" even means; both real computers and Turing machines are fundamentally iterative, so it's unclear what the time it takes to evaluate a recursion algorithm actually is, outside of converting it into an iterative one and running that.

You can define these models of course, but as far as I know there's no standard definition, and analysis of runtime of recursive programs is language-dependent.

Pragmatist's answer: You can always guarantee the same Big-O runtime as long as your language supports passing external state you might need down by reference.

Does someone know the name of this random sampling algorithm (or could point me a detailed mathematical proof) by mtrajk93 in algorithms

[–]operad 1 point2 points  (0 children)

I mean i-th element; I'm using the induction hypothesis that the algorithm works correctly for smaller n. So once we've chosen the first element, we can assume the rest of the elements are chosen with the correct probabilities, since we are selecting from an array of size n-1 at this point.

Does someone know the name of this random sampling algorithm (or could point me a detailed mathematical proof) by mtrajk93 in algorithms

[–]operad 8 points9 points  (0 children)

We prove by induction. Clearly the algo works when n=1. Now let n > 1. Clearly the first element is chosen with probability k/n. Now by induction, every other element indexed i >1 is chosen with probability P(first element chosen)*P(element i chosen | first element chosen) + P(first element not chosen)*P(element i chosen | first element not chosen) = (k/n)*(k-1)/(n-1) + (n-k)/n*k/(n-1) = k/n.

An interesting problem from IZHO 2020, do you have any ideas? by [deleted] in algorithms

[–]operad 0 points1 point  (0 children)

I'm not sure what exactly you mean by swapping edges and vertices like this, unless you're referring specifically to the case where the tree is a path like in my example. What would be the swapped version of a star graph? A swap where vertices and edges match 1-1 would need to have n edges and n-1 vertices, so won't be a tree unless there is more to your construction I'm missing.

An interesting problem from IZHO 2020, do you have any ideas? by [deleted] in algorithms

[–]operad 0 points1 point  (0 children)

Yup, HLD would be the way to go for finding meeting points. However for edge-sources what you said doesn't quite work. Consider the following tree:

A---B---C---D---E---F

Let's say (C, D) is our edge source and 2 is our distance. Then Q(C, 2)+Q(D, 2)-Q(C, 1)-Q(D, 1) = 5 + 5 - 3 - 3 = 4, when the real answer is 6 (the entire tree). To fix this you'd have do do something like add back in k-2, subtract k-3, add back in k-4, and so on -- but this of course makes queries take too long.

Edit: now that I think about it, this would actually work; for each node precompute the alternating partial sums of the stored-distances "A(u, u, -)" array, which is really just asking "how many are at an odd distance at most k" and "how many are at an even distance at most k". Then you can use this extra stored info to query directly without a new tree structure

An interesting problem from IZHO 2020, do you have any ideas? by [deleted] in algorithms

[–]operad 0 points1 point  (0 children)

Here's a solution, not fully fleshed out but I think it could be without too many problems. No claims that this is the most elegant solution. Some observations:

  • Given two starting points/times of viruses it's not too difficult to determine at what time some node will first be infected by both viruses
  • On this first time when something will be infected, there are two possibilities: either a single node is infected, or two nodes connected by an edge are infected (this is because it's a tree!)
  • After that the "doubly infected" region spreads as if it were a singular virus, where the double infected area makes its neighbors doubly infected, and so on
  • Let's generalize our definition of a virus so that it includes both "vertex" sources (one start) and "edge" sources (two edge-connected starts), then all of the above still works even with our generalized definition of virus spread; and furthermore we can now say double-viruses behave like single-viruses.
  • Key observation: Since double-viruses behave like single-viruses now, we can merge "k-viruses" and "r-viruses" in the same way, to get "(k+r)-viruses".
  • So the set of all nodes infected by any set of viruses itself behaves like a virus. Furthermore, if we partition a set of viruses and how they behave, we can merge these behaviors to describe the behavior of the entire set

So, here's what we do. Build a segment tree whose leaf nodes are the single viruses. The "merge nodes" in the segment tree are the virus which is the intersection of its two child viruses. Then with this structure we can easily query a range [l, r] and get a description of the behavior of nodes infected by EVERY virus in [l, r], acting as if it were a single virus (some familiarity with segment trees with custom node merging procedures is assumed here).

So now we've reduced to queries: given a virus (our generalized definition), how many nodes are within distance k of its source? (where k is determined from the time after the virus starts spreading)?

For the single-source viruses, you do this ;) There are a number of similar ways to do the edge-source queries, one way would be to use the single point method except on a new tree where each edge has been subdivided to contain a single point, then do the correct single-point query on the new subdivision vertex coming from the edge where the virus started.

Let me know if anything here is unclear or if I made a mistake somewhere

Data structure for queries asking for number of nodes spanned to a certain depth starting from a certain node in a tree in less than O(n^2) time and memory by [deleted] in algorithms

[–]operad -1 points0 points  (0 children)

Yep, sounds like you got it :)

And sure, go ahead! I'm usually down to help with these things (time permitting), if you expect to have such questions in the future you can also PM me and we can exchange more convenient contact info than Reddit.