100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Class notes

Lecture notes Midterm and Exam

Rating
-
Sold
-
Pages
3
Uploaded on
15-12-2022
Written in
2021/2022

Notes for Final Exam bevat alle college aantekeningen voor het eind tentamen Lectures notes bevat alle college aantekeningen voor de midterm

Institution
Course








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

Written for

Institution
Study
Course

Document information

Uploaded on
December 15, 2022
Number of pages
3
Written in
2021/2022
Type
Class notes
Professor(s)
Mehrabi
Contains
All classes

Subjects

Content preview

Trees and AVL tress
The height of a node:

- If the node has no children: -1
- If the node is a parent: 0
- Height of a random node is the max height (left subtree , right subtree) + 1
- Balance is (the height of the left subtree – height of the right subtree) is smaller or equal to 1

Check where the biggest height is:

- Left right subtree? Perform a left-right rotation
- Left left subtree? Perform a right rotation
- Right left subtree? Perform a right-left rotation.
- Right right subtree? Perform a left rotation




Trees important points
- A node without children is a leaf (external node)
- Each node with children is an internal node
- The depth of a node is the length of the path from that node to the root
- The height of a node is the length of the longest path from that node to a leaf

A Binary tree: each node has AT MOST 2 children

A full Binary tree: all internal nodes have 2 children OR 0 children. The following holds if the tree is a
binary tree: the amount of leaves = the amount of internal nodes + 1

Running time of 3 traversal algorithms: Big Theta of n. Each node will be visited exactly 2 times ( in
preorder and inorder) and three times in postorder. Total number of inorder and preorder is 2n and
postorder 3n  Theta(n). Each visit is Theta(1)

AVL trees
Height-Balanced property: for every internal node v, the heights of its children differ at most 1

The height of an AVL tree storing n keys = O(log(n))

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.
gideonrouwendaal Universiteit van Amsterdam
Follow You need to be logged in order to follow users or courses
Sold
49
Member since
2 year
Number of followers
22
Documents
17
Last sold
6 months ago

5.0

1 reviews

5
1
4
0
3
0
2
0
1
0

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 exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT 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