A pre-order traversal which is used to index the (min,max) pair value at each level except the bottom-most level where all the entries are to be printed. O(n) time O(log n) memory.
On 7/17/11, swetha rahul <[email protected]> wrote: > Sagar , Shubam Maheshwari > Thanks!! > > On Sun, Jul 17, 2011 at 1:11 AM, sagar pareek <[email protected]> wrote: > >> yup :) >> >> >> On Sun, Jul 17, 2011 at 1:03 AM, Shubham Maheshwari < >> [email protected]> wrote: >> >>> according to saagar's algo, it'll be printed ... >>> >>> >>> On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul >>> <[email protected]>wrote: >>> >>>> @Reynald >>>> Will 75 not be included in the tree that u >>>> have given..?? >>>> >>>> >>>> On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek >>>> <[email protected]>wrote: >>>> >>>>> here is the code >>>>> void border(node*); >>>>> void recur(node*); >>>>> >>>>> void border(node *ptr) >>>>> { >>>>> node* tmp; int stack[20],top=0; >>>>> if(tmp=ptr->left) >>>>> { >>>>> while(tmp->left) >>>>> { >>>>> printf("%d ",tmp->data); >>>>> tmp=tmp->left; >>>>> } >>>>> } >>>>> recur(ptr); >>>>> if(tmp=ptr->right) >>>>> { >>>>> while(tmp->right) >>>>> { >>>>> stack[top++]=tmp->data; >>>>> tmp=tmp->right; >>>>> } >>>>> } >>>>> while(top--) printf("%d ",stack[top]); >>>>> printf("%d\n",ptr->data); >>>>> } >>>>> >>>>> void recur(node* ptr) >>>>> { >>>>> if(ptr->left) recur(ptr->left); >>>>> if(!ptr->left&&!ptr->right) printf("%d ",ptr->data); >>>>> if(ptr->right) recur(ptr->right); >>>>> >>>>> } >>>>> >>>>> On Sat, Jul 16, 2011 at 7:07 PM, Reynald >>>>> <[email protected]>wrote: >>>>> >>>>>> Algo to find the border of a given binary tree. Optimized for space >>>>>> and time. >>>>>> Input: >>>>>> 10 >>>>>> / \ >>>>>> 50 50 >>>>>> / \ / \ >>>>>> 25 75 200 20 >>>>>> / \ / / \ >>>>>> 15 35 120 155 250 >>>>>> >>>>>> Output:50 25 15 35 120 155 250 20 150 10 >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Algorithm Geeks" group. >>>>>> To post to this group, send email to [email protected]. >>>>>> To unsubscribe from this group, send email to >>>>>> [email protected]. >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> **Regards >>>>> SAGAR PAREEK >>>>> COMPUTER SCIENCE AND ENGINEERING >>>>> NIT ALLAHABAD >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Algorithm Geeks" group. >>>>> To post to this group, send email to [email protected]. >>>>> To unsubscribe from this group, send email to >>>>> [email protected]. >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups >>>> "Algorithm Geeks" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> >>> >>> -- >>> Shubham Maheshwari >>> ShubZz >>> O.o o.O >>> >>> enJoY ...!!! >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> >> >> -- >> **Regards >> SAGAR PAREEK >> COMPUTER SCIENCE AND ENGINEERING >> NIT ALLAHABAD >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
