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

Study methods

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

Binary Tree Fundamentals

  • 15Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Binary Tree Types

What defines a full binary tree?

15 questions

  1. 1

    What defines a full binary tree?

    1. A

      Every node must have exactly two children.

    2. B

      All levels are completely filled.

    3. C

      Node: either 0 or 2 children.

    4. D

      All leaves are at the same depth.

    Correct answer
    C

    Node: either 0 or 2 children.

    Explanation

    In a full binary tree, nodes have either 0 or 2 children; no node has exactly one child.

  2. 2

    How are nodes arranged in a complete binary tree?

    1. A

      Each node has two children.

    2. B

      All leaves are on the same level.

    3. C

      Filled top-to-bottom, left-to-right.

    4. D

      No node has a single child.

    Correct answer
    C

    Filled top-to-bottom, left-to-right.

    Explanation

    A complete binary tree is filled level by level from left to right, except possibly the last level.

  3. 3

    Which properties must a perfect binary tree satisfy?

    1. A

      It must be complete but not necessarily full.

    2. B

      It must be full and complete.

    3. C

      All nodes must have exactly one child.

    4. D

      It must be full but not necessarily complete.

    Correct answer
    B

    It must be full and complete.

    Explanation

    A perfect binary tree has all leaves on the same level and every internal node has two children, making it both full and complete.

  4. 4

    If a node in a full binary tree has children, how many does it have?

    1. A

      Exactly two

    2. B

      Exactly one

    3. C

      Either one or two

    4. D

      None

    Correct answer
    A

    Exactly two

    Explanation

    In a full binary tree, any node that has children must have exactly two children.

  5. 5

    What is the order of operations in a pre-order traversal?

    1. A

      Node, right subtree, left subtree

    2. B

      Node, left subtree, right subtree

    3. C

      Left subtree, right subtree, node

    4. D

      Left subtree, node, right subtree

    Correct answer
    B

    Node, left subtree, right subtree

    Explanation

    Pre-order visits the current node first, then recursively traverses the left subtree, then the right subtree.

  6. 6

    In an in-order traversal, when is the node visited?

    1. A

      Before its left subtree

    2. B

      After both subtrees

    3. C

      Between its left and right subtrees

    4. D

      After its right subtree

    Correct answer
    C

    Between its left and right subtrees

    Explanation

    In in-order, we traverse left, visit the node, then traverse right.

  7. 7

    In a post-order traversal, the node is visited:

    1. A

      Only if it is a leaf

    2. B

      Before both subtrees

    3. C

      Between left and right subtrees

    4. D

      After both subtrees

    Correct answer
    D

    After both subtrees

    Explanation

    Post-order traverses left, then right, then visits the node.

  8. 8

    The prefix 'pre' in 'pre-order' indicates that the node is visited:

    1. A

      Only if it has children

    2. B

      At the end of the traversal

    3. C

      Before both subtrees

    4. D

      After the left subtree

    Correct answer
    C

    Before both subtrees

    Explanation

    The prefix tells when the node is visited relative to the subtrees: 'pre' means before.

  9. 9

    What order does an in-order traversal produce on a binary search tree?

    1. A

      Alternating pattern

    2. B

      Increasing order

    3. C

      Decreasing order

    4. D

      Leaves first

    Correct answer
    B

    Increasing order

    Explanation

    In-order traversal of a BST visits nodes in sorted (non-decreasing) order.

  10. 10

    What is the defining property of a binary search tree?

    1. A

      It is a complete binary tree.

    2. B

      For each node, all left descendants are smaller and all right descendants are larger.

    3. C

      Every node has at most one child.

    4. D

      It is a full binary tree.

    Correct answer
    B

    For each node, all left descendants are smaller and all right descendants are larger.

    Explanation

    In a BST, the left subtree of a node contains only keys less than the node's key, and the right subtree contains only keys greater than the node's key.

  11. 11

    In a recursive tree traversal, what does each stack frame represent?

    1. A

      The traversal order

    2. B

      The recursion depth

    3. C

      The entire tree

    4. D

      A single node and its tasks (visit, left, right)

    Correct answer
    D

    A single node and its tasks (visit, left, right)

    Explanation

    Each recursive call corresponds to a node, and the stack frame stores the tasks (visit, left, right) for that node.

  12. 12

    What is the time complexity of traversing a binary tree with n nodes?

    1. A

      O(n^2)

    2. B

      O(log n)

    3. C

      O(1)

    4. D

      O(n)

    Correct answer
    D

    O(n)

    Explanation

    Since every node is visited exactly once, the time complexity is linear, O(n).

  13. 13

    Which data structure is typically used for an iterative depth-first tree traversal?

    1. A

      Heap

    2. B

      Queue

    3. C

      Stack

    4. D

      Linked list

    Correct answer
    C

    Stack

    Explanation

    An iterative depth-first traversal (pre, in, post) can be implemented using an explicit stack to simulate recursion.

  14. 14

    Which data structure is commonly used for a breadth-first traversal of a tree?

    1. A

      Stack

    2. B

      Queue

    3. C

      Priority queue

    4. D

      Array

    Correct answer
    B

    Queue

    Explanation

    Breadth-first traversal (level-order) typically uses a queue to process nodes level by level.

  15. 15

    In a recursive tree traversal, where is the state of the recursion stored?

    1. A

      In the heap

    2. B

      In the call stack

    3. C

      In a global variable

    4. D

      In a queue

    Correct answer
    B

    In the call stack

    Explanation

    Recursive calls store their state (parameters, local variables) on the call stack.

Question 1 of 15
Question 1 of 15

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent