Tree top view code problem

codeLink: https://pastebin.com/UTAcY4zM
my code is not producing any output, I am unable to debug it ,please correct it.

@Divya_321 i found two mistakes in your code, i have corrected them and attached the link.

  1. while building the tree, you were not popping from the queue.
  2. while checking for NULL in the top view function, the order of the if condition was not correct. you first have to check for NULL and then for the level. otherwise it will give a segfault.
    https://ide.codingblocks.com/s/184044
1 Like

thank you cleared my doubts :slight_smile: