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

Function printlevelwise

CPP/binarytreeuse.cpp:29–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29void printlevelwise(binarytree<int>*root)
30{
31 queue<binarytree<int>*> pendingnode;
32 pendingnode.push(root);
33
34 while(pendingnode.size()!=0)
35 {
36 binarytree<int>*front=pendingnode.front();
37 cout<<front->data<<":";
38 pendingnode.pop();
39 if(front->left)
40 {
41 cout<<"L"<<front->left->data<<",";
42 pendingnode.push(front->left);
43 }
44
45 if(front->right)
46 {
47 cout<<"R"<<front->right->data<<",";
48 pendingnode.push(front->right);
49 }
50
51 cout<<endl;
52
53 }
54
55}
56
57binarytree<int>* takeinput()
58{

Callers 1

mainFunction · 0.85

Calls 3

pushMethod · 0.45
sizeMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected