Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | May 2017 |
Last Sign in: | 300 Weeks Ago, 3 Days Ago |
Questions Answered: | 66690 |
Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
There is an infinite binary tree which has following structure:
3 / \ 6 8 / \ / \ 11 13 15 17 / \ / \ / \ / \ 20 22 24 26 28 30 32 34 ...
This tree has a formula to get each node’s value. Base of the formula is even binary tree which is infinite tree made of even numbers with root node 2.
Root node’s level is 1 and level of its child nodes is 2 and so on.
Based on value of node in even tree and its level; above tree is formed
First line of input contains a number T, which is total number of test cases.
Following T lines contains a number N.
For every test case, output a single line containing either NO, LEFT or RIGHT.
Output NO if the number N is not in the tree.
Output LEFT if the number is in the tree and its left child of its parent node.
Output RIGHT if the number N is in the tree and its right child of its parent node.
Input: 3 39 16 70 Output: RIGHT NO LEFT
Â
For 34, Its in the tree and its right child of 20.
16 is not in the tree, hence output is NO.
70 is left child of 37, so output is LEFT.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll