Root port

Idle question - the root port appears to be the port used to uplink to another router/switch. It’s assigned dynamically - how does RouterOS work out which is the uplink/root port?

https://en.wikipedia.org/wiki/Spanning_Tree_Protocol

What if I disable STP?