Edit this page Backlinks This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== TDA-uri și inducție structurală ====== 1. Definiți axiome pentru următorii operatori pe tipul ''List'': * ''reverse'' (inversează elementele dintr-o listă) * ''filterEven'' (elimină elementele impare dintr-o listă) 2. Definiți axiome pentru următorii operatori pe tipul ''BTree'': * ''mirror : BTree → BTree'' (arborele oglindit pe verticală, i.e. pentru orice nod, copilul stâng devine copilul drept și vice-versa) * ''flatten : BTree → List'' (lista cu toate elementele din arbore; observați că există mai multe ordini posibile) 3. Definiți axiome pentru următorii operatori pe tipul ''Map'': * ''update : Map × K × V → Map'' (un Map cu o nouă asociere cheie:element) * ''delete : Map × K → Map'' (șterge cheia și valoarea asociată) 4. Demonstrați următoarele propoziții, folosind inducție structurală: * $math[\forall t \in \texttt{BTree}. size(t) = size(mirror(t))] * $math[\forall t \in \texttt{BTree}. size(t) = length(flatten(t))] * $math[\forall l \in \texttt{List}. append(l, Empty) = l] * $math[\forall l_1, l_2, l_3 \in \texttt{List}. append(l_1, append(l_2, l_3)) = append(append(l_1, l_2), l_3))] * $math[\forall l_1, l_2 \in \texttt{List}. length(append(l_1, l_2)) = length(append(l_2, l_1))] * $math[\forall l_1, l_2 \in \texttt{List}. reverse(append(l_1, l_2)) = append(reverse(l_2), reverse(l_1))]. <note> Soluțiile acestui laborator se găsesc [[https://ocw.cs.pub.ro/ppcarte/doku.php?id=aa:lab:sol:12|aici]] </note>