would this be different for < over the floating point numbers?? |
For floats specifically, yes, it would be different, because the float domain has unsortable values. If you meant to ask about reals, then no, it would be the same. I mentioned the integers because they're more relevant in CS.
what is an example of integers x,y such that !(x < y) && !(y < x).
doesn't that imply x == y? |
Yes, but a weak ordering does not consider a symmetric relation.
doesn't it mean that if x is tied with y then x < y == false and y < x == false
so in that case x must be equal to y: x == y must be true??
regarding partial, does that mean that there exist x,y in some SET such that:
x and y are tied and therefore both of these are false: x < y, y < x ?
being tied implies x and y are equal?? |
No, it means they're incomparable. They might be exactly the same value or not, it depends on the type being considered. It is possible to construct types where incomparable values are not equal. For example,
1 2 3 4 5 6 7 8 9
|
struct A{
int x, y;
bool operator<(const A &other) const{
return this->x < other.x;
}
bool operator=(const A &other) const{
return this->x == other.x && this->y == other.y;
}
};
| |
You might want to define something like this because you need sorting to be specifically decoupled from equality.
Another possibility is that the type is a representation of some other type, and you want to sort by the represented type, but compare equality of the representation.
!("sqrt(1)" < "1") && !("1" < "sqrt(1)")
!("sqrt(1)" == "1")
Still another possibility is that the < relation doesn't compare the values themselves, but how they're related to each other. Suppose you're comparing the nodes of a tree and x < y is true if x is a parent or ancestor of y. There may be nodes on the tree that are unrelated but which are not the same node.
can you show by example an ordering that is not strict weak ordering? or that is strict partial ordering? |
A topological sort of a directed acyclic graph requires defining an ordering where incomparability is intransitive.
If you have five software packages with the following dependency graph:
1 2 3 4
|
A <---- B <------ E
^ |
| |
+--- C <---- D <--+
| |
C is incomparable with B and B is incomparable with D, but C is not incomparable with D. That is, [B and C] and [B and D] can be installed in any other with respect to each other, but D must be installed after C.