dee
BAN USERCan we
a) divide the 3D array into eight quadrants by dividing it across rows, columns and depth. ( 0->row/2->rows ; 0->column/2->column; 0->depth/2->depth)
b) compare the left top and the right bottom of each quadrant with the key value given. For eg: while the first division it will be between a[0][0][0], a[depth/2][row/2][col/2] ).
c) If the key appears to lie in that quadrant, repeat step1
d) Else discard the quadrant.
Can we do the following?
1) build a hash table of size N and hash the numbers already given in the array using the hash function H(x)
2) then generate a random number C=RAND()% ( N-1) +1
3) if H(C) results in a collision in the hash table, handle the collision in some method ( either rehash C or do linear or quadratic probing).
The new number to which C is hashed to, is the required number..
Can we do this?
- dee February 19, 2012minLength = infinity;
minLine = ""
For each line L_i:
{
indx1=substring(L_i,w1)
indx2=substring(L_i,w2)
indx3=substring(L_i,w3)
// indx1,indx2 and indx3 are the indexes where w1, w2 and w3 appear in the line L.
Length = max(indx1,indx2,indx3) - min(indx1,indx2,indx3)
if ( Length < minLength)
minLength = Length;
minLine = i;
}