@Ankur... what ever we are inserting we are inserting at the head of the
list, so its O(1).
we are overriding Enque method with Push().
On Sun, May 26, 2013 at 10:15 AM, Ankur Khurana ankur.kkhur...@gmail.comwrote:
but in this approach , How is Push having O(1) complexity ?
On 25 May 2013
Ravi you r correct. Rope aka Cord.
On Sun, May 26, 2013 at 9:36 AM, Ravi Ranjan ravi.cool2...@gmail.comwrote:
Rope
On Sat, May 25, 2013 at 10:24 PM, Nishant Pandey
nishant.bits.me...@gmail.com wrote:
In one of the interview it was asked, can some one suggest good DS for
this.
Thanks
i feel stack would be good as we undo the last edited item easily in stack,
i have not implemented Rope, if some have implemented Rope, please help me
i am interested in implementing Rope.
On Sun, May 26, 2013 at 4:21 PM, Nitish Raj raj.n...@gmail.com wrote:
Ravi you r correct. Rope aka Cord.
An array is given, first and second half are sorted .. Make the array
sorted inplace... Need an algo better than O(n^2)..
If the length of the array is odd.. middle is either in first half or
second half.
Ex:
1. Arr[] = {2,3,6,8,-5,-2,3,8} -- output : Arr[]={-5,-2,2,3,3,6,8,8};
2. Arr[] =
The solution could be given in this way.
1) In one pass get the end index of both array says e1 and e2.
2) now in next pass compare elements at e1 and e2 .
a) if a(e1) a(e2) swap the elements and then decreament e1 and e2 both.
b) if a(e1) a(e2) decreament e2.
c) if a(e1) == a(e2) then
The first pass is not necessary. We can finding the middle element as
follows:
N = even, Range [ 0 - (N/2 - 1) ] [ N/2 - (N - 1) ]
N = odd,
if (A[N/2] A[N/2 -1]) Range [ 0 - N/2 ] [ (N/2 + 1) - (N
- 1) ]
else if ( A[N/2] A[N/2 + 1]) Range [ 0 - (N/2 - 1) ] [
@DOn can u explain ur first algo, it would be helpful.
On Wed, May 22, 2013 at 7:28 PM, Don dondod...@gmail.com wrote:
My program works with any numbers.
Don
On May 22, 3:45 am, Pramida Tumma pramida.tu...@gmail.com wrote:
This above program works only if the array contains consecutive