## intern

BAN USERFillBuck( int x[], int b1, int b2, int b3, int sum){

if (sum == 0) count ++;

else{

if( x[0] && b1<2) FillBuck(x, b1+1, b2, b3, sum-1);

if( x[1] && b1<3) FillBuck(x, b1, b2+1, b3, sum-1);

if( x[2] && b1<2) FillBuck(x, b1, b2, b3+1, sum-1);

x[0]=0;

if( b1 >0) FillBuck(x, b1-1, b2, b3, sum+1);

x[1]=0;

if( b2 >0) FillBuck(x, b1, b2-1, b3, sum+1);

x[2]=0;

if( b3 >0) FillBuck(x, b1, b2, b3-1, sum+1);

}

}

//FillBuck(x, 0, 0, 0, 3) ; where for i = 1 to 3, x[i]=1;

SumArray(int A[], int B[], int C[], int a, int b, int c){

if ( a== Length(A) || b== Length(B) || c== Length(C) ) return;

if ( A[a] == B[b] + C[c]) print A[a],B[b],C[c];

else{

SumArray(A, B, C, a+1, b, c);

SumArray(A, B, C, a, b+1, c);

SumArray(A, B, C, a, b, c+1);

}

}

// complexity (n^3) - without doing sorting O(1)

// Above algo can be improved to n^2 using memory (n*n)

Subset(char arr[], int k, int count, int size){

if count == size print ith element with X[i] = 1; return;

if k> length(arr) print ith element with X[i] = 1; return; // subset with size less than 'size'

x[k] =1: subset ( arr, k+1, count +1 ,size);

x[k] =0; subset ( arr, k+1, count, size);

}

AvgEqual(int arr[], rem,sum,k){

if(k > = length(arr)) return;

if(rem/(length(arr)-count) == sum/count) {

print i where X[i]=1 // as array 1;

print i where X[i]=0 // as array 2;

return; }

X[k]=1;

AvgEqual(arr, rem-arr[k],sum+arr[k],k+1,count+1);

X[k]=0;

AvgEqual(arr, rem,sum,k+1,count);

}

Since question says "character data", so considering 8-bit data (0-255). For each T1 and T2 we can construct a two hash table with keys from (0 - 255) using inorder(). Now compare the values of both hash tables such that hash value of T1 is always >= T2.

Value of Hash->key is the number of times a character appears in a given tree.

Rep**MariaHobbs**, Consultant at AdobeHi, I am Maria Hobbs from NewYork.Teach career development courses for designated areas. Develop, evaluate and revise course materials ...

Rep**stacimdalton**, Dev Lead at ASAPInfosystemsPvtLtdAt the moment I'm implementing Slinkies in the financial sector. My current pet project is researching break up a ...

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

4.

- intern November 23, 2012Test cases.

( 1 3 5 7 6), ( 1 6 7 5 2). To find median is possible in O(n) time complexity with space complexity O(1)