100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

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

Rating
-
Sold
-
Pages
11
Grade
A+
Uploaded on
07-09-2024
Written in
2024/2025

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

Institution
CSC148
Course
CSC148









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
CSC148
Course
CSC148

Document information

Uploaded on
September 7, 2024
Number of pages
11
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

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

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
KenAli West Virginia University
View profile
Follow You need to be logged in order to follow users or courses
Sold
84
Member since
1 year
Number of followers
5
Documents
17177
Last sold
1 week ago

2.9

19 reviews

5
4
4
4
3
4
2
0
1
7

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions