consulta con case fecha menor que o mayor que

tengo el siguiente query

``select Gage_ID,Description,Gage_Type,Location,Last_Calibration_Date,Next_Calibration_Date,Calibration_Frequency, case  WHEN Next_Calibration_Date > GETDATE() THEN 'Requiere Calibracion'       WHEN Next_Calibration_Date <= GETDATE() THEN 'Calibracion ok'        END, GETDATE() as fecha  from quality_v_gage where Gage_Status <> 'Obsoleto/Perdido'``

donde estoy haciendo un casi donde si la fecha es mayor a la fecha en la que estamos me indique que requiere calibración y si es menor la calibración ok pero no me esta respetando el caso.

es decir en las fechas de comparación me salen calibración ok cuando la fecha actual es mayor que la fecha de Next_Calibration_Date

ejemplo Next_Calibration_Date = 12/31/2018 1:00:00 AM

Karp-Rabin – what is the input for the worst case time complexity?

I’m trying to determine the input for the worst case time complexity of Karb-Rabin regardless of the used hash function. However, I’m seeing both of these answers on the internet:

• String “AAAAAAAA” and pattern “AAA”
• String “AAAAAAAB” and pattern “AAB”

Which of these inputs would have the worst running time in Karp-Rabin? Thanks!

Karp-Rabin – what is the input for the worst case time complexity?

I’m trying to determine the input for the worst case time complexity of Karb-Rabin regardless of the used hash function. However, I’m seeing both of these answers on the Internet:

• String “AAAAAAAA” and pattern “AAA”

• String “AAAAAAAB” and pattern “AAB”

Which of these inputs would have the worst running time in Karp-Rabin? Or are they both providing the worst case running time? Thanks!

Usar case en el select con registros que contienen null en sql server

Deseo una columna estatus creada por mi y esta columna sale tomando en cuenta que tenga 3 fechas diferentes en una sola tabla es decir fecha1,fecha2 y fecha3. Como nota el sql server no soporta el if Las restricciones son -si fecha 1 es diferente de null y fecha2 y fecha3 son null estatus es escriturado -si fecha2 es diferente de null y fecha1 y fecha 3 son null el estatus es en proceso. -si fecha 3 es diferente de null y fecha1 y fecha2 son null el estatus es cancelado -si todas las fechas son null el estatus es terminado

Intente hacer un case en el select pero me marcar error cuando comparo las fechas con is null o is not null. Despues use la funcion isnull() y si corre pero solo para uno o dos restricciones y las demas no las hace o marcar warnings

Saludos

What is the real reason that Bubble Sort runs at O(n) in best case?

In this link https://techdifferences.com/difference-between-bubble-sort-and-selection-sort.html it says that the best case of bubble sort is order of n due to the fact that there would be only comparisons and no swaps in the inner loop.

But is that correct? Are comparisons not counted in the complexity ? Only swaps?

Other sources claim the reason is only because it can be optimized with a ‘ flag’ checking if it entered the inner loop. In that case there would be ZERO swaps and n comparisons. ( If this reason is correct, can’t I optimize other sorting algorithms this way? Likesay, selection sort?)

What is the correct reason? I questioned both of the reasons!

EDIT: this is what is said in the link: “In the best case, it is of order n because it just compares the elements and doesn’t swap them”

Is there any system with only one use case?

I’m building a news aggregation system that collects news articles from several websites, then classifies them into categories, tags them with keywords and saves them to a database. All actions are activated in the same sequence, begins with news scraping. Everything is put in a loop that runs every 5 minutes.

My question is that if my system has only one use-case, with an actor is the Timer/Scheduler?

Bubble Sort with “while” loop – why is average case n^2?

If Bubble Sort is written as:

``    while True:         False         for i in (0 to n):             if list[i] > list[i + 1]:                 swap.(list[i], list[i + 1])                 True     return list ``

Seems to me that in the worst case (a list in descending order):

• the `while` loop runs $$n$$ times
• the `for` loop runs $$n – 1$$ times per `while` loop $$∴$$ there will be $$n^2 – n$$ `comparisons`
• the list is reversed so there will ultimately be $$(n^2 – n)/2$$ `swaps`
• $$∴$$ worst case is $$O(n^2)$$

In the best case (a list already sorted):

• the `while` loop runs $$1$$ time
• there will be $$n – 1$$ `comparisons`
• the list is already sorted so there will ultimately be $$0$$ `swaps`
• $$∴$$ best case is $$\Omega(n)$$

So for the average case…

• the `while` loop will run more than $$1$$ time but less than $$n$$ times
• there will be more than $$n – 1$$ but less than $$n^2 – n$$ `comparisons`
• there will be more than $$0$$ but less than $$(n^2 – n)/2$$ `swaps`, depending on the state of the list

• $$∴$$ how can we show that the average case is also $$n^2$$ and $$\Theta(n^2)$$?

I don’t understand where $$n^2$$ can be observed?

Is it because the number of `swaps` will always be equal to $$(n^2 – n)/x$$, where $$x$$ is determined by the state of the list?

And, as stated here (and in other places), on average, with uniform distribution, the number of swaps would be $$(n^2 – n)/4$$, which is half the worst case?

I’m confused `:(` Any help would be appreciated! Thank you.

Tarjan’s Algorithm failure case, what am I missing?

I’m having a little trouble with Tarjan’s Algorthm.

So here’s my problem: I have a graph such that these nodes are directionally-connected as shown:

``A: B C D E B: D E C: B D E F D: C E E: B F: A B D E ``

My problem is Tarjan’s Algorithm never revisits nodes, apparently. If the node isn’t on the stack, it’s not checked.

So here’s what’s happening:

My algorithm is going A, D, E, B. B checks D.

``A(id=0, link=0), D=1, E=2, B=3 -> D is visited, D is on stack, D's id is 1, B(id=3, link=1) ``

Cute. B checks against E (cycle—it’s a tie), which has an ID of 2, and is on the stack, no change.

B is out of neighbors, doesn’t have a neighbor, returns out of the recursion so E can continue.

E, upon return from DFS of B, checks B’s low-link value. It’s lower, so E’s low-link value becomes 1.

``A(id=0, link=0) B(id=3, link=1) C(undefined) D(id=1, link=1) E(id=2, link=1) F(undefined)     ``

Now here’s the fun part.

D proceeds to check C. C checks F. F checks A, which has been visited and is on the stack. A has an ID of 0, so D updates.

``F(id=5, link=0) C(id=4, link=0) B(id=3, link=1) E(id=2, link=1) D(id=1, link=0) A(id=0, link=0) ``

A proceeds to check the rest of its neighbors. B and D have higher link values and IDs and are on the stack, so A doesn’t update.

Every node has been visited.

There’s a path from D to E to B to D, meaning those are part of the same SCC (in fact, all of these are in the same SCC—it’s one SCC).

The stack is {A, D, E, B, C, F} with F at the top.

The two SCCs are {B,E} and {A,C,D,F}.

…you can reach A from B, and you can reach B from A.

What am I missing here?

Set the if condition to true iin PHPUnit test case

I have a if condition inside an observer as follows

``public function execute(Observer \$  observer)     {         if (\$  observer->getData('status') == Status::REQUIRED) {             //implementation          }     } ``

Now I want to write PHPUnit test for above.

How can I do so? basically I want to know how can I bypass the if condition or set it to true in my unit test.

Quick sort wort case complexity improvement

Can the worst case time complexity of quick sort be changed from `O(n^2)` to `O(nlogn)` by modifying it?