Timeline for Prove $T$ is a BST iff for every node $x$ of $T$ that is not a leaf, the key of $x$ is larger or equal than the key of the left child of $x$
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 17, 2017 at 9:46 | history | tweeted | twitter.com/StackCompSci/status/876013212264783875 | ||
Jun 16, 2017 at 9:23 | vote | accept | Yos | ||
Jun 16, 2017 at 9:19 | comment | added | fade2black | you write: "...the key of $x$ is larger or equal than the key of the left child of $x$ OR it is less than or equal than the key of the right child". Pay attention to the second 'or' (uppercase 'or). Consider a three node @Yos, binary tree (1)<--left--((3)) --right-->(2), 3 is root, 1 is the left child and 2 is the right child. So your proposition is TRUE: (node 3 is a non-leaf) and ( (3 is larger than or equal to the left child 1) OR (3 is less than or equal to 2 ) . But the tree is not a BST. | |
Jun 16, 2017 at 9:18 | answer | added | Karegar | timeline score: 3 | |
Jun 16, 2017 at 9:06 | comment | added | Yos | @fade2black the key of $x$ can be larger OR equal than the key of its left child $y$ why does it have to be AND? Also you're saying no need for further proof in the first direction but what about the second direction? | |
Jun 16, 2017 at 9:03 | comment | added | fade2black | In your proposition: "if for every node $x$ of $T$ that is not a leaf, the key of $x$ is larger or equal than the key of the left child of $x$ OR it is less than or equal than the key of the right child", shouldn't OR be replaced with AND. Even in that case you will already have a definition of a BST, so no need to prove it. | |
Jun 16, 2017 at 9:00 | history | edited | Raphael |
edited tags
|
|
Jun 16, 2017 at 8:48 | history | asked | Yos | CC BY-SA 3.0 |