MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / leveloder

Function leveloder

CPP/binarytreeuse.cpp:302–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300}
301
302void leveloder(binarytree<int>*root)
303{
304 queue<binarytree<int>*> pendingnodes;
305 pendingnodes.push(root);
306 pendingnodes.push(NULL);
307
308 while(pendingnodes.size()!=0)
309 {
310 binarytree<int>*front=pendingnodes.front();
311 pendingnodes.pop();
312
313 if(pendingnodes.size()==0)
314 break;
315
316 if(front==NULL)
317 {
318 cout<<endl;
319 pendingnodes.push(NULL);
320 }
321 else
322 {
323 cout<<front->data<<" ";
324 if(front->left)
325 pendingnodes.push(front->left);
326
327 if(front->right)
328 pendingnodes.push(front->right);
329 }
330 }
331}
332
333binarytree<int>*removeleafnodes(binarytree<int>*root)
334{

Callers

nothing calls this directly

Calls 3

pushMethod · 0.45
sizeMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected