Re: [algogeeks] Re: MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-18 Thread Prem Nagarajan
I think there is a problem in this solution. U r accessing stack elements from 1 to n in the outer loop. It is not possible. 1st element cannot be accessed without popping first n-1 elements out. On Mon, Jun 18, 2012 at 11:33 AM, Rituraj worstcod...@gmail.com wrote: My iterative approach

Re: [algogeeks] Re: Microsoft question

2012-06-18 Thread Prem Nagarajan
to k min_index = i for j i+1 to n if a[j] a[min_index] min_index = j swap(a[i],a[min_index]) required element : a[k] On Sunday, 17 June 2012 08:13:18 UTC+5:30, Prem Nagarajan wrote: Give an array of unsorted elements, find the kth smallest element in the array

Re: [algogeeks] Re: Can anyone plz explain how we get this output

2012-06-17 Thread Prem Nagarajan
The arguments in printf are evaluated from right to left. first ++a gives 11 , then a is 11 and a++(bcoz postfix) is also 11 But the final value is copied to the prefix argument (++a) and just 'a'. The postfix argument(a++) will retain the value it obtained. On Sat, Jun 16, 2012 at 3:49 PM,

[algogeeks] Microsoft question

2012-06-17 Thread Prem Nagarajan
Give an array of unsorted elements, find the kth smallest element in the array. The expected time complexity is O(n) and no extra memory space should be used. Quickselect algorithm can be used to obtain the solution. Can anyone explain how quickselect works? -- You received this message

Re: [algogeeks] Microsoft question

2012-06-17 Thread Prem Nagarajan
+919985813081 +919966006652 On Sun, Jun 17, 2012 at 8:13 AM, Prem Nagarajan prem.cmna...@gmail.comwrote: Give an array of unsorted elements, find the kth smallest element in the array. The expected time complexity is O(n) and no extra memory space should be used. Quickselect algorithm can

Re: [algogeeks] Precedence or Associativity

2012-06-17 Thread Prem Nagarajan
Short-circuiting On Sun, Jun 17, 2012 at 10:02 PM, rn rnjailamb...@gmail.com wrote: But the precedence of || hence ++j++k should be dealt with first ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web