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 child has just one parent.
- A tree is acyclic(contains no cycles).