Farzin Nasiri
Farzin Nasiri

Reputation: 730

leader election when UID's are not integers

I'm new to distributed systems and I'm currently studying Nancy lynch's book for distributed algorithms. Now After Finishing the section about leader elections problem and learning algorithms like LCR, HS,.. one problem come a cross my mind:
What if the UID's weren't positive integers?
basically in all of that section I read, UID's were positive integers. How ever when I was thinking about coding this algorithms I thought about objects for comparison. For instance in programming we may have different objects(like apples and oranges!). So the problem would be something like:
If for instance A,B,C,... were the UID's of the nodes, how can I elect the leader?


One of my big problems is that we can't simply compare objects! like we can say A==A but there is no way no say A>B or A<B(its like saying apple is bigger than orange or not?)

Thank in advance

Upvotes: 0

Views: 85

Answers (1)

btilly
btilly

Reputation: 46399

With objects you pick an arbitrary way to compare them. There are many choices of comparison, but if everyone agrees on which one to use, then it works.

For example you can decide to compare your fruits by weight. And now any given apple can be fairly compared to any given orange. And the algorithm works.

Upvotes: 1

Related Questions