pankaj
BAN USERThis is O(nlogn). but it can be modified in such a way that one part of the recursive tree is already sorted and you have again repeat same algo for another part.
for better performance sort longest array(+ve or ve ) and put in recurrence the other array.
eg.
if negative count is smaller
startSearch = 0;
i = first positive index
j = first positive index where it supposed to be
swap(a[i][, a[j]);
if(a[i] < 0){
startSearch = i+1
a[i] = a[i];
}
i = next positive index;
j++;
if(i == first index positive supposed to){
i = startSearch;
}
after this code positive array will be stable in order with only +ve numbers.
repeat same for another array where only negative should be but still not in order. the number in this array is again ve and +ve. use same algo.
thus only one tree computation is happening same as finding nth element in randomized partition.
a[1]>=a[2] && a[n1]<=a[n];
// it means there is a local minima between a[2] to a[n1]
if(a[n/2]<=a[n/2+1])
//it means there is a local minima between a[n/2] ans a[2];
else there is a local minima between a[n/2+1] ans a[n]
now recursively solve it O(lg n) solution;
lets a = pointer to the root node of second BST;
search the place to insert in first BST.
replace the node below the insertion place with this tree.
and a = points to the replaced node.
now i have smaller BST subtree of first BST.
repeat this till there is no node to point.
time o(n), space o(1)
I am reading all post and if i wrong , we just need to find the server which is best fit for a given process. I am doing as follow
array with pair<memory, hardisk>
array2 index of server
sort on hardisk then stable sort on memory
iterate each process and do binary search return which matches best(not necessary exact match) on array
swap that with last
array2 [i] = n;
reduce n (initial length of array) by 1

pankaj
November 20, 2010 Deep jumping in references are not allowed at compile time. In case of
const int a;
int b[a];
one direct reference to the variable. But in case of
const int a[] = {0,1,2};
int b[a[1]];
first 1 store in temporary variable then >used in a[1] >first reference
second b[a[1]] >second reference (depth)
we can create any number of stack in array
for each we maintain two index push index and pop index
create array with following field: just a sudo code
struct arr{
data // value which we want to store in stack
link to previous //index of previous
};
g //1 global index
p1, p2, p3 // index of last push // initialize 1
r1, r2, r3 // index of last pop // initialize all 0
///push/////////////////////
push( n ) // n is stack number in which i want to insert data
v1 , v2, v3 = &sort(r1, r2, r3); //reference of sorted indexes
assign the data value = data
assign previous link = push index of n;
push index of n = v1;
if(v1 == g)g++;
if(v1 != v2)v1 = v2;
else if(v1 != v3)v1 = v2 = v3;
else v1 = v2 = v3 = g;
}
///pop//
pop( n )
int data = data at push index of n
pop index of n = push index of n
push index of n = link to previous at push index of n
return data;

pankaj
November 20, 2010 each path must contain m rows + n cols = m+n;
we can choose these rows and cols in any order. i. e if i represent rows with 1's and cols with 0's then all possible permutation of string gives me the number of possible paths.i. e answer should (m+n)!. but 1 repeat m times and 0 repeat n times so and answer is (m+n)!/(m!*n!)
=(m+n)C n = (m+n)C m
using only one variable i don't think anyone can do it. For iteration to the length of string we need atleast one variable. so here is my thinking.
a = input string
s = 0;
e = n1;
i = 0;
while(i<n){
if 'A' <= a[i] <= 'Z' ans i > s then
swap(a[s], a[i]) //swap using third variable
s++;
else if 'a'<=a[i]<='z' and i < e then
swap(a[i], a[e]);
e;
else i++;
}

pankaj
November 20, 2010
RepIn 2008 I was licensing race cars in Los Angeles, CA. What gets me going now is promoting husband vashikaran ...
geometric median , (4 3 points knows as fermat point )
 pankaj September 29, 2013