Tree Data Structure

Usually when we start to study data structures, we study first trees and then graph. Can I give you two tips ? First read about graph theory. Try to answer for yourself the two following questions:

  • What are acyclic and cyclic graphs ?
  • What are directed, undirected and bidirectional graphs ?

Right. Are you a bit more confused now ? 🙂 Let’s blow the candles and see the knowledge emerging like magic. Let’s list some conditions to say: “Hey it is a tree !”

  • Just like in real life, there are many types of trees data structures that we can have.
  • In graph theory, a tree is a nonlinear data structure, compared to arrays, linked lists, stacks and queues which are linear data structures.
  • One of the disadvantages of using an array or linked list to store data is the time necessary to search for an item. Since both the arrays and Linked Lists are linear structures the time required to search a “linear” list is proportional to the size of the data set.
  • Every tree is a graph, but not every graph is a tree.
    • A is the root but it also a parent. In graph theory, a loop (also called a self-loop or a “bucle”) is an edge that connects a vertex to itself. A tree don’t have loop.
  • A child has just one parent.
  • A tree is acyclic(contains no cycles).

Published by

Mhayk Whandson

Passionate about JavaScript, ReactJS, React Native, Node.js and the entire ecosystem around these technologies. A fullstack developer that has seen the bare metal coding Linux kernel drivers in C and multi-plataform desktop apps in C++/Qt5. Check my GitHub freebies at https://github.com/mhayk.

Leave a Reply

Your e-mail address will not be published. Required fields are marked *