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

2012-06-18 Thread Abhishek Sharma
In a stack, you can't access any element directly, except the top one.

On Mon, Jun 18, 2012 at 11:33 AM, Rituraj worstcod...@gmail.com wrote:

 My  iterative approach

 /*code in c*/
 #includestdio.h
 int main()
 {
  int stack[]={1,2,3,4,5,6,7,8},top=7;//
  int i,j,temp;

  for(i=1;i=top;i++)
  {
   temp=stack[i];

   for(j=i;j0;j--)
 stack[j]=stack[j-1];

   stack[0]=temp;
  }

  for(i=0;i=top;i++)
printf(%d ,stack[i] );

  return 0;
 }
  /*


 Rituraj
 2nd Yr.
 B.tech CSE
 NIT -Trichy

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/n1OE58e8B7IJ.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



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

2012-06-18 Thread aditya gupta
this is not a stack at all, u have just named it as a stack. for it to be a
stack u should access only the top most element at any point of time!!!

On Mon, Jun 18, 2012 at 11:33 AM, Rituraj worstcod...@gmail.com wrote:

 My  iterative approach

 /*code in c*/
 #includestdio.h
 int main()
 {
  int stack[]={1,2,3,4,5,6,7,8},top=7;//
  int i,j,temp;

  for(i=1;i=top;i++)
  {
   temp=stack[i];

   for(j=i;j0;j--)
 stack[j]=stack[j-1];

   stack[0]=temp;
  }

  for(i=0;i=top;i++)
printf(%d ,stack[i] );

  return 0;
 }
  /*


 Rituraj
 2nd Yr.
 B.tech CSE
 NIT -Trichy

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/n1OE58e8B7IJ.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Aditya Gupta
B.Tech III yr CSE
IITR

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



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

 /*code in c*/
 #includestdio.h
 int main()
 {
  int stack[]={1,2,3,4,5,6,7,8},top=7;//
  int i,j,temp;

  for(i=1;i=top;i++)
  {
   temp=stack[i];

   for(j=i;j0;j--)
 stack[j]=stack[j-1];

   stack[0]=temp;
  }

  for(i=0;i=top;i++)
printf(%d ,stack[i] );

  return 0;
 }
  /*


 Rituraj
 2nd Yr.
 B.tech CSE
 NIT -Trichy

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/n1OE58e8B7IJ.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question : find word in 2D array

2012-06-12 Thread hary rathor
1 search should in using KMP algo so that It can be seacrh in O(n) . let
function is   int KMP(src,trget, searchDirection )
this kmpSearch funtion should be implemented is such a fashion that is
search in both direction.
3. assume that give 2d array name is array

const int row =1;
const int col =1;
const int dig =1;

for(i=0;iM;i++)   //O(n^2)
{

KMP(array,target, row);  //O(n)

KMP(array,target,col ); //O(n)

KMP(array,target, dig );//O(n)

}

result in O(n^2)

but still looking for better solution

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question : string compression

2012-06-08 Thread Ashish Goel
#include stdafx.h
#include iostream
using namespace std;

const int len = 20;
const int maxCount = 127;

int rle(char* pStr, int length, char* pNew) {

if (!pStr) return -1;
if (length 3) return -1;

int i = 0;
int k = 0;
char p1 = pStr[i++];
 char p2 = pStr[i++];
char p3 = pStr[i++];
int pos=0;
 int cCount = 0;
bool verbatim = false;
while ((p3)  (ilength)) {
 if (p1==p2) {
if (p2==p3) {
if (i == k+3) //no vRun
 verbatim = false;//no vRun befor this cRun
if (verbatim)
{
 int vEnd = (i-3)-k;;
pNew[pos++] = vEnd;
for (int t=k;tvEnd;t++) {
 pNew[pos++]=pStr[t];
}
}
 cCount++;
p1 = p2;
p2 = p3;/*not required*/
 p3 = pStr[i++];
continue;
}
 else { //run end or no run at all
if (cCount 0) { //a run
pNew[pos++] = -cCount; ///
 pNew[pos++] = p2;
p1 = p3;
k = i-1; //p3's position
 p2 =  pStr[i++];
if (!p2) break;
p3 = pStr[i++];
 cCount = 0;
}
else { /*aab */
 verbatim = true;
p1 = p2;
p2 = p3;
 p3 =pStr[i++];
}
}
 }
