1. Home
  2. Explore
  3. Computer Science
  4. Binary Tree Algorithms

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Binary Tree Algorithms

  • 22Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Tree Terminology
In a tree, the circles that store values are called
.

22 questions

  1. 1
    In a tree, the circles that store values are called
    _____
    .
    Hint

    Think about the basic components that hold data.

    Answer

    nodes

  2. 2
    The lines connecting nodes in a tree are called
    _____
    .
    Hint

    These represent the relationships between nodes.

    Answer

    edges

  3. 3
    A node that has no parent is called the
    _____
    .
    Hint

    This is the topmost node in a tree.

    Answer

    root

  4. 4
    A node that has no children is called a
    _____
    .
    Hint

    It is at the end of a branch.

    Answer

    leaf

  5. 5
    In a tree, if node B is a child of node A, then node A is the
    _____
    of node B.
    Hint

    Think of family relationships.

    Answer

    parent

  6. 6
    A binary tree is a tree where every node has at most
    _____
    children.
    Hint

    The word 'binary' relates to the number two.

    Answer

    two

  7. 7
    A binary tree must have exactly one
    _____
    .
    Hint

    The node with no parent.

    Answer

    root

  8. 8
    In a binary tree, there is exactly one
    _____
    between the root and any node.
    Hint

    A sequence of connected nodes.

    Answer

    path

  9. 9
    A tree with zero nodes, called the empty tree, is considered a
    _____
    .
    Hint

    Even without nodes, it still satisfies the definition.

    Answer

    binary tree

  10. 10
    For a node that does not have a left child, its left property is set to
    _____
    .
    Hint

    A placeholder for no child.

    Answer

    null

  11. 11
    The depth-first traversal algorithm uses a
    _____
    data structure.
    Hint

    Last-in, first-out order.

    Answer

    stack

  12. 12
    In a recursive depth-first traversal, the base case for a null node is to
    _____
    .
    Hint

    No further action needed.

    Answer

    return

  13. 13
    The time complexity of a depth-first traversal on a binary tree with n nodes is
    _____
    .
    Hint

    It visits each node exactly once.

    Answer

    O(n)

  14. 14
    The breadth-first traversal algorithm uses a
    _____
    data structure.
    Hint

    First-in, first-out order.

    Answer

    queue

  15. 15
    Breadth-first traversal cannot be easily implemented
    _____
    due to its reliance on a queue.
    Hint

    Recursion naturally uses a stack.

    Answer

    recursively

  16. 16
    In the "tree includes" problem, if the root is null, the function should return
    _____
    .
    Hint

    Cannot find anything in an empty tree.

    Answer

    false

  17. 17
    In the recursive solution for "tree includes", the base case for a non-null node that matches the target is to return
    _____
    .
    Hint

    Found it.

    Answer

    true

  18. 18
    In the recursive "tree includes", after checking the node value, the result is the logical
    _____
    of the left subtree and right subtree results.
    Hint

    At least one side must contain the target.

    Answer

    OR

  19. 19
    In the recursive tree sum function, the base case for a null node returns
    _____
    .
    Hint

    Empty tree has no value.

    Answer

    0

  20. 20
    In the recursive tree min value function, the base case for a null node returns
    _____
    .
    Hint

    A very large number that will never be the minimum.

    Answer

    Infinity

  21. 21
    In the max root-to-leaf path sum problem, a leaf node returns its own value as the
    _____
    .
    Hint

    A leaf is the end of a path.

    Answer

    max path sum

  22. 22
    For a null node in the max root-to-leaf path sum, the appropriate return value is
    _____
    .
    Hint

    It should never be chosen over a real path.

    Answer

    -Infinity

1 of 22
Question 1 of 22

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent