AI Hints
Home›DSA in Python Tutorial›Tries and Tree Review
DSA in Python · Lesson 75 of 132

Trees Quiz

Test yourself.

⏱ 2 min read▶ Video at 1:28:06🎓 Free
Watch this lesson in the DSA in Python courseWatch on YouTube ↗Full DSA in Python course

Trees, binary search trees, heaps, and tries. That's a lot of branching. Let's check it. Pause, answer, then listen.

Trees Quiz
From the video: Trees Quiz
  • Trees, BSTs, heaps, tries
  • Let's check
  • Pause and answer

Question 1

Which traversal of a binary search tree gives the values in sorted order? The answer is in order. Left, then the node, then right.

Quick check
Sorted output from a BST?

Question 2

What does a binary search tree become if you insert values that are already sorted? The answer is a chain, like a linked list, with O of N searches.

Quick check
Insert sorted values into a plain BST, and you get…

Question 3

Where is the smallest item in a min heap? The answer is at the top, which is index zero in Python's heap Q.

Quick check
In heapq, the smallest item is at…

Question 4

Which structure is best for autocomplete? The answer is a trie, because words with the same beginning share a path.

Quick check
Best for autocomplete?

Summary

Brilliant. Next, a new section. Graphs, the structure behind maps, networks, and social media.

Key takeaways
  • In order = sorted
  • Sorted input → chain
  • heap[0] is the smallest
Next up: Graphs — nodes and edges