c++ - Why is an object sent into this function, but is never used? -


int height(const tree& t, const position& p) {     if (p.isexternal()) return 0;       // leaf has height 0     int h = 0;     positionlist ch = p.children();     // list of children     (iterator q = ch.begin(); q != ch.end(); ++q)       h = max(h, height(t, *q));     return 1 + h;               // 1 + max height of children   } 

my textbook gives above code finding height of general tree. why "tree t" sent function if never used (its member functions/variables never called or used) throughout function?

i guess sort of consistency other functions. example, function depth might calculate depth of position starting @ root of tree , using dfs find position.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -