Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
aa:lab:14 [2021/01/22 09:00]
pdmatei created
aa:lab:14 [2021/01/24 15:10] (current)
roxana_elena.stiuca fixed number of nodes in complete binary tree
Line 1: Line 1:
 ====== Structural Induction ====== ====== Structural Induction ======
 +
 +Recall the ADTs defined in the previous lab:
 +  * ''​Tree''​
 +  * ''​FIFO''​
 +  * ''​Map''​
 +
 +Prove the following properties are true, using structural induction:
 +
 +1. $math[\forall t\in \texttt{Tree}. size(t) \geq height(t)]
 +
 +2. $math[\forall t \in \texttt{Tree}. flatten(mirror(t)) = reverse(flatten(t))]
 +
 +Find a proper formulation and prove the following properties:
 +
 +1. Merging (using the strategy from ''​Mergesort''​) two sorted lists produces a sorted list.
 +
 +2. A complete binary tree always has $math[2^{height(t)}-1] nodes.