Reputation
25,251
Next tag badge:
321/100 score
13/20 answers
Badges
12 56 83
Newest
 Guru
Impact
~907k people reached

Apr
28
comment If I implement an Interface, is it called an Inheritance?
@BillK: Thanks!
Apr
28
comment Binary Search Tree without Natural Ordering
@adv: We can construct efficient trees like ((((X1X)2(X3X))4((X5X)6(X7X)))8((X10X)9(X11X))) which has 8 as the root and is 2 away from the median of 6, but this tree is still optimal. Now, you are right to point out that it is characteristic of balanced trees to have the root value be close to the median value of its descendants. But it only need be close, not equal.
Apr
28
comment Binary Search Tree without Natural Ordering
@adv: if the data in the tree is never changing then yes, it may make sense to organize the tree into a complete tree. But if nodes are being added and removed from the tree then maintaining completeness is an expensive proposition; maintaining a weaker property such as height balance is cheaper.
Apr
28
comment Binary Search Tree without Natural Ordering
@adv: But usually the property that we want is not minimal number of comparisons per search, but rather sublinear number of comparisons per search. To obtain this property we can use a number of techniques, the most common of which is to height-balance the tree. If you can maintain an invariant that, say, the path from any node to the deepest leaf, and the path from any node to the shallowest leaf, differ by no more than some multiple factor, then you can obtain sublinear average search times.
Apr
28
comment Binary Search Tree without Natural Ordering
@adv: Your statement that the median value must be the root in order to minimize search times is false, given no additional information about whether certain searches are more likely than others. Let us notate a tree as X if it is empty and (left-value-right) if it is not. Consider the trees ((X1X)2(((X3X)4(X5X)))) and (((X1X)2X)3(X4(X5X))) The first has 2 as the root, the second has 3, the median, as the root, but both are equally efficient in amortized number of comparisons per search. (That is, on average 2.2 comparisons for every search.)
Apr
28
comment Binary Search Tree without Natural Ordering
@adv: I said correct results, not best performance. In order for a binary search tree to work at all there must be a total order imposed; if there is not then it is possible that there is an element that is in the tree that cannot be found!
Apr
28
revised If I implement an Interface, is it called an Inheritance?
added 1230 characters in body
Apr
28
awarded  Guru
Apr
28
comment Binary Search Tree without Natural Ordering
@KevinJ.Chase: That's not quite what I'm saying. I'm saying that files on disk are very clearly strings of bytes. Many programming languages do not make it easy to extract a string of bytes from an arbitrary data type.
Apr
28
revised If I implement an Interface, is it called an Inheritance?
added 72 characters in body
Apr
28
comment If I implement an Interface, is it called an Inheritance?
@BillK: I see your point now; you are correct to note that if a class has a method whose signature is compatible with the signature of the abstract interface method then that method is not considered to be inherited.
Apr
28
comment If I implement an Interface, is it called an Inheritance?
@BillK: Now, I am not saying that a class which implements an abstract interface "inherits the interface". I am saying what the specification says: that abstract members of superinterfaces are inherited by classes. Again, this is the definition of inheritance in Java, C++ and C#: that members of base types are inherited by types which derive from or implement them.
Apr
27
revised Binary Search Tree without Natural Ordering
added 141 characters in body
Apr
27
comment If I implement an Interface, is it called an Inheritance?
@BenjaminGruenbaum: Now as for your actual question, indeed, why should the designers of the language have the final say about the terminology and its precise definition? Similarly we could ask why it is that J K Rowling has the final say about the events in the Harry Potter books, merely because she spent years of her life creating that work and keeping it consistent. If I think that something else should have happened at Hogwarts, surely my opinion is every bit as valid as hers, right?
Apr
27
comment If I implement an Interface, is it called an Inheritance?
@BenjaminGruenbaum: Don't I know it. Those developers are wrong, and they often take it upon themselves to "educate" others as to their wrong beliefs. You would not believe the number of programming language books I've had to fix because the authors had some completely crazy beliefs about VB, C#, JavaScript, etc, that were in no way correct. (Jon Skeet was not among them; C# In Depth was correct from the start! Never have I made so few comments on a book and still gotten paid.)
Apr
27
comment If I implement an Interface, is it called an Inheritance?
I (mostly) agree with Robert. I think there is real value in understanding the precise technical meanings of jargon words as they are used in various contexts. But Robert is right that it is of far greater benefit to understand the practical impact! How can you use inheritance to make your code safer? More testable? More reusable? More flexible? And so on. Knowing that members of base types are also members of derived types is great, but it is better still to know how to use it effectively.
Apr
27
comment Binary Search Tree without Natural Ordering
@RobertHarvey: Sure, that works too. My point was that there is no reason to suppose that an ordinal comparison of bytes is "natural" for strings containing bytes interpreted as text but "unnatural" for strings containing bytes interpreted as sound. Consider by contrast, say, a set of objects representing types in a type system. They are not strings of text, they are not strings of bytes, heck, they need not even have names or be printable, and there is no natural, obvious way to impose an ordering on them. I can think of lots of things that are unnatural to order; bytes aren't among them.
Apr
27
comment If I implement an Interface, is it called an Inheritance?
@ThomasOwens: Your question is "how do I deal with ambiguity in communication?" and I will repeat my answer. If you think that the person you are communicating with might be confused then you refer them to the specification that defines the words you are using.
Apr
27
comment If I implement an Interface, is it called an Inheritance?
@ThomasOwens: I agree that this scenario is common and I completely disagree with your conclusion. The solution to the communication problem you describe is educate everyone involved as to the precise meanings of the words in the relevant context. Specifications exist to provide this clarity; use them!
Apr
27
awarded  Good Answer