Data Structures and Algorithms

Exercises: Trees

Feb 262018

Before attempting these exercises, you should read the posts about trees and ways to think about trees.


  1. Which of the following are tree structures? Explain your answers.
    1. Books in a library, organised by category.
    2. Employees in a company, organised by who is each person’s manager.
    3. Linked lists.
    4. Words in the English language, organised by prefixes — for example, “cat” is a prefix of “catalyst”.
    5. Classes and subclasses in an object-oriented program.
  2. For each of the tree structures you identified in question 1., make up some example data, and draw a diagram to visualise it as a tree.
  3. Draw node/link diagrams for the following tree structures:
    1. The tree representing the expression 2*x + 3*(y+4).
    2. The directories and files in this git repository.
    3. The exercises listed on this page. (Label the nodes with question numbers, or very short descriptions.)

There are no published comments.

New comment

Your comment will not appear until a moderator approves it.


hosted on werp.site