Tree

A tree is perhaps the most common data structure used in computer science, and you are already more familiar with it than you probably realize. The tree is actually based on the tree that grows in the ground, complete with a trunk, branches, and leaves. You have seen trees in the kittenbook directory and in kittenbook.html. The kittenbook directory is the trunk (everything in the tree grows out of the trunk), the other directories are branches (branches can contain leaves), and the individual files are leaves. In kittenbook.html, the <html> tag is the trunk, tags that contain other tags are branches, and the remaining tags are leaves. Tags within tags are nested (more like Russian nesting dolls, less like the place where a bird lays its ...

Get Learning to Program now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.