levo

Fundamentals of Data Structures

Trees

  • 3 things to know
  • Paper 1
Start revising · £5/month

Overview

Recall questions on rooted and binary trees, parent, child and descendant, leaf nodes, and the ordering rule that governs a binary search tree.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

Define a tree.

Process

What is a binary search tree, and what rule governs it?

Key term

Describe how a binary tree is stored in memory when the language has no tree type.

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    Define a tree.

    Model answer

    A tree is a graph that is connected, undirected and free of cycles. Connected means there is a path between every pair of vertices; no cycles means there is no path that returns to its starting vertex without reusing an edge. Consequently there is exactly one path between any two vertices.

  2. 2

    Does a tree have to have a root?

    Model answer

    A tree does not have to have a root. A tree is simply a connected, undirected graph with no cycles, and that definition says nothing about a root. A root only exists when one vertex has been deliberately designated as such, which makes the tree a rooted tree. It is a common mistake to assume every tree has a root.

  3. 3

    Define a rooted tree.

    Model answer

    Take any tree and single out one of its vertices as the root: what you have is a rooted tree. That one choice imposes parent-child relationships throughout the structure — the root alone has no parent, every other node descends from it, and each node's distance from the root fixes its level. The same underlying tree can yield several different rooted trees, depending on which vertex is chosen.

  4. 4

    In a rooted tree, what is meant by parent, child and descendant?

    Model answer

    Once a root has been chosen, each node other than the root has exactly one parent, the node immediately above it on the unique path back to the root, and any nodes immediately below it are its children. A descendant of a node is any node that can be reached by moving downwards from it — its children, their children, and so on. Every node other than the root is a descendant of the root.

  5. 5

    Define a binary tree.

    Model answer

    A binary tree is a rooted tree in which each node has at most two children. A node may therefore have two children, one child, or none at all, but never three or more.

  6. 6

    What is a leaf node?

    Model answer

    A node in a rooted tree that has no children — nothing hangs below it. In a binary tree, a leaf is a node whose left and right child pointers are both null.

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Fundamentals of Programming
Fundamentals of Data Structures
Fundamentals of Algorithms
Theory of Computation

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

A driver is .
softwarehardwarestorage

Blank Blitz consolidates the facts

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

Head means the first single element of a non-empty list.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Fundamentals of Data Structures, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.