else { //no run
verbatim = true;
 p1 = p2;
p2 = p3;
p3 =pStr[i++];
 }
}
//possible run or no run here
 if (cCount0) {
pNew[pos++] = -cCount;
pNew[pos++] = p2;
 } else {
if (klength) {
pNew[pos++] = length-k-1;
 for (int t=k;tlength;t++) {
pNew[pos++]=pStr[t];
}
 }
}
pNew[pos]='\0';
 return 1;

}
void rleDecode(char *pEnc, char *pDec, char *pOrig)
{
int i = 0;
 int pos =0;
int count ;
char character ;
 do {
count = pEnc[i++];
if (count 0) {
 count = 2-count;
character = pEnc[i++];
for (int j=0;jcount;j++)
 pDec[pos++] = character;
}
else {
 //pNew[pos++]=character;
for (int j=0;jcount;j++) {
pDec[pos++]=pEnc[i++];
 }
}
}while (pEnc[i]);
 pDec[pos]='\0';
for(int i=0;ilen;i++)
if (pOrig[i]!=pDec[i]) cout JERK, do it again!! (: endl;

}


int _tmain(int argc, _TCHAR* argv[])
{
char *pStr = (char *)malloc(sizeof(char)*len);
 pStr = abccdddijkk; //TRY more examples
char *pNew = (char *)malloc(sizeof(char)*len);
 char *pDec = (char *)malloc(sizeof(char)*len);
//rleSimple(pStr,pNew);
rle(pStr,len,pNew);
 rleDecode(pNew, pDec, pStr);
return 0;
}


Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Fri, Jun 8, 2012 at 9:04 AM, Ashish Goel ashg...@gmail.com wrote:



 The idea here is that there will be parts of the stream which actually
 should not be compressed. For example abcdef as well as aa do not need any
 compression. We need to compress only if 3 characters match because for
 compressing two chars we will take up 2 chars so no compression benefit (:

 So we need to keep a pos as a reference to say that here is the position
 in the string i am processing now and do the compress(either verbatim or
 real compress) when 3 same chars are found

 eg

 abcfdgffg: pos is 0 and at index 8 we get to know that there is a run,
 so we should say 8-3+1=6 need to go verbatim so we write 6abcfdg and update
 pos to index 6, and count to 1. Since now run flag is on, we continue till
 we find a triplet mismatch(f==f but f!=g) which happens at g (index
 12)implying an end to a run, therefore now count is 4, we would write 4f
 implying 2+4 times of next char should be expanded. now again pos will be
 set to 12, count to 0 and three same char check should re-begin. This will
 for sure have 2 while loops and a bit comex, and i donot think this is what
 the interviewer should expect one to code. Kindly note that if run is more
 than max length, we need to tweak the writing part too.


 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Thu, Jun 7, 2012 at 7:05 PM, Navin Gupta navin.nit...@gmail.comwrote:

 If abcdef is changed to a1b1c1d1e1f1,
 then we need to allocate memory dynamically.
 Because length is increased,I think this has no practical
 implementation.As abcdef  serves the same purpose.


 On Sunday, 3 June 2012 09:36:25 UTC+5:30, utsav sharma wrote:

 @ashish:-algo given in link wiil fail for abcdef

 @navin:- output of abcdef should be 1a1b1c1d1e1f

 On Sun, May 27, 2012 at 3:24 PM, Ashish Goel ashg...@gmail.com wrote:

 Will fail for the sing having say 257characters all same

 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Sat, May 26, 2012 at 12:26 PM, Navin Gupta 
 navin.nit...@gmail.comwrote:

 This is called Run-Length-Encoding (RLE)  of a string.
 Its purpose is to save space.So in case of abcdef,I think the output
 needed is abcdef (1 is implicit).
 The added benefit is it makes the solution in-place.

 Approach:- (In-place and Linear Time)
 Start from the left of  string  and  PREVIOUS_CHAR = str[0]
 move forward till u match the CURRENT_CHAR with PREVIOUS_CHAR and keep
 count of PREVIOUS_CHAR
 At any point if (PREVIOUS_CHAR!=CURRENT_CHAR)
put the count of prev_char next to the start position of the
 previous character.

 Below is the working code :-
 void torle(char *str)
 {   int i=0,j=0,k=0,cnt=1;
 char cur_char=str[0],num[100];
 while(str[j+1])
 {
 cnt=1;
 while(str[j+1]==cur_char  str[j]!='\0'){
 

Re: [algogeeks] Re: MS question : string compression

2012-06-08 Thread Ashish Goel
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Fri, Jun 8, 2012 at 12:54 PM, Ashish Goel ashg...@gmail.com wrote:

 #include stdafx.h
 #include iostream
 using namespace std;

 const int len = 20;
 const int maxCount = 127;

 int rle(char* pStr, int length, char* pNew) {

 if (!pStr) return -1;
 if (length 3) return -1;

 int i = 0;
 int k = 0;
 char p1 = pStr[i++];
  char p2 = pStr[i++];
 char p3 = pStr[i++];
 int pos=0;
  int cCount = 0;
 bool verbatim = false;
 while ((p3)  (ilength)) {
  if (p1==p2) {
 if (p2==p3) {
 if (i == k+3) //no vRun
  verbatim = false;//no vRun befor this cRun
 if (verbatim)
 {
  int vEnd = (i-3)-k;;
 pNew[pos++] = vEnd;
 for (int t=k;tvEnd;t++) {
  pNew[pos++]=pStr[t];
 }
 }
  cCount++;

if (cCount == maxCount) {
pNew[pos++] = -cCount; ///
 pNew[pos++] = p3;

p1 = pStr[i++];
if (!p1) break;
 k = 0;
p2 =  pStr[i++];
if (!p2) break;
 p3 = pStr[i++];
cCount = 0;
continue;
 } else {

 /*p1 = p2;
  p2 = p3;  //not required*/
  p3 = pStr[i++];
 }
 }
  else { //run end or no run at all
 if (cCount 0) { //a run
 pNew[pos++] = -cCount; ///
  pNew[pos++] = p2;
 p1 = p3;
 k = i-1; //p3's position
  p2 =  pStr[i++];
 if (!p2) break;
 p3 = pStr[i++];
  cCount = 0;
 }
 else { /*aab */
  verbatim = true;
 p1 = p2;
 p2 = p3;
  p3 =pStr[i++];
 }
 }
  }
 else { //no run
 verbatim = true;
  p1 = p2;
 p2 = p3;
 p3 =pStr[i++];
  }
 }
 //possible run or no run here
  if (cCount0) {
 pNew[pos++] = -cCount;
 pNew[pos++] = p2;
  } else {
 if (klength) {
 pNew[pos++] = length-k-1;
  for (int t=k;tlength;t++) {
 pNew[pos++]=pStr[t];
 }
  }
 }
 pNew[pos]='\0';
  return 1;

 }
 void rleDecode(char *pEnc, char *pDec, char *pOrig)
 {
 int i = 0;
  int pos =0;
 int count ;
 char character ;
  do {
 count = pEnc[i++];
 if (count 0) {
  count = 2-count;
 character = pEnc[i++];
 for (int j=0;jcount;j++)
  pDec[pos++] = character;
 }
 else {
  //pNew[pos++]=character;
 for (int j=0;jcount;j++) {
 pDec[pos++]=pEnc[i++];
  }
 }
 }while (pEnc[i]);
  pDec[pos]='\0';
 for(int i=0;ilen;i++)
 if (pOrig[i]!=pDec[i]) cout JERK, do it again!! (: endl;

 }


 int _tmain(int argc, _TCHAR* argv[])
 {
 char *pStr = (char *)malloc(sizeof(char)*len);
  pStr = abccdddijkk; //TRY more examples
 char *pNew = (char *)malloc(sizeof(char)*len);
  char *pDec = (char *)malloc(sizeof(char)*len);
 //rleSimple(pStr,pNew);
 rle(pStr,len,pNew);
  rleDecode(pNew, pDec, pStr);
 return 0;
 }


 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Fri, Jun 8, 2012 at 9:04 AM, Ashish Goel ashg...@gmail.com wrote:



 The idea here is that there will be parts of the stream which actually
 should not be compressed. For example abcdef as well as aa do not need any
 compression. We need to compress only if 3 characters match because for
 compressing two chars we will take up 2 chars so no compression benefit (:

 So we need to keep a pos as a reference to say that here is the position
 in the string i am processing now and do the compress(either verbatim or
 real compress) when 3 same chars are found

 eg

 abcfdgffg: pos is 0 and at index 8 we get to know that there is a
 run, so we should say 8-3+1=6 need to go verbatim so we write 6abcfdg and
 update pos to index 6, and count to 1. Since now run flag is on, we
 continue till we find a triplet mismatch(f==f but f!=g) which happens at g
 (index 12)implying an end to a run, therefore now count is 4, we would
 write 4f implying 2+4 times of next char should be expanded. now again pos
 will be set to 12, count to 0 and three same char check should re-begin.
 This will for sure have 2 while loops and a bit comex, and i donot think
 this is what the interviewer should expect one to code. Kindly note that if
 run is more than max length, we need to tweak the writing part too.


 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Thu, Jun 7, 2012 at 7:05 PM, Navin Gupta navin.nit...@gmail.comwrote:

 If abcdef is changed to a1b1c1d1e1f1,
 then we need to allocate memory dynamically.
 Because length is increased,I think this has no practical
 implementation.As abcdef  serves the same purpose.


 On Sunday, 3 June 2012 09:36:25 UTC+5:30, utsav sharma wrote:

 @ashish:-algo given in link wiil fail for abcdef

 @navin:- output of abcdef should be 1a1b1c1d1e1f

 On Sun, May 27, 2012 at 3:24 PM, Ashish Goel ashg...@gmail.com wrote:

 Will fail for the sing having say 257characters all same

 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Sat, May 26, 2012 at 12:26 PM, Navin Gupta 
 navin.nit...@gmail.comwrote:

 This is called Run-Length-Encoding (RLE)  of a string.
 Its purpose is to save space.So in case of abcdef,I think the output
 needed is abcdef (1 is implicit).
 The added benefit is it makes the solution in-place.

 Approach:- (In-place and Linear 

Re: [algogeeks] Re: MS question : string compression

2012-06-07 Thread Ashish Goel
The idea here is that there will be parts of the stream which actually
should not be compressed. For example abcdef as well as aa do not need any
compression. We need to compress only if 3 characters match because for
compressing two chars we will take up 2 chars so no compression benefit (:

So we need to keep a pos as a reference to say that here is the position in
the string i am processing now and do the compress(either verbatim or real
compress) when 3 same chars are found

eg

abcfdgffg: pos is 0 and at index 8 we get to know that there is a run,
so we should say 8-3+1=6 need to go verbatim so we write 6abcfdg and update
pos to index 6, and count to 1. Since now run flag is on, we continue till
we find a triplet mismatch(f==f but f!=g) which happens at g (index
12)implying an end to a run, therefore now count is 4, we would write 4f
implying 2+4 times of next char should be expanded. now again pos will be
set to 12, count to 0 and three same char check should re-begin. This will
for sure have 2 while loops and a bit comex, and i donot think this is what
the interviewer should expect one to code. Kindly note that if run is more
than max length, we need to tweak the writing part too.


Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Thu, Jun 7, 2012 at 7:05 PM, Navin Gupta navin.nit...@gmail.com wrote:

 If abcdef is changed to a1b1c1d1e1f1,
 then we need to allocate memory dynamically.
 Because length is increased,I think this has no practical
 implementation.As abcdef  serves the same purpose.


 On Sunday, 3 June 2012 09:36:25 UTC+5:30, utsav sharma wrote:

 @ashish:-algo given in link wiil fail for abcdef

 @navin:- output of abcdef should be 1a1b1c1d1e1f

 On Sun, May 27, 2012 at 3:24 PM, Ashish Goel ashg...@gmail.com wrote:

 Will fail for the sing having say 257characters all same

 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Sat, May 26, 2012 at 12:26 PM, Navin Gupta navin.nit...@gmail.comwrote:

 This is called Run-Length-Encoding (RLE)  of a string.
 Its purpose is to save space.So in case of abcdef,I think the output
 needed is abcdef (1 is implicit).
 The added benefit is it makes the solution in-place.

 Approach:- (In-place and Linear Time)
 Start from the left of  string  and  PREVIOUS_CHAR = str[0]
 move forward till u match the CURRENT_CHAR with PREVIOUS_CHAR and keep
 count of PREVIOUS_CHAR
 At any point if (PREVIOUS_CHAR!=CURRENT_CHAR)
put the count of prev_char next to the start position of the
 previous character.

 Below is the working code :-
 void torle(char *str)
 {   int i=0,j=0,k=0,cnt=1;
 char cur_char=str[0],num[100];
 while(str[j+1])
 {
 cnt=1;
 while(str[j+1]==cur_char  str[j]!='\0'){
 j++;
 cnt++;
 }
 str[i++]=cur_char;
 if( cnt9 ){
 itoa(cnt,num);
 k=0;
 while(num[k]) str[i++]=num[k++];
 }
 else if( cnt1  cnt10 )
 str[i++]= cnt+'0';
 j++;
 if(str[j]) cur_char=str[j];
 }
 if(i!=0){
 if(cnt==1)
 str[i++]=cur_char;
 str[i]='\0';

 }
 }


 On Saturday, 26 May 2012 04:32:35 UTC+5:30, utsav sharma wrote:

 Implement a method to perform basic string compression using the
 counts of repeated characters.(inplace)

 eg:- input: aaabcdef
  output:3a5b1c1d1e1f.

 what should be my approach to this problem

 if i calculate the size of array required to store the output string
 and start from the last of the array then i wldn't get the right
 answer of above input case.

 and if start from front then i wldn't get the right answer of this
 input case
 eg:- input: abcdef
  output: 1a1b1c1d1e1f

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To view this discussion on the web visit https://groups.google.com/d/**
 msg/algogeeks/-/4LxWHEUJuK8Jhttps://groups.google.com/d/msg/algogeeks/-/4LxWHEUJuK8J
 .

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to algogeeks+unsubscribe@**
 googlegroups.com algogeeks%2bunsubscr...@googlegroups.com.
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=en http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to algogeeks+unsubscribe@**
 googlegroups.com algogeeks%2bunsubscr...@googlegroups.com.
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=en http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks 

Re: [algogeeks] Re: MS question : string compression

2012-05-27 Thread Ashish Goel
Will fail for the sing having say 257characters all same

Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Sat, May 26, 2012 at 12:26 PM, Navin Gupta navin.nit...@gmail.comwrote:

 This is called Run-Length-Encoding (RLE)  of a string.
 Its purpose is to save space.So in case of abcdef,I think the output
 needed is abcdef (1 is implicit).
 The added benefit is it makes the solution in-place.

 Approach:- (In-place and Linear Time)
 Start from the left of  string  and  PREVIOUS_CHAR = str[0]
 move forward till u match the CURRENT_CHAR with PREVIOUS_CHAR and keep
 count of PREVIOUS_CHAR
 At any point if (PREVIOUS_CHAR!=CURRENT_CHAR)
put the count of prev_char next to the start position of the previous
 character.

 Below is the working code :-
 void torle(char *str)
 {   int i=0,j=0,k=0,cnt=1;
 char cur_char=str[0],num[100];
 while(str[j+1])
 {
 cnt=1;
 while(str[j+1]==cur_char  str[j]!='\0'){
 j++;
 cnt++;
 }
 str[i++]=cur_char;
 if( cnt9 ){
 itoa(cnt,num);
 k=0;
 while(num[k]) str[i++]=num[k++];
 }
 else if( cnt1  cnt10 )
 str[i++]= cnt+'0';
 j++;
 if(str[j]) cur_char=str[j];
 }
 if(i!=0){
 if(cnt==1)
 str[i++]=cur_char;
 str[i]='\0';

 }
 }


 On Saturday, 26 May 2012 04:32:35 UTC+5:30, utsav sharma wrote:

 Implement a method to perform basic string compression using the counts
 of repeated characters.(inplace)

 eg:- input: aaabcdef
  output:3a5b1c1d1e1f.

 what should be my approach to this problem

 if i calculate the size of array required to store the output string
 and start from the last of the array then i wldn't get the right answer
 of above input case.

 and if start from front then i wldn't get the right answer of this input
 case
 eg:- input: abcdef
  output: 1a1b1c1d1e1f

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/4LxWHEUJuK8J.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question : string compression

2012-05-26 Thread Hassan Monfared
u forgot to do inplace and you have wrong conversion of count

On Sat, May 26, 2012 at 11:31 AM, Anchal Gupta anchal92gu...@gmail.comwrote:

 hey, here is the function that do the compression and store the output
 in an array op.


 void str_comp(char *str)
 {
  int count=0,j=0,i;
  char ch,op[100];

  for(i=0;istrlen(str);)
  {
ch = str[i];
while(str[i] == ch)
  { count++;
i++;
  }
 op[j] = count+48;
 op[++j] = ch;
 j++;
 count=0;

   }
   coutinput : ;
   for(i=0;istrlen(str);i++)
coutstr[i];

   cout\n\noutput : ;
   for(i=0;ij;i++)
coutop[i];

  }



 Best Regards
 Anchal Gupta
 USIT(GGSIPU), Delhi
 +91-9015897983




 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question : string compression

2012-05-26 Thread Hassan Monfared
1- try abb

On Sat, May 26, 2012 at 12:07 PM, Anchal Gupta anchal92gu...@gmail.comwrote:

 yeah i forgot inplace so to do that we simply add count and ch in str
 input array instead of op.
 btw whats wrong with count it give me right answer.

 On May 26, 12:08 pm, Hassan Monfared hmonfa...@gmail.com wrote:
  u forgot to do inplace and you have wrong conversion of count
 
  On Sat, May 26, 2012 at 11:31 AM, Anchal Gupta anchal92gu...@gmail.com
 wrote:
 
 
 
 
 
 
 
   hey, here is the function that do the compression and store the output
   in an array op.
 
   void str_comp(char *str)
   {
int count=0,j=0,i;
char ch,op[100];
 
for(i=0;istrlen(str);)
{
  ch = str[i];
  while(str[i] == ch)
{ count++;
  i++;
}
   op[j] = count+48;
   op[++j] = ch;
   j++;
   count=0;
 
 }
 coutinput : ;
 for(i=0;istrlen(str);i++)
  coutstr[i];
 
 cout\n\noutput : ;
 for(i=0;ij;i++)
  coutop[i];
 
}
 
   Best Regards
   Anchal Gupta
   USIT(GGSIPU), Delhi
   +91-9015897983
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question : string compression

2012-05-26 Thread Ashish Goel
http://michael.dipperstein.com/rle/index.html

and basic one is

http://www.fileformat.info/mirror/egff/ch09_03.htm


Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Sat, May 26, 2012 at 1:10 PM, Hassan Monfared hmonfa...@gmail.comwrote:

 1- try abb


 On Sat, May 26, 2012 at 12:07 PM, Anchal Gupta anchal92gu...@gmail.comwrote:

 yeah i forgot inplace so to do that we simply add count and ch in str
 input array instead of op.
 btw whats wrong with count it give me right answer.

 On May 26, 12:08 pm, Hassan Monfared hmonfa...@gmail.com wrote:
  u forgot to do inplace and you have wrong conversion of count
 
  On Sat, May 26, 2012 at 11:31 AM, Anchal Gupta anchal92gu...@gmail.com
 wrote:
 
 
 
 
 
 
 
   hey, here is the function that do the compression and store the output
   in an array op.
 
   void str_comp(char *str)
   {
int count=0,j=0,i;
char ch,op[100];
 
for(i=0;istrlen(str);)
{
  ch = str[i];
  while(str[i] == ch)
{ count++;
  i++;
}
   op[j] = count+48;
   op[++j] = ch;
   j++;
   count=0;
 
 }
 coutinput : ;
 for(i=0;istrlen(str);i++)
  coutstr[i];
 
 cout\n\noutput : ;
 for(i=0;ij;i++)
  coutop[i];
 
}
 
   Best Regards
   Anchal Gupta
   USIT(GGSIPU), Delhi
   +91-9015897983
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-24 Thread Ashish Goel
struct node
{
int data;
struct node *link;
};

node* CreateNode(int val)
{
node* root = (node*)malloc(sizeof(struct node));
root-data = val;
root-link = NULL;
return root;
}

node* createList(int *arr, int n)
{
node * root = CreateNode(arr[0]);
node * temp = root;
for (int i =1; i  n; ++i)
{
temp-link = CreateNode(arr[i]);
temp = temp-link;
}
return root;
}

void deleteList(node *root)
{
if(!root) return;
deleteList(root-link);
free(root);
}

void printList(node *root)
{
while(root)
{
printf(%d - , root-data);
root= root-link;
}
printf(NULL\n);
}

void reverseK(node *root, node **head, node **tail, int i, int K)
{
if(!root-link)
*head = root;
else
{
reverseK(root-link, head, tail, (i+1)%K, K);

if(i == K-1)
{
*tail = *head;
*head = root;
}
else
{
root-link-link= root;
if(i == 0) root-link = *tail;
}
}
}

node* reverseKSize(node *root, int K)
{
if(!root) return NULL;
node *head = NULL;
node *tail = NULL;
reverseK(root, head, tail, 0, K);
return head;
}

int _tmain(int argc, _TCHAR* argv[])
{
int a[11] = {1,2,3,4,5,6,7,8,9,10,11};
node* root = createList(a, 11);
printList(root);
root = reverseKSize(root, 2);
printList(root);
deleteList(root);

return 0;
}

Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Tue, Jan 24, 2012 at 2:30 AM, Lucifer sourabhd2...@gmail.com wrote:

 @above

 attaching the file..

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/YW_phbT3me4J.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-24 Thread atul anand
@Ashish : seems exactly similar to Lucifer code  or you modified something
in his code ?? ...

On Tue, Jan 24, 2012 at 2:02 PM, Ashish Goel ashg...@gmail.com wrote:





 struct node
 {
   int data;
   struct node *link;
 };

 node* CreateNode(int val)
 {
   node* root = (node*)malloc(sizeof(struct node));
   root-data = val;
   root-link = NULL;
   return root;
 }

 node* createList(int *arr, int n)
 {
   node * root = CreateNode(arr[0]);
   node * temp = root;
   for (int i =1; i  n; ++i)
   {
   temp-link = CreateNode(arr[i]);
   temp = temp-link;
   }
   return root;
 }

 void deleteList(node *root)
 {
   if(!root) return;
   deleteList(root-link);
   free(root);
 }

 void printList(node *root)
 {
   while(root)
   {
   printf(%d - , root-data);
   root= root-link;
   }
   printf(NULL\n);
 }

 void reverseK(node *root, node **head, node **tail, int i, int K)
 {
   if(!root-link)
   *head = root;
   else
   {
   reverseK(root-link, head, tail, (i+1)%K, K);
   
   if(i == K-1)
   {
   *tail = *head;
   *head = root;
   }
   else
   {
   root-link-link= root;
   if(i == 0) root-link = *tail;
   }
   }
 }

 node* reverseKSize(node *root, int K)
 {
   if(!root) return NULL;
   node *head = NULL;
   node *tail = NULL;
   reverseK(root, head, tail, 0, K);
   return head;
 }

 int _tmain(int argc, _TCHAR* argv[])
 {
   int a[11] = {1,2,3,4,5,6,7,8,9,10,11};
   node* root = createList(a, 11);
   printList(root);
   root = reverseKSize(root, 2);
   printList(root);
   deleteList(root);

 return 0;
 }

 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652



 On Tue, Jan 24, 2012 at 2:30 AM, Lucifer sourabhd2...@gmail.com wrote:

 @above

 attaching the file..

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/YW_phbT3me4J.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-24 Thread Ashish Goel
oh, a possible mistake from my side, ignore my mail please...

Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Tue, Jan 24, 2012 at 3:08 PM, atul anand atul.87fri...@gmail.com wrote:

 @Ashish : seems exactly similar to Lucifer code  or you modified something
 in his code ?? ...


 On Tue, Jan 24, 2012 at 2:02 PM, Ashish Goel ashg...@gmail.com wrote:





 struct node
 {
  int data;
  struct node *link;
 };

 node* CreateNode(int val)
 {
  node* root = (node*)malloc(sizeof(struct node));
  root-data = val;
  root-link = NULL;
  return root;
 }

 node* createList(int *arr, int n)
 {
  node * root = CreateNode(arr[0]);
  node * temp = root;
  for (int i =1; i  n; ++i)
  {
  temp-link = CreateNode(arr[i]);
  temp = temp-link;
  }
  return root;
 }

 void deleteList(node *root)
 {
  if(!root) return;
  deleteList(root-link);
  free(root);
 }

 void printList(node *root)
 {
  while(root)
  {
  printf(%d - , root-data);
  root= root-link;
  }
  printf(NULL\n);
 }

 void reverseK(node *root, node **head, node **tail, int i, int K)
 {
  if(!root-link)
  *head = root;
  else
  {
  reverseK(root-link, head, tail, (i+1)%K, K);
  
  if(i == K-1)
  {
  *tail = *head;
  *head = root;
  }
  else
  {
  root-link-link= root;
  if(i == 0) root-link = *tail;
  }
  }
 }

 node* reverseKSize(node *root, int K)
 {
  if(!root) return NULL;
  node *head = NULL;
  node *tail = NULL;
  reverseK(root, head, tail, 0, K);
  return head;
 }

 int _tmain(int argc, _TCHAR* argv[])
 {
  int a[11] = {1,2,3,4,5,6,7,8,9,10,11};
  node* root = createList(a, 11);
  printList(root);
  root = reverseKSize(root, 2);
  printList(root);
  deleteList(root);

 return 0;
 }

 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652



 On Tue, Jan 24, 2012 at 2:30 AM, Lucifer sourabhd2...@gmail.com wrote:

 @above

 attaching the file..

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/YW_phbT3me4J.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-24 Thread praveen raj
Steps:
1)Reverse the list ...
2)Now do the swap two nodes... consecutively...

PRAVEEN RAJ
DELHI COLLEGE OF ENGINEERING

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-10-03 Thread shady
search archives :-/

On Mon, Oct 3, 2011 at 11:47 AM, pranav agrawal 
pranav.is.cool.agra...@gmail.com wrote:

 @rahul sharma, i ran this code, it is producing wrong answer :|

 check it,  http://codepad.org/THv1hJq1

 anyone with correct solution?

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/26XU3UBqZ6EJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-10-03 Thread rahul sharma
yeah it is wrong..i have a solution but uses 0(n+m) space.i need it
in 0(n*m) tymand o(1) space

On Mon, Oct 3, 2011 at 11:55 AM, shady sinv...@gmail.com wrote:

 search archives :-/


 On Mon, Oct 3, 2011 at 11:47 AM, pranav agrawal 
 pranav.is.cool.agra...@gmail.com wrote:

 @rahul sharma, i ran this code, it is producing wrong answer :|

 check it,  http://codepad.org/THv1hJq1

 anyone with correct solution?

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/26XU3UBqZ6EJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-10-03 Thread Ashish Goel
keep two var row0 and col0 for checking if there is any 0 in row0flag
/col0flag

now walk over elements from 1,1 to n,m and set corresponding entry in 0th
row /column if you hit a zero.

now walk over zeroth column and rwo and set the complete row/col if a 0 is
there in 0th row/col.

after this based on row0flag/col0flag, set oth col/row values to 0.

Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Mon, Oct 3, 2011 at 12:08 PM, rahul sharma rahul23111...@gmail.comwrote:

 yeah it is wrong..i have a solution but uses 0(n+m) space.i need it
 in 0(n*m) tymand o(1) space


 On Mon, Oct 3, 2011 at 11:55 AM, shady sinv...@gmail.com wrote:

 search archives :-/


 On Mon, Oct 3, 2011 at 11:47 AM, pranav agrawal 
 pranav.is.cool.agra...@gmail.com wrote:

 @rahul sharma, i ran this code, it is producing wrong answer :|

 check it,  http://codepad.org/THv1hJq1

 anyone with correct solution?

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/26XU3UBqZ6EJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-10-03 Thread rahul sharma
@ashish can u give an xample.plz...i have read a lot archives ...but
cant find in 0(1) spaceu using 2 var only...plz give xample...nended
urgent.thnx

On Tue, Oct 4, 2011 at 7:26 AM, Ashish Goel ashg...@gmail.com wrote:

 keep two var row0 and col0 for checking if there is any 0 in row0flag
 /col0flag

 now walk over elements from 1,1 to n,m and set corresponding entry in 0th
 row /column if you hit a zero.

 now walk over zeroth column and rwo and set the complete row/col if a 0 is
 there in 0th row/col.

 after this based on row0flag/col0flag, set oth col/row values to 0.

 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652



 On Mon, Oct 3, 2011 at 12:08 PM, rahul sharma rahul23111...@gmail.comwrote:

 yeah it is wrong..i have a solution but uses 0(n+m) space.i need
 it in 0(n*m) tymand o(1) space


 On Mon, Oct 3, 2011 at 11:55 AM, shady sinv...@gmail.com wrote:

 search archives :-/


 On Mon, Oct 3, 2011 at 11:47 AM, pranav agrawal 
 pranav.is.cool.agra...@gmail.com wrote:

 @rahul sharma, i ran this code, it is producing wrong answer :|

 check it,  http://codepad.org/THv1hJq1

 anyone with correct solution?

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/26XU3UBqZ6EJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-10-03 Thread Ashish Goel
1 1 0 1
0 1 1 1
1 1 1 1
1 1 1 0

row0 is true
col0 is true

for (int i=1; in;i++)
for (int j=1;jm;j++)
if (a[i][j] == 0) {a[i][0]=0; a[0][j]=0;}

now after this
1 1 0 0
0 1 1 1
1 1 1 1
0 1 1 0

for (int i=1; in;i++)
  if (a[i][0] ==0) for (int j=1; jm;j++) a[i][j]=0;
for (int j=1; im;j++)
  if (a[0][j] ==0) for (int i=1; in;i++) a[i][j]=0;

after this
1 1 0 0
0 0 0 0
1 1 0 0
0 0 0 0


because of row0 and col0 vars


final output is
0 0 0 0
0 0 0 0
0 1 0 0
0 0 0 0

Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Tue, Oct 4, 2011 at 7:49 AM, rahul sharma rahul23111...@gmail.comwrote:

 @ashish can u give an xample.plz...i have read a lot archives ...but
 cant find in 0(1) spaceu using 2 var only...plz give xample...nended
 urgent.thnx


 On Tue, Oct 4, 2011 at 7:26 AM, Ashish Goel ashg...@gmail.com wrote:

 keep two var row0 and col0 for checking if there is any 0 in row0flag
 /col0flag

 now walk over elements from 1,1 to n,m and set corresponding entry in 0th
 row /column if you hit a zero.

 now walk over zeroth column and rwo and set the complete row/col if a 0 is
 there in 0th row/col.

 after this based on row0flag/col0flag, set oth col/row values to 0.

 Best Regards
  Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652



 On Mon, Oct 3, 2011 at 12:08 PM, rahul sharma rahul23111...@gmail.comwrote:

 yeah it is wrong..i have a solution but uses 0(n+m) space.i need
 it in 0(n*m) tymand o(1) space


 On Mon, Oct 3, 2011 at 11:55 AM, shady sinv...@gmail.com wrote:

 search archives :-/


 On Mon, Oct 3, 2011 at 11:47 AM, pranav agrawal 
 pranav.is.cool.agra...@gmail.com wrote:

 @rahul sharma, i ran this code, it is producing wrong answer :|

 check it,  http://codepad.org/THv1hJq1

 anyone with correct solution?

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/26XU3UBqZ6EJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-10-03 Thread rahul sharma
row0 and col0 initilayy true coz we have 0 in 0 row???or these r default
values?

On Tue, Oct 4, 2011 at 8:07 AM, Ashish Goel ashg...@gmail.com wrote:

 1 1 0 1
 0 1 1 1
 1 1 1 1
 1 1 1 0

 row0 is true
 col0 is true

 for (int i=1; in;i++)
 for (int j=1;jm;j++)
 if (a[i][j] == 0) {a[i][0]=0; a[0][j]=0;}

 now after this
 1 1 0 0
 0 1 1 1
 1 1 1 1
 0 1 1 0

 for (int i=1; in;i++)
   if (a[i][0] ==0) for (int j=1; jm;j++) a[i][j]=0;
 for (int j=1; im;j++)
   if (a[0][j] ==0) for (int i=1; in;i++) a[i][j]=0;

 after this
 1 1 0 0
 0 0 0 0
 1 1 0 0
 0 0 0 0


 because of row0 and col0 vars


 final output is
 0 0 0 0
 0 0 0 0
 0 1 0 0
 0 0 0 0

 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Tue, Oct 4, 2011 at 7:49 AM, rahul sharma rahul23111...@gmail.comwrote:

 @ashish can u give an xample.plz...i have read a lot archives ...but
 cant find in 0(1) spaceu using 2 var only...plz give xample...nended
 urgent.thnx


 On Tue, Oct 4, 2011 at 7:26 AM, Ashish Goel ashg...@gmail.com wrote:

 keep two var row0 and col0 for checking if there is any 0 in row0flag
 /col0flag

 now walk over elements from 1,1 to n,m and set corresponding entry in 0th
 row /column if you hit a zero.

 now walk over zeroth column and rwo and set the complete row/col if a 0
 is there in 0th row/col.

 after this based on row0flag/col0flag, set oth col/row values to 0.

 Best Regards
  Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652



 On Mon, Oct 3, 2011 at 12:08 PM, rahul sharma 
 rahul23111...@gmail.comwrote:

 yeah it is wrong..i have a solution but uses 0(n+m) space.i need
 it in 0(n*m) tymand o(1) space


 On Mon, Oct 3, 2011 at 11:55 AM, shady sinv...@gmail.com wrote:

 search archives :-/


 On Mon, Oct 3, 2011 at 11:47 AM, pranav agrawal 
 pranav.is.cool.agra...@gmail.com wrote:

 @rahul sharma, i ran this code, it is producing wrong answer :|

 check it,  http://codepad.org/THv1hJq1

 anyone with correct solution?

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/26XU3UBqZ6EJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-10-03 Thread Ashish Goel
0 in 0th row as well as 0 in 0th col and hence true


Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Tue, Oct 4, 2011 at 8:28 AM, rahul sharma rahul23111...@gmail.comwrote:

 row0 and col0 initilayy true coz we have 0 in 0 row???or these r default
 values?


 On Tue, Oct 4, 2011 at 8:07 AM, Ashish Goel ashg...@gmail.com wrote:

 1 1 0 1
 0 1 1 1
 1 1 1 1
 1 1 1 0

 row0 is true
 col0 is true

 for (int i=1; in;i++)
 for (int j=1;jm;j++)
 if (a[i][j] == 0) {a[i][0]=0; a[0][j]=0;}

 now after this
 1 1 0 0
 0 1 1 1
 1 1 1 1
 0 1 1 0

 for (int i=1; in;i++)
   if (a[i][0] ==0) for (int j=1; jm;j++) a[i][j]=0;
 for (int j=1; im;j++)
   if (a[0][j] ==0) for (int i=1; in;i++) a[i][j]=0;

 after this
 1 1 0 0
 0 0 0 0
 1 1 0 0
 0 0 0 0


 because of row0 and col0 vars


 final output is
 0 0 0 0
 0 0 0 0
 0 1 0 0
 0 0 0 0

 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Tue, Oct 4, 2011 at 7:49 AM, rahul sharma rahul23111...@gmail.comwrote:

 @ashish can u give an xample.plz...i have read a lot archives ...but
 cant find in 0(1) spaceu using 2 var only...plz give xample...nended
 urgent.thnx


 On Tue, Oct 4, 2011 at 7:26 AM, Ashish Goel ashg...@gmail.com wrote:

 keep two var row0 and col0 for checking if there is any 0 in row0flag
 /col0flag

 now walk over elements from 1,1 to n,m and set corresponding entry in
 0th row /column if you hit a zero.

 now walk over zeroth column and rwo and set the complete row/col if a 0
 is there in 0th row/col.

 after this based on row0flag/col0flag, set oth col/row values to 0.

 Best Regards
  Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652



 On Mon, Oct 3, 2011 at 12:08 PM, rahul sharma 
 rahul23111...@gmail.comwrote:

 yeah it is wrong..i have a solution but uses 0(n+m) space.i
 need it in 0(n*m) tymand o(1) space


 On Mon, Oct 3, 2011 at 11:55 AM, shady sinv...@gmail.com wrote:

 search archives :-/


 On Mon, Oct 3, 2011 at 11:47 AM, pranav agrawal 
 pranav.is.cool.agra...@gmail.com wrote:

 @rahul sharma, i ran this code, it is producing wrong answer :|

 check it,  http://codepad.org/THv1hJq1

 anyone with correct solution?

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/26XU3UBqZ6EJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, 

Re: [algogeeks] Re: MS question

2011-10-03 Thread rahul sharma
so we shoul d aslo add loop at the top to find only for firrst row and
column the initial values

On Tue, Oct 4, 2011 at 8:30 AM, Ashish Goel ashg...@gmail.com wrote:

 0 in 0th row as well as 0 in 0th col and hence true


 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Tue, Oct 4, 2011 at 8:28 AM, rahul sharma rahul23111...@gmail.comwrote:

 row0 and col0 initilayy true coz we have 0 in 0 row???or these r default
 values?


 On Tue, Oct 4, 2011 at 8:07 AM, Ashish Goel ashg...@gmail.com wrote:

 1 1 0 1
 0 1 1 1
 1 1 1 1
 1 1 1 0

 row0 is true
 col0 is true

 for (int i=1; in;i++)
 for (int j=1;jm;j++)
 if (a[i][j] == 0) {a[i][0]=0; a[0][j]=0;}

 now after this
 1 1 0 0
 0 1 1 1
 1 1 1 1
 0 1 1 0

 for (int i=1; in;i++)
   if (a[i][0] ==0) for (int j=1; jm;j++) a[i][j]=0;
 for (int j=1; im;j++)
   if (a[0][j] ==0) for (int i=1; in;i++) a[i][j]=0;

 after this
 1 1 0 0
 0 0 0 0
 1 1 0 0
 0 0 0 0


 because of row0 and col0 vars


 final output is
 0 0 0 0
 0 0 0 0
 0 1 0 0
 0 0 0 0

 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Tue, Oct 4, 2011 at 7:49 AM, rahul sharma rahul23111...@gmail.comwrote:

 @ashish can u give an xample.plz...i have read a lot archives ...but
 cant find in 0(1) spaceu using 2 var only...plz give xample...nended
 urgent.thnx


 On Tue, Oct 4, 2011 at 7:26 AM, Ashish Goel ashg...@gmail.com wrote:

 keep two var row0 and col0 for checking if there is any 0 in row0flag
 /col0flag

 now walk over elements from 1,1 to n,m and set corresponding entry in
 0th row /column if you hit a zero.

 now walk over zeroth column and rwo and set the complete row/col if a 0
 is there in 0th row/col.

 after this based on row0flag/col0flag, set oth col/row values to 0.

 Best Regards
  Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652



 On Mon, Oct 3, 2011 at 12:08 PM, rahul sharma rahul23111...@gmail.com
  wrote:

 yeah it is wrong..i have a solution but uses 0(n+m) space.i
 need it in 0(n*m) tymand o(1) space


 On Mon, Oct 3, 2011 at 11:55 AM, shady sinv...@gmail.com wrote:

 search archives :-/


 On Mon, Oct 3, 2011 at 11:47 AM, pranav agrawal 
 pranav.is.cool.agra...@gmail.com wrote:

 @rahul sharma, i ran this code, it is producing wrong answer :|

 check it,  http://codepad.org/THv1hJq1

 anyone with correct solution?

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/26XU3UBqZ6EJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this 

Re: [algogeeks] Re: MS question

2011-10-03 Thread rahul sharma
got it..thnx yr

On Tue, Oct 4, 2011 at 8:34 AM, rahul sharma rahul23111...@gmail.comwrote:

 so we shoul d aslo add loop at the top to find only for firrst row and
 column the initial values


 On Tue, Oct 4, 2011 at 8:30 AM, Ashish Goel ashg...@gmail.com wrote:

 0 in 0th row as well as 0 in 0th col and hence true


 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Tue, Oct 4, 2011 at 8:28 AM, rahul sharma rahul23111...@gmail.comwrote:

 row0 and col0 initilayy true coz we have 0 in 0 row???or these r default
 values?


 On Tue, Oct 4, 2011 at 8:07 AM, Ashish Goel ashg...@gmail.com wrote:

 1 1 0 1
 0 1 1 1
 1 1 1 1
 1 1 1 0

 row0 is true
 col0 is true

 for (int i=1; in;i++)
 for (int j=1;jm;j++)
 if (a[i][j] == 0) {a[i][0]=0; a[0][j]=0;}

 now after this
 1 1 0 0
 0 1 1 1
 1 1 1 1
 0 1 1 0

 for (int i=1; in;i++)
   if (a[i][0] ==0) for (int j=1; jm;j++) a[i][j]=0;
 for (int j=1; im;j++)
   if (a[0][j] ==0) for (int i=1; in;i++) a[i][j]=0;

 after this
 1 1 0 0
 0 0 0 0
 1 1 0 0
 0 0 0 0


 because of row0 and col0 vars


 final output is
 0 0 0 0
 0 0 0 0
 0 1 0 0
 0 0 0 0

 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Tue, Oct 4, 2011 at 7:49 AM, rahul sharma 
 rahul23111...@gmail.comwrote:

 @ashish can u give an xample.plz...i have read a lot archives
 ...but cant find in 0(1) spaceu using 2 var only...plz give
 xample...nended urgent.thnx


 On Tue, Oct 4, 2011 at 7:26 AM, Ashish Goel ashg...@gmail.com wrote:

 keep two var row0 and col0 for checking if there is any 0 in row0flag
 /col0flag

 now walk over elements from 1,1 to n,m and set corresponding entry in
 0th row /column if you hit a zero.

 now walk over zeroth column and rwo and set the complete row/col if a
 0 is there in 0th row/col.

 after this based on row0flag/col0flag, set oth col/row values to 0.

 Best Regards
  Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652



 On Mon, Oct 3, 2011 at 12:08 PM, rahul sharma 
 rahul23111...@gmail.com wrote:

 yeah it is wrong..i have a solution but uses 0(n+m) space.i
 need it in 0(n*m) tymand o(1) space


 On Mon, Oct 3, 2011 at 11:55 AM, shady sinv...@gmail.com wrote:

 search archives :-/


 On Mon, Oct 3, 2011 at 11:47 AM, pranav agrawal 
 pranav.is.cool.agra...@gmail.com wrote:

 @rahul sharma, i ran this code, it is producing wrong answer :|

 check it,  http://codepad.org/THv1hJq1

 anyone with correct solution?

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/26XU3UBqZ6EJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more 

Re: [algogeeks] Re: MS Question - Median of a BST without using extra space and in O(n)

2011-09-28 Thread anshu mishra
*@all to median of BST time O(n) space O(1) (modified code of nitin to
get median)


medianBST*(node, n)
  int x = 0;
  *while* hasleftchild(node) *do*
node = node.left
  *do*

x++;
if (x == n/2) return node-val;
*if* (hasrightchild(node)) *then*
  node = node.right
  *while* hasleftchild(node) *do*
node = node.left
*else*

  *while* node.parent ≠ *null* *and* node == node.parent.right *do*
node = node.parent
  node = node.parent
  *while* node ≠ *null*


@dheeraj u

U  can get the number of elements by just traversing the who tree by above
method

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-09-27 Thread Yogesh Yadav
Suppose matrix is

1 0 0 1
1 0 1 0
0 0 0 0

then we traverse the matrix for each 1 we found at a[i][j] , we will check
for i=i to irow and j=j to jcol if that contains any more 1

if it contains 1 in row then we don't make the whole row as 1..we ignore the
row  and same will be for column

if it don't contains any other 1 after that (i,j) location then we make the
whole row as 1.. and same will be for column




i know this is not in O(mn) but i just want to check if my logic is correct
or not...because it can be used somewhere else...

.

On Tue, Sep 27, 2011 at 11:51 AM, Gene gene.ress...@gmail.com wrote:

 If you're given that it's a sparse matrix, then you must assume
 storage is in a sparse matrix data structure to get time less than
 O(mn).

 In fact, if you assume the right data structure, then the operation
 can take O(1) time.

 For example if you say the structure is an array of sets of indices of
 the 1's in each row (so that L(i) is a list that contains j if and
 only if A(i,j) is a 1), then all you have to do is flip a bit saying
 the representation has changed, i.e. lookups will work differently.
 The old lookup is

 A(i,j) = if L(i) contains j then 1 else 0.

 The new lookup will be

 A(i,j) = if L(i) is nonempty or L(j) contains i then 1 else 0

 You'd probably want to store the sets in hash tables so that lookups
 will remain O(1). Other choices might make more sense if A has special
 structure.

 On Sep 26, 6:41 pm, Ankur Garg ankurga...@gmail.com wrote:
  Guys an Update ,
 
  This has been asked in MS by me.. I suggested O(m*n) but they were
 looking
  for a solution in nlogn ( n*n Sparse Matrix ) ..Any idea ...
 
  This post was discussed earlier but every1 came with O(m*n) solution so
  instead of cluttering it ..opened a new One ...
 
 
 
  On Tue, Sep 27, 2011 at 3:06 AM, Gene gene.ress...@gmail.com wrote:
   I assume we don't want to use extra storage.
 
   So one way is this: Go over the matrix and mark the first row with a 1
   and the first column with a 1 for each 1 you find.  Because row and
   column 1 are used for temporary storage in this manner, you must first
   remember whether they contained a 1, then go ahead. With row and
   column 1 holding the necessary marks, you can fill in all the rows and
   columns except them. Finally you can fill in row and column 1 by
   checking the saved values.  It will look something like this.
 
   row0has1 = 0;
   for (j = 0; j  n; j++) if (M(0,j)) { row0has1 = 1; break; }
   col0has1 = 0;
   for (i = 0; i  n; i++) if (M(i,0)) { col0has1 = 1; break; }
   for (i = 1; i  m; i++)
for (j = 1; j  n; j++)
  if (M(i,j)) M(i,0) = M(0,j) = 1;
   for (i = 1; i  m; i++)
for (j = 1; j  n; j++)
  if (M(i,0) || M(0,j)) M(i, j) = 1;
   if (row0has1)
for (j = 0; j  n; j++) M(0,j) = 1;
   if (col0has1)
for (i = 0; i  n; i++) M(i,0) = 1;
 
   Maybe there's a slicker way, but this is O(mn)
 
   On Sep 26, 9:46 pm, Ankur Garg ankurga...@gmail.com wrote:
Saw this question in one of the algo communities.
 
Amazon telephonic interview question on Matrix
Input is a matrix of size n x m of 0's and 1's. eg:
1 0 0 1
0 0 1 0
0 0 0 0
 
If a location has 1; make all the elements of that row and column =
 1. eg
1 1 1 1
1 1 1 1
1 0 1 1
 
Solution should be with Time complexity = O(n*m) and space complexity
 =
   O(1)
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question - Median of a BST without using extra space and in O(n)

2011-09-27 Thread anshu mishra
its not o(n) it is O(max height of tree) :P
i have not seen the constraint.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question - Median of a BST without using extra space and in O(n)

2011-09-27 Thread Dheeraj Sharma
@anshu
can middle element can be found if the no. of nodes are not given...

On Tue, Sep 27, 2011 at 8:34 PM, vikas vikas.rastogi2...@gmail.com wrote:

 a simple one is rabit-tortoise method, and using stackless traversal,
 facing a lot of corner cases in coding this, can someone check this as
 well?

 On Sep 27, 6:41 pm, anshu mishra anshumishra6...@gmail.com wrote:
  its not o(n) it is O(max height of tree) :P
  i have not seen the constraint.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
*Dheeraj Sharma*

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question - Median of a BST without using extra space and in O(n)

2011-09-27 Thread Sanjay Rajpal
Recursion also requires space, so the problem is how to traverse without
extra space.

Once this is done, nothing is left in the problem.
Sanju
:)



On Tue, Sep 27, 2011 at 8:35 AM, Dheeraj Sharma dheerajsharma1...@gmail.com
 wrote:

 @anshu
 can middle element can be found if the no. of nodes are not given...


 On Tue, Sep 27, 2011 at 8:34 PM, vikas vikas.rastogi2...@gmail.comwrote:

 a simple one is rabit-tortoise method, and using stackless traversal,
 facing a lot of corner cases in coding this, can someone check this as
 well?

 On Sep 27, 6:41 pm, anshu mishra anshumishra6...@gmail.com wrote:
  its not o(n) it is O(max height of tree) :P
  i have not seen the constraint.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 *Dheeraj Sharma*



 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question - Median of a BST without using extra space and in O(n)

2011-09-27 Thread Nitin Garg
Do inorder traversal, to find out the total no. of nodes.

Next time, do the inorder traversal but keeping the count of nodes visited
and stop when you visit n/2 nodes.

Non recursive In-order Traversal -

*inorder*(node)
  *while* hasleftchild(node) *do*
node = node.left
  *do*
visit(node)
*if* (hasrightchild(node)) *then*
  node = node.right
  *while* hasleftchild(node) *do*
node = node.left
*else*
  *while* node.parent ≠ *null* *and* node == node.parent.right *do*
node = node.parent
  node = node.parent
  *while* node ≠ *null*

Source: Wikipedia

On Tue, Sep 27, 2011 at 9:13 PM, Sanjay Rajpal srn...@gmail.com wrote:

 Recursion also requires space, so the problem is how to traverse without
 extra space.

 Once this is done, nothing is left in the problem.
 Sanju
 :)



 On Tue, Sep 27, 2011 at 8:35 AM, Dheeraj Sharma 
 dheerajsharma1...@gmail.com wrote:

 @anshu
 can middle element can be found if the no. of nodes are not given...


 On Tue, Sep 27, 2011 at 8:34 PM, vikas vikas.rastogi2...@gmail.comwrote:

 a simple one is rabit-tortoise method, and using stackless traversal,
 facing a lot of corner cases in coding this, can someone check this as
 well?

 On Sep 27, 6:41 pm, anshu mishra anshumishra6...@gmail.com wrote:
  its not o(n) it is O(max height of tree) :P
  i have not seen the constraint.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 *Dheeraj Sharma*



 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question - Median of a BST without using extra space and in O(n)

2011-09-27 Thread Sanjay Rajpal
Since we are given pointer to root node, we can easily find the minimum
element in the tree.

This will be the first node in the inorder traversal, now use method to find
the inorder successor of a each node. Do it iteratively.

Complexity will be O(n log n) and O(n) if tree is skewed.

Correct me if m wrong.
Sanju
:)



On Tue, Sep 27, 2011 at 8:49 AM, Nitin Garg nitin.garg.i...@gmail.comwrote:

 Do inorder traversal, to find out the total no. of nodes.

 Next time, do the inorder traversal but keeping the count of nodes visited
 and stop when you visit n/2 nodes.

 Non recursive In-order Traversal -

 *inorder*(node)
   *while* hasleftchild(node) *do*
 node = node.left
   *do*
 visit(node)
 *if* (hasrightchild(node)) *then*
   node = node.right
   *while* hasleftchild(node) *do*
 node = node.left
 *else*
   *while* node.parent ≠ *null* *and* node == node.parent.right *do*
 node = node.parent
   node = node.parent
   *while* node ≠ *null*

 Source: Wikipedia

   On Tue, Sep 27, 2011 at 9:13 PM, Sanjay Rajpal srn...@gmail.com wrote:

   Recursion also requires space, so the problem is how to traverse
 without extra space.

 Once this is done, nothing is left in the problem.
 Sanju
 :)



 On Tue, Sep 27, 2011 at 8:35 AM, Dheeraj Sharma 
 dheerajsharma1...@gmail.com wrote:

 @anshu
 can middle element can be found if the no. of nodes are not given...


 On Tue, Sep 27, 2011 at 8:34 PM, vikas vikas.rastogi2...@gmail.comwrote:

 a simple one is rabit-tortoise method, and using stackless traversal,
 facing a lot of corner cases in coding this, can someone check this as
 well?

 On Sep 27, 6:41 pm, anshu mishra anshumishra6...@gmail.com wrote:
  its not o(n) it is O(max height of tree) :P
  i have not seen the constraint.

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 *Dheeraj Sharma*



 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


 --
   You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Nitin Garg

 Personality can open doors, but only Character can keep them open

 --
  You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-09-26 Thread Ankur Garg
Guys an Update ,

This has been asked in MS by me.. I suggested O(m*n) but they were looking
for a solution in nlogn ( n*n Sparse Matrix ) ..Any idea ...

This post was discussed earlier but every1 came with O(m*n) solution so
instead of cluttering it ..opened a new One ...



On Tue, Sep 27, 2011 at 3:06 AM, Gene gene.ress...@gmail.com wrote:

 I assume we don't want to use extra storage.

 So one way is this: Go over the matrix and mark the first row with a 1
 and the first column with a 1 for each 1 you find.  Because row and
 column 1 are used for temporary storage in this manner, you must first
 remember whether they contained a 1, then go ahead. With row and
 column 1 holding the necessary marks, you can fill in all the rows and
 columns except them. Finally you can fill in row and column 1 by
 checking the saved values.  It will look something like this.

 row0has1 = 0;
 for (j = 0; j  n; j++) if (M(0,j)) { row0has1 = 1; break; }
 col0has1 = 0;
 for (i = 0; i  n; i++) if (M(i,0)) { col0has1 = 1; break; }
 for (i = 1; i  m; i++)
  for (j = 1; j  n; j++)
if (M(i,j)) M(i,0) = M(0,j) = 1;
 for (i = 1; i  m; i++)
  for (j = 1; j  n; j++)
if (M(i,0) || M(0,j)) M(i, j) = 1;
 if (row0has1)
  for (j = 0; j  n; j++) M(0,j) = 1;
 if (col0has1)
  for (i = 0; i  n; i++) M(i,0) = 1;

 Maybe there's a slicker way, but this is O(mn)

 On Sep 26, 9:46 pm, Ankur Garg ankurga...@gmail.com wrote:
  Saw this question in one of the algo communities.
 
  Amazon telephonic interview question on Matrix
  Input is a matrix of size n x m of 0's and 1's. eg:
  1 0 0 1
  0 0 1 0
  0 0 0 0
 
  If a location has 1; make all the elements of that row and column = 1. eg
  1 1 1 1
  1 1 1 1
  1 0 1 1
 
  Solution should be with Time complexity = O(n*m) and space complexity =
 O(1)

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question

2011-08-25 Thread SANDEEP CHUGH
wat abt doing wid hashing?

On Thu, Aug 25, 2011 at 3:55 PM, vikas vikas.rastogi2...@gmail.com wrote:

 yep, trie needs to be built

 On Aug 24, 10:49 pm, Ankur Garg ankurga...@gmail.com wrote:
  It means when u call that func u get the next word in the document
 
  Regards
  Ankur
 
 
 
 
 
 
 
  On Wed, Aug 24, 2011 at 6:59 PM, vikas vikas.rastogi2...@gmail.com
 wrote:
   what do you mean by a function for finding the next word is given ?
 
   On Aug 22, 1:56 am, Ankur Garg ankurga...@gmail.com wrote:
Question--  Given a document containing some words ...and a
 function
for finding the next word is given .design a code which
 efficiently
search
the word  and find occurrence of it in given document .
 
 -which data structure will be used?
 
 -write  algorithm for implementing
 complexity?
 
Guys any Ideas here .. I think tries can be used but can anyone
explain/suggest/discuss proper implementation /technique to solve
 this
problem
 
Regards
 
Ankur
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question

2011-08-25 Thread nishaanth
ya why not hashing ?

On Thu, Aug 25, 2011 at 3:31 PM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote:

 wat abt doing wid hashing?


 On Thu, Aug 25, 2011 at 3:55 PM, vikas vikas.rastogi2...@gmail.comwrote:

 yep, trie needs to be built

 On Aug 24, 10:49 pm, Ankur Garg ankurga...@gmail.com wrote:
  It means when u call that func u get the next word in the document
 
  Regards
  Ankur
 
 
 
 
 
 
 
  On Wed, Aug 24, 2011 at 6:59 PM, vikas vikas.rastogi2...@gmail.com
 wrote:
   what do you mean by a function for finding the next word is given ?
 
   On Aug 22, 1:56 am, Ankur Garg ankurga...@gmail.com wrote:
Question--  Given a document containing some words ...and a
 function
for finding the next word is given .design a code which
 efficiently
search
the word  and find occurrence of it in given document .
 
 -which data structure will be used?
 
 -write  algorithm for implementing
 complexity?
 
Guys any Ideas here .. I think tries can be used but can anyone
explain/suggest/discuss proper implementation /technique to solve
 this
problem
 
Regards
 
Ankur
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
S.Nishaanth,
Computer Science and engineering,
IIT Madras.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question

2011-08-25 Thread SANDEEP CHUGH
for every word in the document , apply hash funtion..  store the string n
its frequency too..
if we get the same word , then  increment the frequency.

after storing.

whenver we want to search the word , searching in O(1) time , jst applying
hash function again on the word to be searched ..

correct me if i am wrong?


On Thu, Aug 25, 2011 at 7:14 PM, Shrey Choudhary choudharyshre...@gmail.com
 wrote:

 how will we exactly implement hashtables in this? What will be
 appropriate keys? ??

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question

2011-08-25 Thread SANDEEP CHUGH
no ..
question says that  there is a function  that gives the next word in the
document..
this means after hashing one word , we hav to go to another word ... for
this going to next word in the document , we hav already provided wid a
function..

nothing to do wid the occurence

On Thu, Aug 25, 2011 at 7:30 PM, Shrey Choudhary choudharyshre...@gmail.com
 wrote:

 But it says finding the next word and also it's position of
 occurence. If we use frequency..won't position of occurence overlap?

 Am not sure whether I got the question right or not!

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question

2011-08-25 Thread SANDEEP CHUGH
ohh sry my mistake ..  got it

On Thu, Aug 25, 2011 at 7:36 PM, Shrey Choudhary choudharyshre...@gmail.com
 wrote:

 design a code which efficiently  search
 the word  and find occurrence of it in given document


 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question

2011-08-25 Thread SANDEEP CHUGH
@shrey   but its not given in question that we have to return the position
or the occurence in the document.. we hav to only the tell whether the word
is in document..
read
.design a code which efficiently  search the word  and find occurrence of it
in given document .

its nt given that return the position or something like that.

isn't so ??
On Thu, Aug 25, 2011 at 7:38 PM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote:

 ohh sry my mistake ..  got it


 On Thu, Aug 25, 2011 at 7:36 PM, Shrey Choudhary 
 choudharyshre...@gmail.com wrote:

 design a code which efficiently  search
 the word  and find occurrence of it in given document


 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question

2011-08-25 Thread Shrey Choudhary
i made a boo boo

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question

2011-08-24 Thread Ankur Garg
It means when u call that func u get the next word in the document

Regards
Ankur

On Wed, Aug 24, 2011 at 6:59 PM, vikas vikas.rastogi2...@gmail.com wrote:

 what do you mean by a function for finding the next word is given ?

 On Aug 22, 1:56 am, Ankur Garg ankurga...@gmail.com wrote:
  Question--  Given a document containing some words ...and a function
  for finding the next word is given .design a code which efficiently
  search
  the word  and find occurrence of it in given document .
 
   -which data structure will be used?
 
   -write  algorithm for implementing complexity?
 
  Guys any Ideas here .. I think tries can be used but can anyone
  explain/suggest/discuss proper implementation /technique to solve this
  problem
 
  Regards
 
  Ankur

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-08-09 Thread *$*
I guess , it can be done using indexing , with time stamp as key , and frame
pointer as data ..
Please correct me if I am wrong.

On Tue, Aug 9, 2011 at 11:03 PM, Priyanshu priyanshuro...@gmail.com wrote:

 Anyone??

 Regards,
 Priyanshu Gupta


 On Fri, Aug 5, 2011 at 6:09 PM, priyanshu priyanshuro...@gmail.comwrote:

 Give an efficient algorithm  to determine which part of the video
 should be displayed as a thumbnail??


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Thx,
--Gopi

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-08-09 Thread Aditya Virmani
i guess ur qn was how will u decide which frame shud b ur thumbnail...as
after tht, the frame cud be set as a thumbnail which is pretty much an eay
task in windows programming.i think most, dun hav much info abt it though,
thumbnails shud contain more of data; i mean shudnt be unicolour(blank
screen).

On Tue, Aug 9, 2011 at 11:30 PM, *$* gopi.komand...@gmail.com wrote:

 I guess , it can be done using indexing , with time stamp as key , and
 frame pointer as data ..
 Please correct me if I am wrong.


 On Tue, Aug 9, 2011 at 11:03 PM, Priyanshu priyanshuro...@gmail.comwrote:

 Anyone??

 Regards,
 Priyanshu Gupta


 On Fri, Aug 5, 2011 at 6:09 PM, priyanshu priyanshuro...@gmail.comwrote:

 Give an efficient algorithm  to determine which part of the video
 should be displayed as a thumbnail??


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Thx,
 --Gopi


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-08-09 Thread Priyanshu
@gopi.. didnt got you...

@adi.. ya thats what i am talking about...


Regards,
Priyanshu Gupta



On Tue, Aug 9, 2011 at 11:18 AM, Aditya Virmani virmanisadi...@gmail.comwrote:

 i guess ur qn was how will u decide which frame shud b ur thumbnail...as
 after tht, the frame cud be set as a thumbnail which is pretty much an eay
 task in windows programming.i think most, dun hav much info abt it though,
 thumbnails shud contain more of data; i mean shudnt be unicolour(blank
 screen).


 On Tue, Aug 9, 2011 at 11:30 PM, *$* gopi.komand...@gmail.com wrote:

 I guess , it can be done using indexing , with time stamp as key , and
 frame pointer as data ..
 Please correct me if I am wrong.


 On Tue, Aug 9, 2011 at 11:03 PM, Priyanshu priyanshuro...@gmail.comwrote:

 Anyone??

 Regards,
 Priyanshu Gupta


 On Fri, Aug 5, 2011 at 6:09 PM, priyanshu priyanshuro...@gmail.comwrote:

 Give an efficient algorithm  to determine which part of the video
 should be displayed as a thumbnail??


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Thx,
 --Gopi


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-08-09 Thread abhijeet srivastva
Below is a solution -

#include stdio.h
int main(int  argc, char* argv[]){
int i = 0;
char *array = argv[1];
char prev = array[0];
while(array[i]){
int count = 0;
while(prev == array[i]){
i +=1;
count++;
}
printf(%d%c,,count,prev);
prev = array[i];
}
printf(\n);
}

Regards
Abhijeet Srivastva



On Wed, Aug 10, 2011 at 9:04 AM, monish001 monish.gup...@gmail.com wrote:

 Given : ddbbccae
 O/P : 2d4a2b2c1a1e
 What is happening? What algo?

 Thanks and regards
 Monish

 On Aug 9, 5:59 pm, ankit sambyal ankitsamb...@gmail.com wrote:
  Given an array of characters, change the array to something as shown in
 the
  following example.
  Given : ddbbccae
  O/P : 2d4a2b2c1a1e
 
  Do it in the most efficient manner both in terms of time and space ...

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-07-29 Thread vaibhav agarwal
what has palindrome to do with this?

On Mon, Jul 18, 2011 at 1:11 AM, swetha rahul swetharahu...@gmail.comwrote:

 Thanks everyone!!


 On Sun, Jul 17, 2011 at 10:56 PM, ankit sambyal ankitsamb...@gmail.comwrote:

 Check for case senstivity also:
 eg:   Madam and madam both are palindromes.


 Also for clarify with the interviewer whether whitespace and
 punctuation can be ignored.
 eg: is the following string a palindrome or not:
 A man, a plan, a canal, Panama
 And check for this condition accordingly

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-07-29 Thread rajeev bharshetty
Test cases for MSN Search Engine

 1 : Check for auto completion feature  (The auto completion based on the
prefix should provide suggestions for the most searched keyword with that
prefix)
.
 2 : The spelling correction feature which shows as to what the user
actually meant. This should be highly relevant to the input query.

3 : Speed of page searches is done using usually caching the pages , check
for that required speed with various benchmark tests.

4 : then you can test for the protocols , the maximum load the server can
bear by stress testing it.

5 :The results returned usually should be highly relevant  (test for that) ,
the count of results returned should be validated  .

6 : If the search engine supports various languages , then it should be
tested on various languages .

7 :You can test for working of various buttons on the search web page .Test
various links on the page.

8 : Test for the validity of GET or POST requests sent by the search engine
.

9 :Check for validity of links on the results page . check various links are
working or not through a bot.

10 : The Validity of Page rank algorithm used can also be tested for various
search queries.The machine learning object fitted  in search engine should
be tested with various kinds of inputs to make it learn the behavior .

On Fri, Jul 29, 2011 at 11:13 PM, vaibhav agarwal 
vibhu.bitspil...@gmail.com wrote:

 what has palindrome to do with this?


 On Mon, Jul 18, 2011 at 1:11 AM, swetha rahul swetharahu...@gmail.comwrote:

 Thanks everyone!!


 On Sun, Jul 17, 2011 at 10:56 PM, ankit sambyal 
 ankitsamb...@gmail.comwrote:

 Check for case senstivity also:
 eg:   Madam and madam both are palindromes.


 Also for clarify with the interviewer whether whitespace and
 punctuation can be ignored.
 eg: is the following string a palindrome or not:
 A man, a plan, a canal, Panama
 And check for this condition accordingly

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards
Rajeev N B http://www.opensourcemania.co.cc

*Winners Don't do Different things , they do things Differently*

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-07-17 Thread swetha rahul
is this ans sufficient..? any other possible test cases for palindrome ?

On Sun, Jul 17, 2011 at 8:53 PM, Nishant mittal.nishan...@gmail.com wrote:

 1.If string is NULL then it should return 1 i.e. string is palindrome
 2.If there is only one character in string then it is palindrome
 3.If reverse of given string is same as string

 On Jul 17, 8:18 pm, swetha rahul swetharahu...@gmail.com wrote:
  ya got it..thanks...
 
  how abt test cases for program to check whether a given string is
 palindrome
  or not..?
 
  On Sun, Jul 17, 2011 at 8:35 PM, ankit sambyal ankitsamb...@gmail.com
 wrote:
 
   1. If u entered nothing and just pressed search, it should display
 nothing.
   2. If u just entered a space and just pressed search, it should display
   nothing.
   3.Verify the results are really related to give word or not
   4.Check if proper Result is displayed for key word.
   5. Check for the Order of the Result set, whether most relevant
   results are displayed first.
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-07-17 Thread vaibhav agarwal
check for query injection,string like (spaces,nothing) entered.

On Sun, Jul 17, 2011 at 9:04 PM, Dumanshu duman...@gmail.com wrote:

 Well, for the third case, you can elaborate on the implementation. We
 need to compare the first half with the later half. So, in case of
 even no. of characters it splits perfectly and in case of odd number
 of characters, just ignore the middle character.

 On Jul 17, 8:28 pm, swetha rahul swetharahu...@gmail.com wrote:
  is this ans sufficient..? any other possible test cases for palindrome ?
 
 
 
  On Sun, Jul 17, 2011 at 8:53 PM, Nishant mittal.nishan...@gmail.com
 wrote:
   1.If string is NULL then it should return 1 i.e. string is palindrome
   2.If there is only one character in string then it is palindrome
   3.If reverse of given string is same as string
 
   On Jul 17, 8:18 pm, swetha rahul swetharahu...@gmail.com wrote:
ya got it..thanks...
 
how abt test cases for program to check whether a given string is
   palindrome
or not..?
 
On Sun, Jul 17, 2011 at 8:35 PM, ankit sambyal 
 ankitsamb...@gmail.com
   wrote:
 
 1. If u entered nothing and just pressed search, it should display
   nothing.
 2. If u just entered a space and just pressed search, it should
 display
 nothing.
 3.Verify the results are really related to give word or not
 4.Check if proper Result is displayed for key word.
 5. Check for the Order of the Result set, whether most relevant
 results are displayed first.
 
 --
 You received this message because you are subscribed to the Google
   Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
 
  - Show quoted text -

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-07-17 Thread ankit sambyal
Check for case senstivity also:
eg:   Madam and madam both are palindromes.


Also for clarify with the interviewer whether whitespace and
punctuation can be ignored.
eg: is the following string a palindrome or not:
A man, a plan, a canal, Panama
And check for this condition accordingly

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-07-17 Thread swetha rahul
Thanks everyone!!

On Sun, Jul 17, 2011 at 10:56 PM, ankit sambyal ankitsamb...@gmail.comwrote:

 Check for case senstivity also:
 eg:   Madam and madam both are palindromes.


 Also for clarify with the interviewer whether whitespace and
 punctuation can be ignored.
 eg: is the following string a palindrome or not:
 A man, a plan, a canal, Panama
 And check for this condition accordingly

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-06-29 Thread rizwan hudda
@Dave: Think of it again counting sort won't work, If you are just
considering the last character as
the even though key is just last character, the value is the whole string..


On Tue, Jun 28, 2011 at 1:53 PM, juver++ avpostni...@gmail.com wrote:

 List[letter] - linked list of all words with the last character as letter.
 Then iterate over all letters and concatenate lists.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/vK4GhYEHHbUJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Thanks and regards
Rizwan A Hudda
http://sites.google.com/site/rizwanhudda2

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-06-28 Thread Kamakshii Aggarwal
@Dave:can u please explain the second method.

On Mon, Jun 27, 2011 at 11:24 PM, Dave dave_and_da...@juno.com wrote:

 @Nishant: Here are a couple of O(n) alternatives, given that there are
 a limited number of last characters and no requirement to break ties
 in any particular way:

 1. A counting sort.

 2. Form a linked list of entries corresponding to each last character,
 and then merge these lists in collating sequence.

 Dave

 On Jun 27, 3:58 am, Nishant Mittal mittal.nishan...@gmail.com wrote:
  WAP to sort an array of character strings on the basis of last
  character of each string
  eg:- {xxxc , yyya, zzzb} = {yyya , zzzb, xxxc}

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards,
Kamakshi
kamakshi...@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS question

2011-06-28 Thread juver++
List[letter] - linked list of all words with the last character as letter.
Then iterate over all letters and concatenate lists.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/vK4GhYEHHbUJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question

2011-06-14 Thread Divye Kapoor
Good one! That halved the memory requirement. :)

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/N6mbMaJHO64J.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question

2011-06-14 Thread Arpit Sood
i meant if N = { 1, 1, 1, 2, 12}
and M = { 1, 1, 3, 12}
then answer should be = {1, 1, 12}


On Mon, Jun 13, 2011 at 8:06 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 no we can take care of duplicates without any extra memory
 modify 2nd step of my previous solution as follows

 if T[a[i]] is set then this element is there in second array so report this
 element and Reset T[a[i]].

 now no duplicates will be reported. and only 1025 bits will be required.
 any failures ??


 --
 Sunny Aggrawal
 B-Tech IV year,CSI
 Indian Institute Of Technology,Roorkee

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards,
Arpit Sood

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question

2011-06-14 Thread sunny agrawal
Nice Confusion... :)

