java - want to create tree node and print following pattern on console -
b1 a1 b2 c1 a2 c2
want print pattern dynamically. tried using node represent positions left,right
node<integer> root = new node<integer>(2); node<integer> n11 = new node<integer>(7); node<integer> n12 = new node<integer>(5); node<integer> n21 = new node<integer>(2); node<integer> n22 = new node<integer>(6); node<integer> n23 = new node<integer>(3); node<integer> n24 = new node<integer>(6); node<integer> n31 = new node<integer>(5); node<integer> n32 = new node<integer>(8); node<integer> n33 = new node<integer>(4); node<integer> n34 = new node<integer>(5); node<integer> n35 = new node<integer>(8); node<integer> n36 = new node<integer>(4); node<integer> n37 = new node<integer>(5); node<integer> n38 = new node<integer>(8); root.left = n11; root.right = n12; n11.left = n21; n11.right = n22; n12.left = n23; n12.right = n24; n21.left = n31; n21.right = n32; n22.left = n33; n22.right = n34; n23.left = n35; n23.right = n36; n24.left = n37; n24.right = n38;
the program should accept position dynamically
Comments
Post a Comment