title: TreeSet Vs Tree
body: <p>I have few questions related to Collection Frameworks's <code>TreeSet</code> that I am putting here.</p>
  <ol>
  <li><p>Is the only functional difference between <code>TreeSet</code> and <code>ArrayList</code> classes is constraint of unique elements and elements being sorted too in <code>TreeSet</code>?</p>
  </li>
  <li><p>Presence of prefix <code>Tree</code> creates a confusion about visualizing a <code>TreeSet</code> as a hierarchical data structure or linear one. Mathematical sets are linear data structures while name <code>Tree</code> in computing indicates a hierarchical one.</p>
  <p>Is there really any similarity / relation between <code>Tree</code> Data Structure and Java's <code>TreeSet</code> or name <code>TreeSet</code> just a coincidence?</p>
  </li>
  </ol>
  <p>I mean, it doesn't seem that set will have anything to do with parent - child relationships.</p>
  <p><strong>EDIT</strong> - Looks like, I was confused about what I am trying to ask which got clarified after pondering over comments and answers. I guess, my main question should have been &quot;why mathematical set DS ( sorted or unsorted ) is implemented via a Tree?&quot; and that is a duplicate of <a href="https://stackoverflow.com/questions/2630738/c-how-to-implement-set-data-structure">How to implement Set data structure?</a></p>