Consider the following case
A[M] = {1,1,3,12};
B[N] = {1,2,12}

here again i think answer should be {1,1,12} , why are u binding one
occurrence of 1 in array A with one in B.  Question is which elements of
first array is present in second array. so for this case A[0], A[1], A[3]
are present so answer should be still {1,1,12} whether or not it occurs
multiple times in B.

now the question remains is whether to report duplicate entries or not. both
have been handled above with same time and space complexity.

Any Questions are Welcome :)

On Wed, Jun 15, 2011 at 1:08 AM, Arpit Sood soodfi...@gmail.com wrote:

 i meant if N = { 1, 1, 1, 2, 12}
 and M = { 1, 1, 3, 12}
 then answer should be = {1, 1, 12}


 On Mon, Jun 13, 2011 at 8:06 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 no we can take care of duplicates without any extra memory
 modify 2nd step of my previous solution as follows

 if T[a[i]] is set then this element is there in second array so report
 this element and Reset T[a[i]].

 now no duplicates will be reported. and only 1025 bits will be required.
 any failures ??


 --
 Sunny Aggrawal
 B-Tech IV year,CSI
 Indian Institute Of Technology,Roorkee

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards,
 Arpit Sood

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Sunny Aggrawal
B-Tech IV year,CSI
Indian Institute Of Technology,Roorkee

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question

