ok nair so tell me from where u found these questions? On Fri, Aug 19, 2011 at 9:19 PM, jestincobol nair <jestinco...@gmail.com>wrote:
> A binary search tree is defined as follows. > > Each node has a key, a value, a (possibly null) left child, and a > (possibly null) right child. > An ordering is defined on the keys to be stored in the tree. > For a given node nd, the keys of all the nodes in its left subtree are > “before” nd’s key, and the keys of all the nodes in its right subtree are > “after” nd’s key. > The depth of the root node is defined to be 0; the depth of any other > node is 1 more than the depth of its parent. > > How would the next() function of a binary search tree’s iterator be > defined, assuming no changes are made to the tree while the iterator is > active? > > Note: next() should return the value at each node in order of the > corresponding keys; also, assume for each answer that the iterator has been > appropriately initialized before the first call to next(). > > 1. using a queue: > > nd = q.remove() > q.add(nd.leftChild) > a.qdd(nd.rightChild) > return nd.value > > 2. using a stack: > > nd = stk.remove() > stk.add(nd.leftChild) > stk.add(nd.rightChild) > return nd.value > > 3. using a stack: > > nd = stk.remove() > nxt = nd.getRight() > while (null != nxt) { stk.push(nxt); nxt = nxt.getLeft(); } > return nd.value > > > > 1 is correct > > > 2 is correct > > > 3 is correct > > > None of these > > > plz say ur answers for this ?? > > > On Fri, Aug 19, 2011 at 9:18 PM, jestincobol nair > <jestinco...@gmail.com>wrote: > >> @ sagar:no dude !! dese are of not of citrix :) >> >> >> On Fri, Aug 19, 2011 at 9:14 PM, sagar pareek <sagarpar...@gmail.com>wrote: >> >>> @nair >>> Are these questions of CITRIX? >>> >>> coz all these questions i already faced somewhere >>> >>> >>> On Fri, Aug 19, 2011 at 9:12 PM, priya ramesh < >>> love.for.programm...@gmail.com> wrote: >>> >>>> 5th is option 1 sorry >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to algogeeks@googlegroups.com. >>>> To unsubscribe from this group, send email to >>>> algogeeks+unsubscr...@googlegroups.com. >>>> 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 algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.