Log in from a computer to take this course

You'll need to log in from a computer to start Introduction to Non-linear Data Structures in Swift. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
Learn

Trees grow downwards in computer science, and a root node is at the very top. The root of this tree is /photos.

/photos references to two other nodes: /safari and /wedding. /safari and /wedding are children or child nodes of /photos.

Conversely, /photos is a parent node because it has child nodes.

/safari and /wedding share the same parent node, which makes them siblings.

Note that the /safari node is child (to /photos) and parent (to lion.jpg and giraffe.jpg). It’s extremely common to have nodes act as both parent and child to different nodes within a tree.

When a node has no children, we refer to it as a leaf node.

Instructions

These terms: root, leaf, child, sibling, and parent give us a precise way to communicate the relationships between nodes.

What are the four leaf nodes in this diagram?

What node has no parent?

What is the sibling node to lion.jpg?

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?