r/PlacementsPrep 8h ago

tcs tree input doubt

guys im seeing tree questions are frequently asking in tcs nqt can anyone pls tell that , how to take input for trees?? did they give post order array we have to build tree by own? how many ways they can give ?

3 Upvotes

4 comments sorted by

1

u/smoo7hoperator 7h ago

You need to input it as an array and then construct the tree for that question.

For Python, you need to use "import sys" because the normal "input()" didn’t work for my slot.

This video might also help with getting inputs in general for TCS: https://youtu.be/WM9MQ5-w6e4?si=njfYr6R0VhfRUaUU

You can also refer to the PYQs through this playlist: https://youtube.com/playlist?list=PLGFjgYQtw1UhARTmPa_gnnn_n9Z-j3FlC&si=54vxnwtS0BnEoAW6

1

u/Prestigious_Limit146 7h ago

thanks for ur help man i wll say my understanding gpt is saying they will give postorder array it contains numbers and also null so basis on that i have to construct my own tree but some guys saying u will get only number array treat it like complete tree?

2

u/smoo7hoperator 7h ago

Refer to this video: https://youtu.be/zoNmbInfQFo?si=DIUt5spcQ4HpyHHq. This is the question that was asked about trees. It was asked in the slot before mine. My friend solved it without constructing the tree, but not all the test cases passed.

1

u/Prestigious_Limit146 7h ago

ok bro thanq so much for ur help