2011-06-13 Thread sunny agrawal
why do we need 2 bits at all ??
i think single bit per table entry will do.
say table is T[1025], and array is A[M]

1. Go through the N sized array and set bit 0 of the hash table entry to 1
if it is present in the first array.
2. Go through the M sized array and if T[a[i]] is set then this element is
there in second array else not.

any cases this can fails??

On Mon, Jun 13, 2011 at 5:28 PM, Divye Kapoor divyekap...@gmail.com wrote:

 Use a hash table of size 1025 with bits per table entry = 2.
 1. Go through the N sized array and set bit 0 of the hash table entry to 1
 if it is present in the first array.
 2. Go through the M sized array and set bit 1 of the hash table entry to 1
 if the element belongs to 0 to 1024.
 3. Go through the hash table and print entries with bit values 11.

 Space usage = O(1), 2050 bits (rounded off to the corresponding nearest
 byte). Time complexity = O(N + M)

 --
 DK

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/xP98wCgLEAwJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Sunny Aggrawal
B-Tech IV year,CSI
Indian Institute Of Technology,Roorkee

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question

2011-06-13 Thread Arpit Sood
we can take care of the duplicate entries, but then that would cost more
space(int), as of now we are working with bool

On Mon, Jun 13, 2011 at 5:51 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 that will report duplicate entries multiple times :(


 On Mon, Jun 13, 2011 at 5:38 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 why do we need 2 bits at all ??
 i think single bit per table entry will do.
 say table is T[1025], and array is A[M]


 1. Go through the N sized array and set bit 0 of the hash table entry to 1
 if it is present in the first array.
 2. Go through the M sized array and if T[a[i]] is set then this element is
 there in second array else not.

 any cases this can fails??

 On Mon, Jun 13, 2011 at 5:28 PM, Divye Kapoor divyekap...@gmail.comwrote:

 Use a hash table of size 1025 with bits per table entry = 2.
 1. Go through the N sized array and set bit 0 of the hash table entry to
 1 if it is present in the first array.
 2. Go through the M sized array and set bit 1 of the hash table entry to
 1 if the element belongs to 0 to 1024.
 3. Go through the hash table and print entries with bit values 11.

 Space usage = O(1), 2050 bits (rounded off to the corresponding nearest
 byte). Time complexity = O(N + M)

 --
 DK

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/xP98wCgLEAwJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Sunny Aggrawal
 B-Tech IV year,CSI
 Indian Institute Of Technology,Roorkee




 --
 Sunny Aggrawal
 B-Tech IV year,CSI
 Indian Institute Of Technology,Roorkee

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards,
Arpit Sood

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MS Question

2011-06-13 Thread sunny agrawal
no we can take care of duplicates without any extra memory
modify 2nd step of my previous solution as follows

if T[a[i]] is set then this element is there in second array so report this
element and Reset T[a[i]].

now no duplicates will be reported. and only 1025 bits will be required.
any failures ??

-- 
Sunny Aggrawal
B-Tech IV year,CSI
Indian Institute Of Technology,Roorkee

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.