100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CSC148 Trees Exam Study Guide Questions with Complete solutions (A Graded) $12.79   Add to cart

Exam (elaborations)

CSC148 Trees Exam Study Guide Questions with Complete solutions (A Graded)

 0 view  0 purchase
  • Course
  • CSC148
  • Institution
  • CSC148

CSC148 Trees Exam Study Guide Questions with Complete solutions (A Graded)

Preview 2 out of 11  pages

  • September 7, 2024
  • 11
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • CSC148
  • CSC148
avatar-seller
KenAli
CSC148 Trees Exam Study Guide
Questions with Complete solutions (A
Graded)

descendants of a value - ANSWER - it children,
its children's children


ancestors of a value - ANSWER - its parent, its parent's parent



Path - ANSWER a sequence of values (nodes_ where there is an edge between each pair of n-
n(i+1)


Length of path - ANSWER the number of edges in a path
- there's a unique path from the root of the tree to each node in that tree


No cycles - ANSWER -There are no cycles


Leaf - ANSWER - a value(node) with no children(no subtrees)
- internal node: a value (node) with one or more children

- Height of a tree: the longest path from the root to one of the leaves (count the number of
values on the path, can be expressed as 1+ the maximum path length in a tree, a
value(node)'s height is 1+ the maximum path length of the tree rotted at that node

, Internal Node - ANSWER A value with one or more children


Height of the tree - ANSWER Longest path from the root to one of the leaves


depth of the value (node) - ANSWER length of the path from the root to that value


arity, branching factor - ANSWER maximum number of children for any node


General Tree Deletion - ANSWER - Hidden Assumption: subtree of a Tree is not empty




def _delete_root(self) -> None:
"""Delete the root of this tree.
Precondition: this tree is non-empty.
"""
if self._subtrees == []:

# This is a leaf. Deleting the root gives an empty
tree. self._root = None
else:
# This tree has more than one value!
# Can't just set self._root = None, need to REPLACE it.
# Strategy 1: "Promote" a subtree.
# 1. Remove the rightmost subtree.
last_subtree = self._subtrees.pop()
# 2. Update self._root
self._root = last_subtree._root
# 3. Update self._subtrees

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller KenAli. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $12.79. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79064 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$12.79
  • (0)
  Add to cart