In the right-rotation case for red-black trees, there is a less efficient way to recolor it, why is it not O(log(n)) anymore?

So the first time I tried to recolor this insertion case from memory, I ended up with the right-hand side recoloring; of course the left recoloring is more efficient as the loop ends at this point. If however, we check in the right case for whether the grandparent of a is the root (color it black) and otherwise continue the loop from that node, I read that it makes the recoloring not O(log(n)) anymore, why is that? It still seems to me to be O(log(2n)) at worst, even if the number of rotations performed is not O(1) anymore. red-black recoloring alternatives

Looking for researches or case studies on How to move users from engaging / visiting social media to website

Are there any resources, articles, research documents or case studies explains how companies or apps succeed to move users from social media to their website?

On other words: create motivation and building a transitional road map from social media to website

example: Instagram account sells goods, and want to move to e-commerce website but currently exploring opportunities how to do that (fear of the idea that its business is currently based on being a social-based store)

context: I’m currently on secondary research for UX project and I want to explore this specific area in order to get some assumptions to be validated.

confusion with worst case for direct addressing

In CLRS there is an exercise for direct addressing data structure

Suppose that a dynamic set S is represented by a direct-address table T of length m. Describe a procedure that finds the maximum element of S. What is the worst-case performance of your procedure?

for this question i have seen a lot of websites indicating the worst case possibility is O(m) by starting and examining every non null slot up to end and then returning the maximum index, but i think it can be done in a faster way than that. If direct addressing tables has m slots , then obviously the highest value should be in the end (i thought keys are treated as indexes in direct addressing,correct me if i am wrong) , so if we start iterating from the end then worst case would be O(m-n) where n is the number of elements examined by our iterator before reaching non null value from end of the direct addressing table

is something wrong with my approach? Can any one clear this topic?

¿Existe una forma posible de usar el case del switch como “case (rango de números)”?

¡Buenas tardes! La forma en que lo digité en el título es obviamente errónea, pero es para que entiendan a lo que me refiero. Normalmente un switch case 1, el case siempre obedece a un entero, pero qué pasa si quiero un case que lea un rango de enteros posibles dentro de la variable del switch, por ejemplo

switch(edad())      case (edad()>=1)  

Aquí un ejemplo en código fácil de lo que me refiero.

switch(edadGato())     {     case 1:         cout<<"Al gato le corresponde la vacuna de la Rabia";         break;     case 3:         cout<<"Al gato le corresponde la vacuna de la Panleucopenia";         break;     default:         cout<<"Basado en la edad, al gato no le corresponde ninguna edad";         break;     } 

Si la edad fuese 2, no me detectaría que ya tendría una vacuna pendiente por tener más de un año (case 1), por eso, mi duda sobre si existe una forma algo como case (rango de números).

Nota: Sé que con if es más fácil, pero si en switch es posible, compártanlo conmigo. Gracias de antemano.

Is my use case UML diagram too complicated?

The user of my app has access to two tools within my app. Each tool is comprised of multiple tables that the user has to fill with information.
The app is more complex but that’s roughly what’s it’s about.
This is the UML Diagram that I have designed based on the app:
enter image description here I am wondering whether the use case diagram should be designed otherwise. Maybe, I should design the use case diagram for each tool independently. That way, it will be less cumbersome.
But, this will mean that each tool represents its own system. And I don’t know if from a UML viewpoint, that is the right thing to do.

Proof of the average case of the Heap Sort algorithm

Consider the following python implementation of the Heap Sort algorithm:

def heapsort(lst):     length = len(lst) - 1     leastParent = length // 2     for i in range (leastParent, -1, -1):         moveDown(lst, i, length)      for i in range(length, 0, -1):         if lst[0] > lst[i]:             swap(lst, 0, i)             moveDown(lst, 0, i - 1)   def moveDown(lst, first, last):     largest = 2 * first + 1     while largest <= last:         # right child is larger than left         if (largest < last) and (lst[largest] < lst[largest + 1]):             largest += 1          # right child is larger than parent         if lst[largest] > lst[first]:             swap(lst, largest, first)             # move down to largest child             first = largest;             largest = 2 * first + 1         else:             return # exit   def swap(lst, i, j):     tmp = lst[i]     lst[i] = lst[j]     lst[j] = tmp 

I have been able to formally prove that worst-case is in $ \Theta(n \log(n))$ and that the best-case is in $ \Theta(n)$ (some might argue the best-case is in $ \Theta(n \log(n))$ as well since that’s what most searches on the internet will return but just think of what happens when an input list where all of the elements are the same number).

I have showed both upper and lower bounds of the worst and best-case by realizing that the route taken by moveDown function is dependent on the height of the heap/tree and whether the elements in the list are distinct or the same number across the whole list.

I have not been able to prove the average case of this algorithm which I know is also in $ \Theta(n \log(n))$ . I do know, however, that I am supposed to consider an input set or family of lists of all length $ n$ and I am allowed to make an assumption such as that all of the elements in the list are distinct. I confess that I am not good at average-case analysis and would really appreciate it if someone could give a complete and thorough proof(including the exact expressions especially of the number of inputs) as it would help me understand the concept a great deal.