問答題

一個(gè)有4層結(jié)點(diǎn)的完全二叉樹。按前序遍歷周游給結(jié)點(diǎn)從1開始編號(hào),則第21號(hào)結(jié)點(diǎn)的父結(jié)點(diǎn)是多少號(hào)?(注釋:根的層數(shù)為0) For a complete binary tree with four levels, label the nodes starting from 1 according to the preorder traversal. what is the label of the parent node for node 21? (The root is on level 0)

答案: 在完全二叉樹中,如果按照前序遍歷(根-左-右)給結(jié)點(diǎn)編號(hào),那么對(duì)于任意一個(gè)結(jié)點(diǎn)i,它的左子結(jié)點(diǎn)的編號(hào)是2i,右子結(jié)點(diǎn)的編...
微信掃碼免費(fèi)搜題