Code is not producing any output

Please help.My code is not producing any output.Its not even printing tree.
Link:https://ide.codingblocks.com/s/224251

Hello @kv6737,

You can refer to the following video:
link
Also, the output should be in a sorted manner.

Let me know if you still can’t find the error in your code.

Hope, this would help.
Give a like if you are satisfied.

I have used priority queue for sorting.I am not able to get the error.Please help.

Hello @kv6737,

Compilation error:
Your have defined two functions Position() and Search() with return types.
But, there are no return statements at the end of the function.

Segmentation Fault:
Incorrect logic of Search() function.

I have corrected your code for the above two mistakes:


But it will still face three test cases.

Wrong order of the output:
9
1 20 8 4 2 12 10 14 22
2 4 8 10 12 14 20 22 1
1
8 2
Expected Output:
1 2 10 14 22
Your Output:
22 14 10 2 1

Solution:
Rather use set to store the elements instead of the priority queue.

Correct it yourself.

Hope, this would help.
Give a like if you are satisfied.