Re: [algogeeks] Re: microsoft interview

2011-09-26 Thread Ankur Garg
@Teja Bala

U dont need the last line for a[0][0]

else code will be wrong

conside

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

Regards


On Sun, Sep 11, 2011 at 11:56 PM, teja bala pawanjalsa.t...@gmail.comwrote:

 //pseudo code dis  will work for sure.

 for(i=0;irow_count;i++)
 for(j=0;jcolumn_count;j++)
 {
 if (a[i][j] == 1)
 {
 a[i][0] = 1;
 a[0][j] = 1;
 }
 }
 for(i=1;irow_count;i++)
 for(j=1;jcolumn_count;j++)
 {
  if (a[0][j] == 1 || a[i][0] == 1)
  {
   a[i][j] = 1;
  }
 ]
 if (a[0][0] == 1)
 {
 for (i=0;irow_count;i++)
 {
  a[i][0] = 1;
 }
 for (i=0;icolumn_count;i++)
 {
  a[0][i] = 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-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.



[algogeeks] Amazon Question

2011-09-25 Thread Ankur Garg
You are given 2 log files each having 1 billion entries and each entry has a
unique customer id.You need to print the records in two files which are
common.

-- 
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] Amazon Interview Question

2011-09-24 Thread Ankur Garg
void sort012(int a[],int n){
int i = 0, s = 0, last = n-1;
 while(i=last){
   if(a[i] == 0  i!=s)
{
   swap(a[i], a[s]);
   s++;
   }
else if(a[i] == 2  i!=last)
{
   swap(a[i], a[last]);
   last--;
}
else
   i++;
}
}



On Sat, Sep 24, 2011 at 5:13 PM, Ankit Sinha akki12...@gmail.com wrote:

 I think this will do the same: -

 #include stdafx.h
 #include stdlib.h

 void swap(int *a, int start, int end)
 {
int temp;
temp = *(a + start);
*(a + start) = *(a + end);
*(a + end) = temp;
 }

 int _tmain(int argc, _TCHAR* argv[])
 {
int minIndex=0, maxIndex=8;
int i=1;
int a[9] ={1,0,2,1,0,2,0,0,1};
while(imaxIndex)
{
if(a[maxIndex] == 2)
maxIndex--;
if(a[minIndex] == 0)
minIndex++;
if(a[i]  a[maxIndex])
{
swap(a, i, maxIndex);
continue;
}
else  if (a[i]  a[minIndex])
{
swap(a, i, minIndex);
continue;
}
i++;
}
for (i =0 ; i 9; i++)
printf([%d], a[i]);
system(PAUSE);
return 0;
 }
 Please comment.

 Cheers,
 Ankit Sinha

 On Sat, Sep 24, 2011 at 4:10 PM, malay chakrabarti m1234...@gmail.com
 wrote:
  dutch national flag problem :)
 
  On Sat, Sep 24, 2011 at 3:45 PM, Dheeraj Sharma
  dheerajsharma1...@gmail.com wrote:
 
  i think this travels only once ... correct me if am wrong
  #includestdio.h
  #includestring.h
  #define SWAP(a,b,c) (c)=(a),(a)=(b),(b)=(c)
  int main()
  {
  int t,x;
  scanf(%d,t);
  while(t--)
  {
char str[100];
scanf(%s,str);
int i=0,j=0,k=strlen(str)-1;
 
while(str[i]=='0')
i++;
while(str[k]=='2')
k--;
 
j=i;
while(j=k)
{
   if(str[j]=='2')
   {
   SWAP(str[j],str[k],x);
   k--;
   }
 
   if(str[j]=='0')
   {
  SWAP(str[i],str[j],x);
  i++;
  }
if(str[j]!='2')
j++;
  }
 
printf(%s\n,str);
}
  return 0;
  }
 
 
  On Sat, Sep 24, 2011 at 11:39 AM, Yogesh Yadav medu...@gmail.com
 wrote:
 
  we cant traverse the string twice...
 
  if there is an error in my logic then plz tell
 
  my logic is:
  we have to take starting and ending indexes for '0','1','2' like below
 
 0  1 2
  starting_index
  ending_index
 
 
  now suppose our string 102112011
 
  so we start from the left and traverse the whole string
 
  first character ='1'
 
 0  1 2
  starting_index 0
  ending_index  0
 
  next character = '0'
 
 0  1 2
  starting_index 1  0
  ending_index  1  0
 
  ( ending_index0  ending_index1 ) so we swap the numbers according to
  Starting_index not according to Ending_index
  So it will become
 
 0  1 2
  starting_index 0  1
  ending_index  0  1
 
  and string will become 01
 
  next character '2'
 
 0  1 2
  starting_index 0  1 2
  ending_index  0  1 2
 
  (ending_index0ending_index1ending_index2)so ending indexes in
  increasing order...so no need to swap
 
  so string is now 012
 
  next character '1'
 
 
 0  1 2
  starting_index 0  1 2
  ending_index  0  3 2
 
  (ending_index1ending_index2) so we swap the current 1 with starting
  index of 2
  so string will become 0112
 
 0  1 2
  starting_index 0  1 3
  ending_index  0  2 3
 
  next character '1'
 
 0  1 2
  starting_index 0  1 3
  ending_index  0  4 3
 
  (ending_index1ending_index2) so we swap the current 1 with starting
  index of 2
 
  so string will become 01112
 
 0  1 2
  starting_index 0  1 4
  ending_index  0  3 4
 
  next character '2'
 

Re: [algogeeks] Re: Amazon online test

2011-09-24 Thread Ankur Garg
Deoki nandan

In MCQ there were options as well ?? is it ?

Also were questions in MCQ only from  coding or OOPS,DBMS,OS etc also are
part of those ?

Regards


On Sat, Sep 24, 2011 at 6:13 PM, Aamir Khan ak4u2...@gmail.com wrote:

 @shiv  :  Correct Answer should be  : 5C3 X 5 X 4 X3 = 600





 Aamir Khan | 3rd Year  | Computer Science  Engineering | IIT 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.


-- 
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.



[algogeeks] Questions on Graphs

2011-09-22 Thread Ankur Garg
Hi Frnds

Can anybody suggest me some questions typically asked on Graphs .

Couldnt find much in the internet

If some one can share link or few questions on Graphs it will be really
helpful


Thanks in Advance

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.



Re: [algogeeks] Re: Questions on Graphs

2011-09-22 Thread Ankur Garg
Thanks Don :)

On Fri, Sep 23, 2011 at 2:51 AM, Don dondod...@gmail.com wrote:

 Given an undirected graph in which each edge has a capacity, find the
 maximum capacity from node A to node B.

 Given a directed graph where each edge has a cost, find the lowest
 cost path from node A to node B.

 Find the minimal spanning tree of a weighted, connected graph.

 On Sep 22, 2:03 pm, Ankur Garg ankurga...@gmail.com wrote:
  Hi Frnds
 
  Can anybody suggest me some questions typically asked on Graphs .
 
  Couldnt find much in the internet
 
  If some one can share link or few questions on Graphs it will be really
  helpful
 
  Thanks in Advance
 
  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: Directi Questions - needed answers

2011-09-19 Thread Ankur Garg
Q9 -   1 *logn for getting the minimum element ..Normal heap Sort procedure

Q3 -  n+logn-2 comparisions so 51 -2 + log 51


Regards
Ankur

On Mon, Sep 19, 2011 at 7:59 PM, Ashima . ashima.b...@gmail.com wrote:

 m getting  result in 95 matches

 Ashima
 M.Sc.(Tech)Information Systems
 4th year
 BITS Pilani
 Rajasthan




 On Mon, Sep 19, 2011 at 7:07 PM, malay chakrabarti m1234...@gmail.comwrote:

 i have explained :)

 On Sun, Sep 18, 2011 at 11:53 PM, Ashima . ashima.b...@gmail.com wrote:

 @malay: how cm n+logn-2?
 cn u explain the logic ?

 Ashima
 M.Sc.(Tech)Information Systems
  4th year
 BITS Pilani
 Rajasthan




  On Sun, Sep 18, 2011 at 11:07 AM, Ashima . ashima.b...@gmail.comwrote:

 rite! 62.5%

 Ashima
 M.Sc.(Tech)Information Systems
 4th year
 BITS Pilani
 Rajasthan




 On Sat, Sep 17, 2011 at 9:04 PM, malay chakrabarti 
 m1234...@gmail.comwrote:

 create a tournament tree.in each round one value is eliminated to
 obtain in the process the winner or the highest value in n-1 comparisons.
 Then check the queue of the winner which contains log(n) entries of the
 values beaten by the winner which implicitly will contain the runners
 up.Then log(n)-1 comparisons to find the highest among all the losers whom
 the winner had beaten. So all over complexity will be n-1 +log(n) -1 =
 n+log(n)-2. Hp that answers ur query. nice question btw :)


 On Sun, Sep 18, 2011 at 8:02 AM, VIHARRI viharri@gmail.comwrote:

 hey i'm also thinking n + logn -2.. but couldnt able to figure out
 how??? can you please explain the logic

 --
 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: K-LCS

2011-09-19 Thread Ankur Garg
Yes...You cant use suffix trees here...Forget Coding...can anybody even
explain the algo as to how suffix trees or tries can be used here ?



On Tue, Sep 20, 2011 at 12:45 AM, pooja pooja27tan...@gmail.com wrote:

 exactly.. to implement suffix tree was out f my reach atleast during
 the test. even thou i knew dat it ws d correct DS to use. i cudn't
 actlly use it.

 On Sep 19, 11:51 pm, hary rathor harry.rat...@gmail.com wrote:
  can anybody tell about other approach because suffix tree is very thought
 to
  implement at interview or written test time

 --
 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] All valid dictionary words must be found and printed.

2011-09-19 Thread Ankur Garg
nice find bhanu..though i didnt get much :P on first read :D :D

On Tue, Sep 20, 2011 at 4:34 AM, Bhanu Kishore bhanukishor...@gmail.comwrote:

 See this algorithm:
 http://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_algorithm


 --
 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.



[algogeeks] Microsoft Question

2011-09-16 Thread Ankur Garg
 In a matrix of characters, find an string. String can be in any way (all 8
neighbours to be considered)
like find Microsoft in below matrix.

A
C
P
*R
*C*
*X
*S
**O
*P
*C*
V
*O*
V
N
*I*
W
G
*F
**M
*N
Q
A
*T*
I
T

*Any Ideas How to Solve/Approach this problem ?*

-- 
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: algorithm problem

2011-09-16 Thread Ankur Garg
Some typos in my solution  :(
Use a Max heap..

first take the first 10 stations and build a* Max *heap O(10)..Heap contains
distance between 2 stations  . Initial Heap will contain 10 *minimum
*distances
with maximum of those  at the top . Now 11 th comes u compare with the root
of the heap . If its less than that than replace it with the top and run
heapify (O(log10) ) ..keep doing the same . In the end u have 10 stations
with min distance between them

Complexity O(10) + O(log(10)) = O(1) ..Comparision takes constant time

So total complexity O(1)

Regards
Ankur

On Sat, Sep 17, 2011 at 5:00 AM, Dave dave_and_da...@juno.com wrote:

 @Pankaj: Let's number the stations from 0 to 101, where stations 0 and
 101 are the end stations and stations 1 through 100 are the
 intermediate stations. Let a[i], i = 1, 2, ..., 100 be the distance of
 station i from station 0, and finally assume that the a's are
 increasing, i.e., that the stations are presented in order. We want to
 find i[1], i[2], ..., i[10] such that 0 = i[0]  i[1]  i[2]  ... 
 i[10]  i[11] = 101. Given any x, 0  x = a[101] (the distance
 between the end stations), we can find the last station that is within
 x of station 0. Call this station i1. In other words, a[i1] = x but
 a[i1+1]  x. Now find the last station that is within x of station
 i[1] and call it i[2]. Etc until you find the last station that is
 within x of station i10. If you get to station 101 in the process, the
 rest of the i's = 101. This can be done with a linear search in
 O(100), or using 10 binary searches in O(10 log 100). Now the problem
 is to find the smallest x such that I[11] = 101. We can do this with a
 binary search on x. Initialize xmin = a[101]/11 (that would have the
 10 intermediate stations equally spaced) and xmax = a[101] and begin a
 loop. Let x = xmin + (xmax - xmin)/2. If x == xmin or x == xmax,
 break; xmax is the minimax distance between stations and i[1], ...,
 i[10] are the stations. Otherwise, calculate i[1] through i[11] as
 above. If i[11]  101, then x is too small, so set xmin = x and loop.
 If i[11] = 101, then x is too large, so set xmax = x and loop.

 Dave

 On Sep 16, 1:22 pm, pankaj kumar p9047551...@gmail.com wrote:
  You are given two end points ( consider them as two end stations
  at some distance  ) there are 100 stations between these two . Now you
  need to build a train track between these two end points which
  includes only 10 stations and not more than that . Now the objective
  is to find such 10 stations such that the maximum distance between any
  two consecutive stations is minimum .
 
  mine solution is
 
   find all  possible subset of 10 elements and answer is that subset
  for which sum (of distance  between
  consecutive stations )is minimum..
  is it correct or any other 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.



-- 
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: Microsoft Question

2011-09-13 Thread Ankur Garg
But dude are u saying stack will be implemented as a map with
value,priority

and then choose element based on priority ?

regards
Ankur

On Tue, Sep 13, 2011 at 10:16 PM, Ankuj Gupta ankuj2...@gmail.com wrote:


 For stack :- Keep incrementing the priority of each pushed element. So
 the last pushed element will have the greatest priority and the
 element pushed first will have
 lowest priority.
 For queue:- keep decrementing the priority of each inserted element.

 On Sep 13, 1:45 am, Ankur Garg ankurga...@gmail.com wrote:
  How to Implement a Queue with a Priority Queue
  Similarly how woud you implement Stack with Priority Queue

 --
 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: unique no. problem

2011-09-12 Thread Ankur Garg
^+1

On Mon, Sep 12, 2011 at 11:41 PM, Ankuj Gupta ankuj2...@gmail.com wrote:

 Is there any restriction on the input like they are in given range ?

 On Sep 11, 11:10 pm, Neha Singh neha.ndelhi.1...@gmail.com wrote:
  You are given an array that contains integers. The integers content is
 such
  that every integer occurs 3 times in that array leaving one integer that
  appears only once.
  Fastest way to find that single integer
  eg:
  Input: [2,1,4,5,1,4,2,2,4,1]
  Answer: 5
 
  The solution must be of O(n) time and O(1) 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.



[algogeeks] Amazon ques

2011-09-11 Thread Ankur Garg
given an array of size N containing only 0s and 1s return the length of the
maximum sub array containing equal number of 0s and 1s

Give a O(n) solution

It has been asked before in this forum but no one has given a proper
solution so m asking again

May be we need DP here..But what will be the recurrence . I cant get it :(


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.



Re: [algogeeks] Re: Amazon ques

2011-09-11 Thread Ankur Garg
This solution is not in O(n) time :(
Unfortunately interviewer wants O(n) .

On Sun, Sep 11, 2011 at 4:01 PM, Kunal Patil kp101...@gmail.com wrote:

 @Brijesh: +1


 On Sun, Sep 11, 2011 at 2:14 PM, Brijesh brijeshupadhyay...@gmail.comwrote:

  This is the fastest way I can think of to do this, and it is linear to
 the number of intervals there are.

 Let L be your original list of numbers and A be a hash of empty arrays
 where initially A[0] = [0]

 sum = 0
 for i in 0..n
   if L[i] == 0:
 sum--
 A[sum].push(i)
   elif L[i] == 1:
 sum++
 A[sum].push(i)

 Now A is essentially an x y graph of the sum of the sequence (x is the
 index of the list, y is the sum). Every time there are two x values x1 and
 x2 to an y value, you have an interval (x1, x2] where the number of 0s and
 1s is equal.

 There are m(m-1)/2 (arithmetic sum from 1 to m - 1) intervals where the
 sum is 0 in every array M in A where m = M.length

 Using your example to calculate A by hand we use this chart

 L   #   0  1  0  1  0  0  1  1  1  1  0
 A keys  0  -1  0 -1  0 -1 -2 -1  0  1  2  1
 L index-1   0  1  2  3  4  5  6  7  8  9  10

 (I've added a # to represent the start of the list with an key of -1. Also
 removed all the numbers that are not 0 or 1 since they're just distractions)
 A will look like this:

 [-2]-[5]
 [-1]-[0, 2, 4, 6]
 [0]-[-1, 1, 3, 7]
 [1]-[8, 10]
 [2]-[9]

 For any M = [a1, a2, a3, ...], (ai + 1, aj) where j  i will be an
 interval with the same number of 0s as 1s. For example, in [-1]-[0, 2, 4,
 6], the intervals are (1, 2), (1, 4), (1, 6), (3, 4), (3, 6), (5, 6).

 Building the array A is O(n), but printing these intervals from A must be
 done in linear time to the number of intervals. In fact, that could be your
 proof that it is not quite possible to do this in linear time to n because
 it's possible to have more intervals than n and you need at least the number
 of interval iterations to print them all.

 Unless of course you consider building A is enough to find all the
 intervals (since it's obvious from A what the intervals are), then it is
 linear to n

 THis is the solution..go through it, its very easy to understand...
 PS: copied from

 http://stackoverflow.com/questions/6967853/dynamic-programming-can-interval-of-even-1s-and-0s-be-found-in-linear-time





 --
 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/-/wM8Xhc1tUXQJ.

 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: Amazon ques

2011-09-11 Thread Ankur Garg
Yeah :(
U r right dude ...I dont think O(n) solution can exist for this problem


On Sun, Sep 11, 2011 at 4:27 PM, Kunal Patil kp101...@gmail.com wrote:

 As the author correctly mentions it:
 Building the array is O(n) , but printing these intervals must be done in
 linear time to the number of intervals.
 Assuming n means number of elements in the original array
 There are O(n^2) possible intervals, how can you print them in O(n) ???


 On Sun, Sep 11, 2011 at 4:20 PM, Ankur Garg ankurga...@gmail.com wrote:

 This solution is not in O(n) time :(
 Unfortunately interviewer wants O(n) .


 On Sun, Sep 11, 2011 at 4:01 PM, Kunal Patil kp101...@gmail.com wrote:

 @Brijesh: +1


 On Sun, Sep 11, 2011 at 2:14 PM, Brijesh 
 brijeshupadhyay...@gmail.comwrote:

  This is the fastest way I can think of to do this, and it is linear to
 the number of intervals there are.

 Let L be your original list of numbers and A be a hash of empty arrays
 where initially A[0] = [0]

 sum = 0
 for i in 0..n
   if L[i] == 0:
 sum--
 A[sum].push(i)
   elif L[i] == 1:
 sum++
 A[sum].push(i)

 Now A is essentially an x y graph of the sum of the sequence (x is the
 index of the list, y is the sum). Every time there are two x values x1 and
 x2 to an y value, you have an interval (x1, x2] where the number of 0s and
 1s is equal.

 There are m(m-1)/2 (arithmetic sum from 1 to m - 1) intervals where the
 sum is 0 in every array M in A where m = M.length

 Using your example to calculate A by hand we use this chart

 L   #   0  1  0  1  0  0  1  1  1  1  0
 A keys  0  -1  0 -1  0 -1 -2 -1  0  1  2  1
 L index-1   0  1  2  3  4  5  6  7  8  9  10

 (I've added a # to represent the start of the list with an key of -1.
 Also removed all the numbers that are not 0 or 1 since they're just
 distractions) A will look like this:

 [-2]-[5]
 [-1]-[0, 2, 4, 6]
 [0]-[-1, 1, 3, 7]
 [1]-[8, 10]
 [2]-[9]

 For any M = [a1, a2, a3, ...], (ai + 1, aj) where j  i will be an
 interval with the same number of 0s as 1s. For example, in [-1]-[0, 2, 4,
 6], the intervals are (1, 2), (1, 4), (1, 6), (3, 4), (3, 6), (5, 6).

 Building the array A is O(n), but printing these intervals from A must
 be done in linear time to the number of intervals. In fact, that could be
 your proof that it is not quite possible to do this in linear time to n
 because it's possible to have more intervals than n and you need at least
 the number of interval iterations to print them all.

 Unless of course you consider building A is enough to find all the
 intervals (since it's obvious from A what the intervals are), then it is
 linear to n

 THis is the solution..go through it, its very easy to understand...
 PS: copied from

 http://stackoverflow.com/questions/6967853/dynamic-programming-can-interval-of-even-1s-and-0s-be-found-in-linear-time





 --
 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/-/wM8Xhc1tUXQJ.

 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.



Fwd: [algogeeks] Re: MICROSOFT

2011-09-11 Thread Ankur Garg
If its a BST then the rightmost element will be the maximum followed by root
and left node
So we can use recursion

Working Code

struct node* findKthLargest(node* root, int k)
{
  if(root==NULL){
 return NULL;
  }
  struct node* temp;
  temp=findKthLargest(root-right,k);
  k--;
  if(k==0)
 return root;
  if(k0)
  temp=findKthLargest(root-left,k);
  return temp;
}

Regards

Ankur

-- Forwarded message --
From: praveen raj praveen0...@gmail.com
Date: Fri, Sep 9, 2011 at 10:26 AM
Subject: Re: [algogeeks] Re: MICROSOFT
To: algogeeks@googlegroups.com


Through heapsort

k times...
O(klogn)
.

With regards,

Praveen Raj
DCE-IT praveen0...@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.

-- 
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] pattern matching

2011-09-02 Thread Ankur Garg
Use KMP dude if u know it ...Who told not to use it ??

Dont read absurd things from net

Regards
Ankur

On Sat, Sep 3, 2011 at 12:35 AM, Aman Kumar amanas...@gmail.com wrote:

 Hiii

 Friends ,if pattern matching question is asked in the interview , we
 should answer brute force(with some optimization) approach or use
 ADVANCED algorithm like KMP?

 I am very much confused regarding this because in on blog i have read
 that we should not use advanced data structure in interview.


 help me out.

 --
 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.



[algogeeks] How to find median of 2 sorted arrays of different length

2011-09-01 Thread Ankur Garg
Can anybody explain logic ?

-- 
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] URGENT- Software engineers - Java / J2ee...Need LOCALS !!

2011-08-30 Thread Ankur Garg
Hi Tech Coder


Didnt check the details :( ...thanks for your concern man!!

Appreciate it


Thanks
Ankur



On Tue, Aug 30, 2011 at 1:27 AM, tech coder techcoderonw...@gmail.comwrote:

 are u carzy replying such spams and  putting ur resume on public forum


 On Mon, Aug 29, 2011 at 12:52 PM, Ankur Garg ankurga...@gmail.com wrote:

 Hi

 PFA my resume for the below position

 Regards
 Ankur

 On Tue, Aug 30, 2011 at 1:00 AM, katie williams 
 katiewilliams...@gmail.com wrote:

 *URGENT- Software engineers - Java / J2ee!! MAX $45/Hr...Need LOCALS
 (Face to Face Required)*

 -After TS Second round of interviews will be F2F! This position is
 located outside the Philadelphia area and is a long term contract.
 Philadelphia, PA
 Long Term Contract
 **

 *Description:*

 Seeking bright, motivated Software Engineers to work as a member of the
 Java/J2EE-based product engineering teams.

  *Please send all resumes to **ka...@itbrainiac.com*ka...@itbrainiac.com


  Thanks,
 Katie - Staffing Manager
 201-855-4204
 ka...@itbrainiac.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.


  --
 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] Find square root a number

2011-08-30 Thread Ankur Garg
@techcoder

Making an array of 32768 or INT_MAX will make ur compiler cry

Also ur case doesnt handle the scenario where square root is a decimal
number



On Tue, Aug 30, 2011 at 1:35 PM, tech coder techcoderonw...@gmail.comwrote:

 the sqrt of 32 bit number can't be more than 16 bits.

 have an array of 2^16 elemnts wtih elemts 1 2 3 4 5  32768 .

 now apply binary search
 i=a[mid]where mid=(lower+upper)/2

 if(i*i==num)
 i is the sqrt

 increment lower and upper accordingly as we do in binary search

 so order is Olognwhere n=2^16


 On Tue, Aug 30, 2011 at 11:37 AM, Raghavan its...@gmail.com wrote:

 how to design this logic effectively?

 double squareRoot(int num){

 }



 --
 Thanks and Regards,
 Raghavan KL

  --
 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] URGENT- Software engineers - Java / J2ee...Need LOCALS !!

2011-08-29 Thread Ankur Garg
Hi

PFA my resume for the below position

Regards
Ankur

On Tue, Aug 30, 2011 at 1:00 AM, katie williams
katiewilliams...@gmail.comwrote:

 *URGENT- Software engineers - Java / J2ee!! MAX $45/Hr...Need LOCALS (Face
 to Face Required)*

 -After TS Second round of interviews will be F2F! This position is located
 outside the Philadelphia area and is a long term contract.
 Philadelphia, PA
 Long Term Contract
 **

 *Description:*

 Seeking bright, motivated Software Engineers to work as a member of the
 Java/J2EE-based product engineering teams.

  *Please send all resumes to **ka...@itbrainiac.com*ka...@itbrainiac.com


  Thanks,
 Katie - Staffing Manager
 201-855-4204
 ka...@itbrainiac.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.


-- 
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.



AnkurGargResume.doc
Description: MS-Word document


Re: [algogeeks] Re: 2 Binary trees are isomorphic?

2011-08-28 Thread Ankur Garg
cant we just count the no of nodes in each level and compare them with the
second one..

if the numbers are same trees can be said to be isomorphic

On Sun, Aug 28, 2011 at 3:54 AM, Dave dave_and_da...@juno.com wrote:

 @Bugaboo: Use recursion. Assuming

 struct tree_node {
tree_node *left;
tree_node *right;
int data;
 };

 int AreIsomorphic(tree_node tree1, tree_node tree2)
 {
if( tree1 == NULL  tree2 == NULL )
return TRUE; // both trees are null
if( tree1 == NULL || tree2 == NULL)
return FALSE; // one tree is null, the other is not
return AreIsomorphic(tree1-left,tree2-left) 
 AreIsomorphic(tree1-right,tree2-right);
 }

 Dave

 On Aug 27, 12:05 pm, bugaboo bharath.sri...@gmail.com wrote:
  Considering the definition of binary tree isomorphism is the
  following:
  - 2 binary trees are isomorphic if they have the same structure but
  differ just by values.
 
  What is the logic (or pseudo code) for checking if two binary trees
  are isomorphic?

 --
 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: 2 Binary trees are isomorphic?

2011-08-28 Thread Ankur Garg
Daves solution looks cool to me...shud work :)

Nice one Dave :)

Regards
Ankur

On Sun, Aug 28, 2011 at 4:08 PM, Ankur Garg ankurga...@gmail.com wrote:

 cant we just count the no of nodes in each level and compare them with the
 second one..

 if the numbers are same trees can be said to be isomorphic


 On Sun, Aug 28, 2011 at 3:54 AM, Dave dave_and_da...@juno.com wrote:

 @Bugaboo: Use recursion. Assuming

 struct tree_node {
tree_node *left;
tree_node *right;
int data;
 };

 int AreIsomorphic(tree_node tree1, tree_node tree2)
 {
if( tree1 == NULL  tree2 == NULL )
return TRUE; // both trees are null
if( tree1 == NULL || tree2 == NULL)
return FALSE; // one tree is null, the other is not
return AreIsomorphic(tree1-left,tree2-left) 
 AreIsomorphic(tree1-right,tree2-right);
 }

 Dave

 On Aug 27, 12:05 pm, bugaboo bharath.sri...@gmail.com wrote:
  Considering the definition of binary tree isomorphism is the
  following:
  - 2 binary trees are isomorphic if they have the same structure but
  differ just by values.
 
  What is the logic (or pseudo code) for checking if two binary trees
  are isomorphic?

 --
 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.



[algogeeks] amazon ques :Online round

2011-08-25 Thread Ankur Garg
You are given n no. of lines in form of Ax + By = C, basically you are given
A[i], b[i] and C[i] for line i.
Lines are given in a way such that 0 = x[i] = 1 and y[i]  y[i+1] for same
X.
Also, one point (x,y) is given too. Find out the two closest lines to the
point such that the point is between them.
Given: n - no. of lines
a[i] b[i] c[i] - i th line.
X Y - Point
Output
A[i] B[i] C[i]
A[j] B[j] C[j]
such that the point X,Y is between them.

-- 
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: Find the non-duplicate element in sorted array in O(n) time

2011-08-24 Thread Ankur Garg
Hi

The ques explicitly said the elements are in pairs ...But the one given by
sanjay has more than 2 2's ...that question cant be done using bsearch then

On Wed, Aug 24, 2011 at 6:21 PM, Sanjay Rajpal srn...@gmail.com wrote:

 yes this is the only one till now, but i think we can do better also.

 Hope a better solution will be posted by someone soon.

 Sanju
 :)



 On Wed, Aug 24, 2011 at 5:22 AM, Venkat venkataharishan...@gmail.comwrote:

 @Sanju: For your input both above solution wont work...

 Do you ve any soultion for your input??
 For your input Xor all numbers - will give you the result:)
 but its O(n)

 Anyway your input allow everyone to think little wider than Binay
 search.


 Thanks
 Venkat


 On Aug 24, 4:05 pm, Sanjay Rajpal srn...@gmail.com wrote:
  @Venkat : suppose if the array were : 1 2 2 2 2 2 2 2 2 2 2, would ur
  solution work ?
 
  Sanju
  :)
 
  On Wed, Aug 24, 2011 at 3:58 AM, Ankit Minglani 
 ankit.mingl...@gmail.comwrote:
 
 
 
 
 
 
 
   How about this :
   We use a divide and conquer approach and since the array is sorted.
   We find the middle element and check its value with its immediate left
 and
   right element .. it must match with anyone of them ..
 
   if it doesnt we have found such a element . and otherwise we divide
 the
   array again ..
   and then again find the middle element .. to check the same condition
 ..
 
   This will take O(lg n ) time :)
 
   On Wed, Aug 24, 2011 at 3:45 PM, Venkat venkataharishan...@gmail.com
 wrote:
 
we can solve this with the help of  binary search.
 
   we know N, which is odd(because of one pair missing)
 
   We divide it array. Let consider your input { 1,1,2,2,2,2,3,3,4,5,5}
 
   int find_culprit(int[] array, int start, int end)
   {
   if(end==start)
   return -1;
 
   int mid=((end-start) / 2) + start;
   if array[mid] == array[mid-1]
return find_culprit(mid,end)
   if(array[mid] == array [mid +1]
return find_culprit(start, mid);
   else
   return array[mid];
   }
 
   Run through:
   Steps1: find_culprit(array,0,8)
   mid=4
   Step 2 : find_culprit(array,4,8))
   mid=6
   step 3 : find_culprit(array,6,8))
   mid=7
   return array[7]=4 (which dont have pair)
 
   Run time O(log n+1) = O(log n)
 
   Please ask if you ve any doubts.
 
   Regards
   Venkat.
 
   On Aug 24, 2:49 pm, atul purohit gonewiththe...@gmail.com wrote:
Hi,
 
A* sorted *integer array contains elements in pairs. All the pairs
 are
complete except one element whose pair is missing. Find that
 element.
 
Ex.   { 1,1,2,2,2,2,3,3,4,5,5}
 result = 5
 
There is a standard solution which returns an XOR of all the
 elements.
   But
this needs O(n) time complexity. The person who asked me this
 question
   said
that this can be done in  O(n). Maybe we can eliminate some
 elements.
Anyone knows how to do this?
 
Cheers,
Atul
 
   --
   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.
 
   --
   The more you sweat in the field, the less you bleed in war.
 
   Ankit Minglani
   NITK Surathkal
 
   --
   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.



[algogeeks] Citrix C Question

2011-08-24 Thread Ankur Garg
Hi

Suppose there is a program

int main(){
printf(%t,main());
   sleep(1000);
  return 0;
}

The above program is run from 100 different windows

What will be the output

Will there be any pattern

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.



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] Remove all Duplicates Words

2011-08-24 Thread Ankur Garg
Both of these methods will require extra ,memory

On Wed, Aug 24, 2011 at 9:42 PM, Anup Ghatage ghat...@gmail.com wrote:

 How about this,
 We compare the first character with every character except the characters
 in the word itself, if there is a hit, it might be a word which is a
 duplicate.
 So from there on, compare each of the following characters till there is a
 white space or new line character.
 If there is no match, skip all the next characters and start with the next
 word's first character, but search only from that index to n.
 if there is a complete match, shift all the characters following the
 duplicate to the duplicates position.

 Finding the same first characters: O(n)
 Finding if they are duplicates: O(n)

  --
 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] Citrix C Question

2011-08-24 Thread Ankur Garg
I dont think it will be error, U r passing main function as reference so it
will print some address ..

The only concern is when u execute this 100 or more times will there be some
pattern in the answer ?

Regards
Ankur

On Thu, Aug 25, 2011 at 1:41 AM, prasanth n nprasnt...@gmail.com wrote:

 @ankur:

 i think its error..l value required

 On Wed, Aug 24, 2011 at 11:18 PM, Ankur Garg ankurga...@gmail.com wrote:

 Hi

 Suppose there is a program

 int main(){
 printf(%t,main());
sleep(1000);
   return 0;
 }

 The above program is run from 100 different windows

 What will be the output

 Will there be any pattern

 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.




 --
 *prasanth*

 --
 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: Doublly link list

2011-08-24 Thread Ankur Garg
http://en.wikipedia.org/wiki/XOR_linked_list

Check this...will be handy

On Thu, Aug 25, 2011 at 2:12 AM, Mohit kumar lal kumarmohit...@gmail.comwrote:

 it might cause STACK OVERFLOW for larger size of lists.


 On Thu, Aug 25, 2011 at 2:04 AM, Abhishek 
 mailatabhishekgu...@gmail.comwrote:

 in brief,
 in the next pointer put the XOR value of previous and next block address.
 when you want to access the previous node just do the XOR operation with
 next block address
 and for next node do the XOR operation with previous block address.
 it will require an extra variable to maintain either previous node address
 or next node address.

  --
 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/-/c9ibogMmpkMJ.

 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.




 --
 Mohit kumar lal
 rit2009014
 IIIT ALLAHABAD
 contact@9454681805
 kumarmohit...@gmail.com
 mohitkumar...@yahoo.com
 rit2009...@iiita.ac.in
 http://profile.iiita.ac.in/rit2009014

  --
 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.



[algogeeks] Amazon Ques

2011-08-22 Thread Ankur Garg
Find the middle of the stack..(Time complexity should be minimum)


Stack is not implemented as Linked List ...u have normal stack with push,pop
and top

How to do this ??

-- 
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] Mentor Graphics Help !!

2011-08-22 Thread Ankur Garg
Also to add,

If you post profile in their portal no reply comes...How to apply ...can any
one here refer my candidature for Mentor Graphics ..I have 2 yrs work ex
working with IBM ISL

Regards
Ankur

On Mon, Aug 22, 2011 at 7:23 PM, Mangal Dass mangaldass1...@gmail.comwrote:

 Anybody pls tell me the questions coming into Information-Mosaic campus
 test.
 Pls tell me both the pattern as well as questions whatever u r remembered.

 Thanks a lot,

 On 8/22/11, sourabh jakhar sourabhjak...@gmail.com wrote:
  i also want to know abt the off campus recruitment  of mentor graphics
  On Mon, Aug 22, 2011 at 6:49 PM, Decipher ankurseth...@gmail.com
 wrote:
 
  Can anyone tell me the interview procedure of Mentor Graphics along with
  some interview questions ??
 
  --
  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/-/NiJZzcypKH0J.
  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.
 
 
 
 
  --
  SOURABH JAKHAR,(CSE)(Final year)
  ROOM NO 167 ,
  TILAK,HOSTEL
  'MNNIT ALLAHABAD
 
  The Law of Win says, Let's not do it your way or my way; let's do it the
  best way.
 
  --
  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] Microsoft :)

2011-08-21 Thread Ankur Garg
@Harsha

Bro I am unable to read ur blog ..It says this

http://harshal-theone.blogspot.com/

It doesn't look like you have been invited to read this blog. If you think
this is a mistake, you might want to contact the blog author and request an
invitation.

Is there anything I need to do to view this blog of urs man !

Regards

Ankur

On Sun, Aug 21, 2011 at 1:54 PM, Vijay Khandar vijaykhand...@gmail.comwrote:

 Congrates Harshal!!

 On Sat, Aug 6, 2011 at 12:15 PM, Harshal hc4...@gmail.com wrote:

 Algogeeks is really awesome and very informative. I got a job in
 microsoft, and this group has played vital role in building concepts. So I
 just want to thank this group and the people here..
 keep it up guys! All the best :)


 --
 Best Regards,
 Harshal Choudhary
 7th Semester, CSE Dept.
 NIT Surathkal, India.
 The road to knowledge runs through the land of confusion.

 Mobile: +91 9844667142
 Email : hc4...@gmail.com
  http://www.facebook.com/profile.php?id=1518764305 
 https://twitter.com/#!/harshal4342
   http://www.linkedin.com/pub/harshal-choudhary/17/731/291 
 http://kkoolharshal.blogspot.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.


  --
 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.



[algogeeks] MS Question

2011-08-21 Thread Ankur Garg
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.



[algogeeks] Can We Use STL like Vectors,Maps,Stack Queues to solve problems in Interviews

2011-08-20 Thread Ankur Garg
One of my frnds was saying its not recommended to  be Used

Please suggest

-- 
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: Urgent...plz help

2011-08-18 Thread Ankur Garg
U can use selection Algorithm to achieve the same ...it has got expected
running time complexity as O(n) ...Read Wikipedia to see the proper
implementation..

Just some tweak with Quick Sort ..Also there is one method median of medians
one which has worst case complexity as O(n)

Regards

Ankur

On Wed, Aug 17, 2011 at 11:47 PM, Amol Sharma amolsharm...@gmail.comwrote:

 it will be max heap only.in which root denotes the largest number in
 your set of 100 smallest
 --


 Amol Sharma
 Third Year Student
 Computer Science and Engineering
 MNNIT Allahabad




 On Thu, Aug 18, 2011 at 9:14 AM, aditi garg aditi.garg.6...@gmail.comwrote:

 @ dave : i hv one doubt,we wud be maintaining a max or a min heap??


 On Thu, Aug 18, 2011 at 9:11 AM, aditi garg aditi.garg.6...@gmail.comwrote:

 thank u so much dave :)


 On Thu, Aug 18, 2011 at 8:44 AM, Dave dave_and_da...@juno.com wrote:

 @Aditi: Form a max-heap of the first 100 numbers. Then as you read the
 remaining numbers, if a number is less than the root of the max-heap,
 replace the root with it and restore the heap condition. When you
 reach the end of the million numbers, the heap will contain the
 smallest 100 numbers.

 If there are n numbers and you want the smallest k, this algorithm is
 O(n log k).

 Dave

 On Aug 17, 10:05 pm, aditi garg aditi.garg.6...@gmail.com wrote:
  How to find the set of smallest 100 numbers out of 1 million
 numbers...

 --
 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.




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi





 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi


  --
 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.



[algogeeks] Amazon Question

2011-08-18 Thread Ankur Garg
Define a data structure , using extra memory/space , such that :

Insert(int a)
Delete(int a)
isPresent(int a)
get(int a)

All above operations on the defined data structure take O(1) , i.e. constant
time.


Any suggestions /solutions for 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.



Re: [algogeeks] Amazon Question

2011-08-18 Thread Ankur Garg
Can u provide a bit detail bro !!

On Thu, Aug 18, 2011 at 8:04 AM, sagar pareek sagarpar...@gmail.com wrote:

 Hashing
 :)

 On Thu, Aug 18, 2011 at 5:30 PM, Ankur Garg ankurga...@gmail.com wrote:

 Define a data structure , using extra memory/space , such that :

 Insert(int a)
 Delete(int a)
 isPresent(int a)
 get(int a)

 All above operations on the defined data structure take O(1) , i.e.
 constant time.


 Any suggestions /solutions for 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.




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

  --
 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.



[algogeeks] Possible solutions to these sort of Questions

2011-08-17 Thread Ankur Garg
Write test cases for WordPad,Notepad

In general while writing test cases for problems what parameters should one
Consider. MS has a habit of asking these sort of questions on a regular
basis


Please help as i cant think much on how to attack ques like these

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.



[algogeeks] Can anybody provide source code or suggest how to write one for median of median algo

2011-08-17 Thread Ankur Garg
I found it a bit tough..Can anyone suggest code for it

-- 
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: How to solve this problem

2011-08-15 Thread Ankur Garg
@Dave

Dude can u provide a sample code...What do u mean by radix n ..also radix
sort requires some other sorting algo to sort digits

Regards
Ankur

On Sun, Aug 14, 2011 at 1:33 PM, Dave dave_and_da...@juno.com wrote:

 @Ankur: Use a radix sort with radix n. It will take 3 passes to sort
 the 3 base-n digits, each of O(n), so the overall order will be O(n).

 On Aug 14, 10:08 am, Ankur Garg ankurga...@gmail.com wrote:
  This is one question from Coreman
 
  3rd Edition -
 
  8-3-4 --  Sort n integers in the range 0 to n^3 -1 in O(n) time
 
  Any ideas how to do this in O(n)

 --
 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.



[algogeeks] How to solve this problem

2011-08-14 Thread Ankur Garg
This is one question from Coreman

3rd Edition -

8-3-4 --  Sort n integers in the range 0 to n^3 -1 in O(n) time


Any ideas how to do this in O(n)

-- 
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] Memory Leak

2011-08-14 Thread Ankur Garg
Where ever u have allocated dynamic memory that qualifies to be a culprit
for causing memory leak ...Scan through the code if the memory block has
been deallocated or not ...


Regards
Ankur

On Sun, Aug 14, 2011 at 6:03 PM, SAMMM somnath.nit...@gmail.com wrote:

 How to detect in which line the Memory Leak has occured ?? I want the
 line number where the Memory leak occurs ??? Give every wild answer u
 can think off 

 --
 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: Amazon question.

2011-08-12 Thread Ankur Garg
@Dave

How is the complexity O(n^2logn) .. Can you please tell

I believe there cant be solution better than O(n^2) unless u use FFT which
again is out of scope , at least for me :)

Regards
Ankur

2011/8/11 Samba Ganapavarapu sambasiv...@gmail.com

 Can we find any alg. which runs faster than O(n^2) using these 2 axioms ?


 2011/8/10 Amethy hobby news...@gmail.com

 it also like Pythagorean theorem;
 so the a[k] also with the value where
 a[j]-a[i]a[k]a[i]+a[j]
 and a[k]a[j]=a[i];

 On 8月9日, 下午10时43分, Samba Ganapavarapu sambasiv...@gmail.com wrote:
  We have an array of integers, we need to find the element a[i],a[j] and
 a[k]
  values where.. a[i]^2 + a[k]^2 = a[k] ^2
  what would be the fast algorithm to find ?
 
  - Samba

 --
 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] Design .. how to attack ???

2011-08-12 Thread Ankur Garg
+1..me too need answers for this



On Fri, Aug 12, 2011 at 11:39 AM, MAC macatad...@gmail.com wrote:

 if someone  can share one good solution , it would really help me. I am
 unable to form the answer to these questions

 --mac


 On Fri, Aug 12, 2011 at 1:15 PM, MAC macatad...@gmail.com wrote:

 thanks guys .. so lets take the question we had  design a car rental
 system   .. so the interviewer can say , ok requirement is that you have a
 pool of cars , people come and book a car for a particular time slot if
 available . This is the most basic thing . so now what , what shd i do next

 --mac


 On Fri, Aug 12, 2011 at 1:11 PM, keyan karthi 
 keyankarthi1...@gmail.comwrote:

 First thing tat should come to your mind s ' requirements ' ask him
 wat de requirements are. He will expect tat..

 On 8/12/11, MAC macatad...@gmail.com wrote:
  Hi guys ,
 
  Can anyone help me in understanding what is expected when some some one
   asks you  design a car rental system . Exactly what all is required
 to be
  told to the interviewer .
 
  --
  thanks
  --mac
 
  --
  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.
 
 

 --
 Sent from my mobile device

 --
 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.




 --
 thanks
 --mac




 --
 thanks
 --mac

  --
 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] constness in c++

2011-08-08 Thread Ankur Garg
In the code snippet that you have written u r changing the value of the
variable d which has been defined as auto variable (int d)

Now when u declare
const int *const ptr = d;

that means both the ptr and int are constant and u cant change either so u
cant deference ptr to some other int value

hence it doesnt work

try doing

const int d=1 ;

This would give error saying

 error: assignment of read-only variable `d'

I hope this make things clear

Regards
Ankur

On Mon, Aug 8, 2011 at 10:23 AM, mohit verma mohit89m...@gmail.com wrote:

 In c++

 int d=1;
 const int *const ptr = d;   means ptr is const ptr to const object .So
 neither ptr nor d can be changed. But

 when i do -
  d=5;
 coutd *ptr;
 the values are changed. Why is it so?
 Moreover doing something like : *ptr=5 gives error. Can someone explain
 internals here?
 --
 
 *MOHIT VERMA*

  --
 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] ThoghtWorks on campus

2011-08-08 Thread Ankur Garg
How much thought work pays..Can any1 tell ?


On Mon, Aug 8, 2011 at 2:48 PM, vaibhav shukla vaibhav200...@gmail.comwrote:

 @raj : its about to come to our campus too..questions hv been uploaded
 already in grp. Do send the questions which they ask please



 On Tue, Aug 9, 2011 at 12:09 AM, raj kumar megamonste...@gmail.comwrote:

 hi friends ,
 thoughtworks is coming to our campus after two days.
 please send me the questions which they asked in your campuses.
 thanks

 --
 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.




 --
   best wishes!!
 Vaibhav


  --
 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: Directi interview question

2011-08-08 Thread Ankur Garg
I can think of this solution

Put first elements in a max heap ..O(10)

Now take 11 th element ..compare it with root of this max heap ..If less
than root ignore ..else remove root and call max-heapify and put this
element in right place

Similarly do this for rest

Complexity will be  n+nlogk where k is 10

Please put ur comments and correct if wrong !!

Regards

Ankur

On Mon, Aug 8, 2011 at 4:36 PM, shady sinv...@gmail.com wrote:

 @DK can you please explain your solution, i couldn't understand...

 @all any alternate solution ?


 On Sun, Aug 7, 2011 at 11:02 PM, DK divyekap...@gmail.com wrote:

 This is a simple problem:

 1. Understand that if you are selecting 2 petrol pumps, say P and Q with
 say another petrol pump R between them, then it is optimal to include R into
 the set of selected petrol pumps as the max-distance for the chosen pumps
 remains PQ but number of included petrol pumps is reduced.

 Diagram: P --- R --- Q

 Therefore, all the selected pumps in the final solution are going to be
 contiguous.

 The simplest solution thus is to sort the points along the line AB. O(n
 log n)
 Then the answer is min{ai+10 - ai} for i = 0 to N-11 - O(n)

 Therefore net complexity is O(n log n).
 If the petrol pumps are given in sorted order from distance from A, then
 the complexity is simply O(n).

 --
 DK

 http://gplus.to/divyekapoor
 http://www.divye.in
 http://twitter.com/divyekapoor

 --
 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/-/m1jZuQUY85AJ.

 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: amazon online test format

2011-08-06 Thread Ankur Garg
The questions in the link are quite decent...Is the toughness level of
Amazon test same or more ?

On Sat, Aug 6, 2011 at 11:47 AM, shady sinv...@gmail.com wrote:

 @nivedita this is for job right ?


 On Sat, Aug 6, 2011 at 9:14 PM, nivedita arora 
 vivaciousnived...@gmail.com wrote:

 no online test is happening on campus for us

 On Aug 6, 7:17 pm, Nitish Garg nitishgarg1...@gmail.com wrote:
  Can anyone shed some light on Amazon Off campus procedure? This online
 test
  is for off campus aspirants right? Also does this online test happen
 after
  the phonic interview?

 --
 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: amazon online test format

2011-08-06 Thread Ankur Garg
@Yasir

MCQ are of which types ???

Regards

Ankur Garg

On Sat, Aug 6, 2011 at 4:45 PM, Yasir yasir@gmail.com wrote:

 Earlier they had telephonic interview as first round but now this
 online exam has become initial screening test.
 Based on ur online test's performance they call for phonic round or on-
 site interview.

 In online test, there there are 10 mcq questions and 5 coding probs.

 Cheers \o/

 On Aug 6, 7:17 pm, Nitish Garg nitishgarg1...@gmail.com wrote:
  Can anyone shed some light on Amazon Off campus procedure? This online
 test
  is for off campus aspirants right? Also does this online test happen
 after
  the phonic interview?

 --
 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: amazon online test format

2011-08-06 Thread Ankur Garg
@Yasir

Thanks bro :)

On Sat, Aug 6, 2011 at 7:13 PM, Yasir yasir@gmail.com wrote:

 Same as of DS  Algo in GATE exam.
 http://geeksforgeeks.org/?cat=66

 On Aug 7, 2:29 am, Ankur Garg ankurga...@gmail.com wrote:
  @Yasir
 
  MCQ are of which types ???
 
  Regards
 
  Ankur Garg
 
 
 
 
 
 
 
  On Sat, Aug 6, 2011 at 4:45 PM, Yasir yasir@gmail.com wrote:
   Earlier they had telephonic interview as first round but now this
   online exam has become initial screening test.
   Based on ur online test's performance they call for phonic round or on-
   site interview.
 
   In online test, there there are 10 mcq questions and 5 coding probs.
 
   Cheers \o/
 
   On Aug 6, 7:17 pm, Nitish Garg nitishgarg1...@gmail.com wrote:
Can anyone shed some light on Amazon Off campus procedure? This
 online
   test
is for off campus aspirants right? Also does this online test happen
   after
the phonic interview?
 
   --
   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.



[algogeeks] Why cant structures be declared or defined in C but can be done in C++ ?

2011-08-04 Thread Ankur Garg
Why cant structures be declared or defined in C but can be done in C++ ?


What is the reason for this ?

-- 
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] Why cant structures be declared or defined in C but can be done in C++ ?

2011-08-04 Thread Ankur Garg
sorry guys cudnt put question properly :P..my bad ..:((

the question i wanted to ask was

Why cant functions  be declared or defined in structures in  C but can be
done in C++ ?

On Thu, Aug 4, 2011 at 2:45 PM, Himanshu Srivastava 
himanshusri...@gmail.com wrote:

 afcose strcutures can be declared.classes are not declared!!!


 On Fri, Aug 5, 2011 at 12:13 AM, Dipankar Patro dip10c...@gmail.comwrote:

 Structures can very well be declared in C:
 struct student{
 char name[20];
 int roll;
 }s1;

 Are you talking about Classes?


 On 4 August 2011 23:51, Ankur Garg ankurga...@gmail.com wrote:

 Why cant structures be declared or defined in C but can be done in C++ ?


 What is the reason for this ?

 --
 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.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

 --
 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] Why cant structures be declared or defined in C but can be done in C++ ?

2011-08-04 Thread Ankur Garg
@Sagar

Pls check the below code ..I found this from google  :P

http://forums.devshed.com/c-programming-42/declaring-function-in-structure-in-c-545529.html

Guess now u can undestand my question and if possible provide help


On Thu, Aug 4, 2011 at 3:33 PM, sagar pareek sagarpar...@gmail.com wrote:

 @ ankur

 first tell me diff b/w class and structure in reference to C++;

 answer is :-
 in structure all data members are by default public and in class its
 private

 all the left characteristics like inheritance, overloading etc can be done
 on both

 even u can inherit a structure from a class and vice-verse ...

 if u dont believe then just try it or google it...

 so as C is not object oriented hence we cant do things in it as we do in
 C++


 On Fri, Aug 5, 2011 at 12:46 AM, Ankur Garg ankurga...@gmail.com wrote:

 sorry guys cudnt put question properly :P..my bad ..:((

 the question i wanted to ask was

 Why cant functions  be declared or defined in structures in  C but can be
 done in C++ ?

 On Thu, Aug 4, 2011 at 2:45 PM, Himanshu Srivastava 
 himanshusri...@gmail.com wrote:

 afcose strcutures can be declared.classes are not declared!!!


 On Fri, Aug 5, 2011 at 12:13 AM, Dipankar Patro dip10c...@gmail.comwrote:

 Structures can very well be declared in C:
 struct student{
 char name[20];
 int roll;
 }s1;

 Are you talking about Classes?


 On 4 August 2011 23:51, Ankur Garg ankurga...@gmail.com wrote:

 Why cant structures be declared or defined in C but can be done in C++
 ?


 What is the reason for this ?

 --
 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.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

 --
 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
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

  --
 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.



[algogeeks] Oracle Interview ..Need Help!!

2011-08-03 Thread Ankur Garg
Hi All,

Anyone who recently appeared for Oracle Interview .

What all topics,subjects do they ask ?

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.



Re: [algogeeks] Re: Give an efficient search algo

2011-08-03 Thread Ankur Garg
Q1 can be looked as rotated sorted array...check whether the no is less or
greater than kth element ..if greater search using binary search with low =0
high k-1 and if less earch in right with low=k+1 high =n;

q2) Dont know :(


On Wed, Aug 3, 2011 at 3:44 PM, Dave dave_and_da...@juno.com wrote:

 @Tushar: For problem 1, do a binary search on elements 1 to k, and if
 no hit is found, do a binary search on elements k+1 to n.

 For problem 2, suppose that you are searching the given array for the
 number 2. The idea is to take big steps when you are far from the
 target, and small steps when you are close. Start with i = 0. If a[i] !
 = 2, then add abs(a[i]-2) to i and try again. This is because it will
 take at least abs(a[i]-2) steps to get to 2.

  In this case, i = 0 and a[0] = 6, so add 4 to i, getting 4. a[4] = 4,
 so add 2 to i, getting 6. a[6] = 3, so add 1. a[7] = 2.

 Dave

 On Aug 3, 2:09 pm, TUSHAR tusharkanta.r...@gmail.com wrote:
  1.   Given an array of n-elements ? the 1st k -elements are in
  descending order and k+1 to n elements are in
ascending order. give an  efficient algo for searching an
  element ?
 
  2.  Given an array of n-elements ? each element in the array is either
  same or less by 1 or larger by 1 from the
   previous element . give an  efficient algo for searching an
  element ?
 
e.g :   6 6 6 5 4 4 3 2 3 4 3 4 

 --
 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: Give an efficient search algo

2011-08-03 Thread Ankur Garg
Dave's solution looks gud to me :)

On Wed, Aug 3, 2011 at 3:52 PM, Ankur Garg ankurga...@gmail.com wrote:

 Q1 can be looked as rotated sorted array...check whether the no is less or
 greater than kth element ..if greater search using binary search with low =0
 high k-1 and if less earch in right with low=k+1 high =n;

 q2) Dont know :(



 On Wed, Aug 3, 2011 at 3:44 PM, Dave dave_and_da...@juno.com wrote:

 @Tushar: For problem 1, do a binary search on elements 1 to k, and if
 no hit is found, do a binary search on elements k+1 to n.

 For problem 2, suppose that you are searching the given array for the
 number 2. The idea is to take big steps when you are far from the
 target, and small steps when you are close. Start with i = 0. If a[i] !
 = 2, then add abs(a[i]-2) to i and try again. This is because it will
 take at least abs(a[i]-2) steps to get to 2.

  In this case, i = 0 and a[0] = 6, so add 4 to i, getting 4. a[4] = 4,
 so add 2 to i, getting 6. a[6] = 3, so add 1. a[7] = 2.

 Dave

 On Aug 3, 2:09 pm, TUSHAR tusharkanta.r...@gmail.com wrote:
  1.   Given an array of n-elements ? the 1st k -elements are in
  descending order and k+1 to n elements are in
ascending order. give an  efficient algo for searching an
  element ?
 
  2.  Given an array of n-elements ? each element in the array is either
  same or less by 1 or larger by 1 from the
   previous element . give an  efficient algo for searching an
  element ?
 
e.g :   6 6 6 5 4 4 3 2 3 4 3 4 

 --
 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: Give an efficient search algo

2011-08-03 Thread Ankur Garg
@Dave ..for question 1 why use binary search for 1to k initially say array
is

17 15 13 11 9 1 3 5 7 the kth element is 9  ..Now if u want to find 3 why to
search in first half ..Just compare with kth element and if greater find on
left else go to right :)

Not totally conviced with ur solution for 1 st question though it will give
answer but not optimized one :)

On Wed, Aug 3, 2011 at 4:02 PM, amit karmakar amit.codenam...@gmail.comwrote:

 I think for question 1, the value of k is not provided, right?

 On Aug 4, 12:53 am, Ankur Garg ankurga...@gmail.com wrote:
  Dave's solution looks gud to me :)
 
 
 
  On Wed, Aug 3, 2011 at 3:52 PM, Ankur Garg ankurga...@gmail.com wrote:
   Q1 can be looked as rotated sorted array...check whether the no is less
 or
   greater than kth element ..if greater search using binary search with
 low =0
   high k-1 and if less earch in right with low=k+1 high =n;
 
   q2) Dont know :(
 
   On Wed, Aug 3, 2011 at 3:44 PM, Dave dave_and_da...@juno.com wrote:
 
   @Tushar: For problem 1, do a binary search on elements 1 to k, and if
   no hit is found, do a binary search on elements k+1 to n.
 
   For problem 2, suppose that you are searching the given array for the
   number 2. The idea is to take big steps when you are far from the
   target, and small steps when you are close. Start with i = 0. If a[i]
 !
   = 2, then add abs(a[i]-2) to i and try again. This is because it will
   take at least abs(a[i]-2) steps to get to 2.
 
In this case, i = 0 and a[0] = 6, so add 4 to i, getting 4. a[4] = 4,
   so add 2 to i, getting 6. a[6] = 3, so add 1. a[7] = 2.
 
   Dave
 
   On Aug 3, 2:09 pm, TUSHAR tusharkanta.r...@gmail.com wrote:
1.   Given an array of n-elements ? the 1st k -elements are in
descending order and k+1 to n elements are in
  ascending order. give an  efficient algo for searching an
element ?
 
2.  Given an array of n-elements ? each element in the array is
 either
same or less by 1 or larger by 1 from the
 previous element . give an  efficient algo for searching an
element ?
 
  e.g :   6 6 6 5 4 4 3 2 3 4 3 4 
 
   --
   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] latest google interview questions

2011-08-02 Thread Ankur Garg
Is this to tell people that U got an Intern at Google :P

Another Wannabe here ...arg

On Tue, Aug 2, 2011 at 5:17 PM, Anil Arya anilarya...@gmail.com wrote:

 I think the right answer is Balaguruswamy.
 If am wrong ..Plzz correct me


 On Wed, Aug 3, 2011 at 2:12 AM, sagar pareek sagarpar...@gmail.comwrote:

 ha ha who is ritchie?? lol...


 On Wed, Aug 3, 2011 at 1:50 AM, aanchal goyal 
 goyal.aanch...@gmail.comwrote:


 Who developed  C language ?
 I gave the answer Yashwant Kanetkar.
 rofl ! :D
 On Wed, Aug 3, 2011 at 1:31 AM, Ram CEG honest...@gmail.com wrote:

 funny:)


 On Wed, Aug 3, 2011 at 1:25 AM, UTKARSH SRIVASTAV 
 usrivastav...@gmail.com wrote:

 hi I got intern in google ...but i was not able to do some question of
 written paper
 1.
 main()
 {
  printf(hello);
 }
 OUTPUT-  hello

 Why the output is coming hello?
 2.  Who developed  C language ?
 I gave the answer Yashwant Kanetkarbut the interviewer said
 it was Dennis Ritchie...can anyone please tell me who is Dennis
 Ritchie



 --
 *
 *

  --
 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,*
 Aanchal Goyal*.


  --
 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
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

  --
 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.




 --
 Anil Kumar Arya
 B.Tech  III year
 computer science  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.


-- 
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.



[algogeeks] Myantra Iview

2011-07-30 Thread Ankur Garg
Has anybody given Myantra Iview recently

I have an interview coming up

Please share ques if you have

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.



[algogeeks] Re: Myantra Iview

2011-07-30 Thread Ankur Garg
No one has it ?

On Sat, Jul 30, 2011 at 7:52 PM, Ankur Garg ankurga...@gmail.com wrote:

 Has anybody given Myantra Iview recently

 I have an interview coming up

 Please share ques if you have

 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.



Re: [algogeeks] Facebook Interview question at NIT Warangal

2011-07-27 Thread Ankur Garg
Hi

The solution in the link is of complexity (n*2^n))

Does anyone know any better solution ?

Regards
Ankur
On Tue, Jul 26, 2011 at 11:10 PM, rajeev bharshetty rajeevr...@gmail.comwrote:

 @Ankur The link does has a very good explanation. Nice solution :)


 On Tue, Jul 26, 2011 at 10:47 PM, Kunal Patil kp101...@gmail.com wrote:

 @Ankur Garg: Nice explanation at the link given by u...


 On Tue, Jul 26, 2011 at 10:35 PM, Ankur Garg ankurga...@gmail.comwrote:

 Check this

 http://codesam.blogspot.com/2011/03/find-all-subsets-of-given-set.html


 On Tue, Jul 26, 2011 at 9:41 PM, Vishal Thanki 
 vishaltha...@gmail.comwrote:

 Here is the working code..

 #include stdio.h
 #include stdlib.h
 int a[] = {1,2,3,4,5};
 #define ARRLEN(a) (sizeof(a)/sizeof(a[0]))
 void print_comb(int len)
 {
int tlen = len;
int i, j, k;
 int al = ARRLEN(a);
for (i = 0; i  al; i++) {
for (j=i+len-1; jal;j++) {
for (k = i; k  i+len-1; k++) {
printf(%d , a[k]);
}
printf(%d\n, a[j]);
 }
}
 }

 int main(int argc, char *argv[])
 {
int len = atoi(argv[1]);
 print_comb(len);
return 0;
 }



 On Tue, Jul 26, 2011 at 5:18 PM, praneethn praneeth...@gmail.com
 wrote:
 
  check this link:
 
  *http://www.stefan-pochmann.info/spots/tutorials/sets_subsets/*
 
  On Tue, Jul 26, 2011 at 11:59 AM, sumit sumitispar...@gmail.com
 wrote:
 
  Given an array of size n, print all the possible subset of array of
  size k.
  eg:-
  input:
  a[]={1,2,3,4}, k = 2
  output:
  1,2
  1,3
  1,4
  2,3
  2,4
  3,4
 
  --
  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.




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

  --
 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] Facebook Interview question at NIT Warangal

2011-07-26 Thread Ankur Garg
Hi

Dont u think the subsets will also be

{2,1}
{3,1}
{3,2}
{4,1}
{4,2}
{4,3}

On Tue, Jul 26, 2011 at 11:59 AM, sumit sumitispar...@gmail.com wrote:

 Given an array of size n, print all the possible subset of array of
 size k.
 eg:-
 input:
 a[]={1,2,3,4}, k = 2
 output:
 1,2
 1,3
 1,4
 2,3
 2,4
 3,4

 --
 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] The Google Resume

2011-07-26 Thread Ankur Garg
+1
Me too looking out for the same :(

On Tue, Jul 26, 2011 at 7:10 PM, Saravanan T mail2sarava...@gmail.comwrote:

 +1

 Pls send to my email id as well..


 On Tue, Jul 26, 2011 at 7:09 PM, Akshata Sharma akshatasharm...@gmail.com
  wrote:

 Anyone having the Google Resume book pdf?

 --
 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] Amazon Question

2011-07-26 Thread Ankur Garg
Hey Guys

Can we use KMP Algorithm here to generate permutations...May be a bit
modification is req


On Tue, Jul 26, 2011 at 9:07 PM, keyan karthi keyankarthi1...@gmail.comwrote:

 oops .. permutation  pardon me guys !!!

 On 7/26/11, keyan karthi keyankarthi1...@gmail.com wrote:
  @kavitha: u can use back tracking to print all the substring for a
  string .. pseudo code should look some thing like this:
 
  void next_perm(string st,int pos)
  {
 if(pos==length)
 {
   coutst;
  return;
 }
 for(int i=pos;ilength;i++)
{
  swap(st,i,pos);
  next_perm(st,i+1);
  swap(st,i,pos);
}
  }
 
  On 7/26/11, ankit sambyal ankitsamb...@gmail.com wrote:
  @Swetha :Number of possible sub strings of a string of length n is of
  the order of n^2.
  So, there can,t be a better solution than O(n^2)
 
  --
  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] Facebook Interview question at NIT Warangal

2011-07-26 Thread Ankur Garg
Check this

http://codesam.blogspot.com/2011/03/find-all-subsets-of-given-set.html


On Tue, Jul 26, 2011 at 9:41 PM, Vishal Thanki vishaltha...@gmail.comwrote:

 Here is the working code..

 #include stdio.h
 #include stdlib.h
 int a[] = {1,2,3,4,5};
 #define ARRLEN(a) (sizeof(a)/sizeof(a[0]))
 void print_comb(int len)
 {
int tlen = len;
int i, j, k;
 int al = ARRLEN(a);
for (i = 0; i  al; i++) {
for (j=i+len-1; jal;j++) {
for (k = i; k  i+len-1; k++) {
printf(%d , a[k]);
}
printf(%d\n, a[j]);
 }
}
 }

 int main(int argc, char *argv[])
 {
int len = atoi(argv[1]);
 print_comb(len);
return 0;
 }



 On Tue, Jul 26, 2011 at 5:18 PM, praneethn praneeth...@gmail.com wrote:
 
  check this link:
 
  *http://www.stefan-pochmann.info/spots/tutorials/sets_subsets/*
 
  On Tue, Jul 26, 2011 at 11:59 AM, sumit sumitispar...@gmail.com wrote:
 
  Given an array of size n, print all the possible subset of array of
  size k.
  eg:-
  input:
  a[]={1,2,3,4}, k = 2
  output:
  1,2
  1,3
  1,4
  2,3
  2,4
  3,4
 
  --
  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] Patterns in a String

2011-07-25 Thread Ankur Garg
Use KMP algorithm

On Mon, Jul 25, 2011 at 4:47 PM, nitesh abhishek.khattr...@gmail.comwrote:

 Given a string, give an algo to find the number of occurrences of a
 particular pattern

 Eg:

 Input: bellatbellfordbelly
 Find the number of occurrences of pattern(or substring) bell in it..

 --
 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/-/FY2cN6kSkNoJ.
 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: Prime Numbers

2011-07-24 Thread Ankur Garg
Do take a look at this also

http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes#cite_note-7

Source code to list all prime numbers till number n

#includeiostream
#includealgorithm
#define bool int
using namespace std;
int main(){
   int n;
   cinn;
   int i,j;
   bool primeValues[1000]={0};
   for(i=4;i=n;i=i+2){
  primeValues[i] = 1;
   }
   for(i=3;i*i=n;i=i+2){
  for(j=2;jn/i;j++)
primeValues[i*j] = 1;
   }
   for(i=2;in;i++){
 if(primeValues[i] == 0)
cout i ;
   }

}


On Sun, Jul 24, 2011 at 11:51 AM, frank abb...@gmail.com wrote:

 thanq u  very much

 On Jul 23, 10:13 pm, arun kumar kumar0...@gmail.com wrote:
  hope this link will help youhttp://
 www.topcoder.com/tc?module=Staticd1=tutorialsd2=primalityTes...
 
 
 
 
 
 
 
  On Sat, Jul 23, 2011 at 10:39 PM, frank abb...@gmail.com wrote:
   what is the efficient algorith to find the prime numbers or to check a
   number prime or not ?
   Helpful if the pseudo code provided.
 
  thank you
 
   --
   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 athttp://
 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: chronus corp..

2011-07-23 Thread Ankur Garg
9 for how much exp ??


On Sat, Jul 23, 2011 at 3:26 PM, sush57 sushaant...@gmail.com wrote:

 9...

 On Jul 23, 12:42 pm, sukhmeet singh sukhmeet2...@gmail.com wrote:
  Whats the CTC ???
 
  On Sat, Jul 23, 2011 at 11:36 AM, sush57 sushaant...@gmail.com wrote:
   can anyone suggest interview questions for chronus corp...i have
   interview on august 1st...
 
   --
   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: chronus corp..

2011-07-23 Thread Ankur Garg
kool man ...Whr to apply for exp people ??

Can you share some link and all

is company Chronos?



On Sat, Jul 23, 2011 at 3:33 PM, sush57 sushaant...@gmail.com wrote:

 fresher

 On Jul 23, 3:02 pm, Ankur Garg ankurga...@gmail.com wrote:
  9 for how much exp ??
 
  On Sat, Jul 23, 2011 at 3:26 PM, sush57 sushaant...@gmail.com wrote:
   9...
 
   On Jul 23, 12:42 pm, sukhmeet singh sukhmeet2...@gmail.com wrote:
Whats the CTC ???
 
On Sat, Jul 23, 2011 at 11:36 AM, sush57 sushaant...@gmail.com
 wrote:
 can anyone suggest interview questions for chronus corp...i have
 interview on august 1st...
 
 --
 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: chronus corp..

2011-07-23 Thread Ankur Garg
http://chronus.com/

Is this the site of the company ?


On Sat, Jul 23, 2011 at 3:45 PM, Ankur Garg ankurga...@gmail.com wrote:

 kool man ...Whr to apply for exp people ??

 Can you share some link and all

 is company Chronos?




 On Sat, Jul 23, 2011 at 3:33 PM, sush57 sushaant...@gmail.com wrote:

 fresher

 On Jul 23, 3:02 pm, Ankur Garg ankurga...@gmail.com wrote:
  9 for how much exp ??
 
  On Sat, Jul 23, 2011 at 3:26 PM, sush57 sushaant...@gmail.com wrote:
   9...
 
   On Jul 23, 12:42 pm, sukhmeet singh sukhmeet2...@gmail.com wrote:
Whats the CTC ???
 
On Sat, Jul 23, 2011 at 11:36 AM, sush57 sushaant...@gmail.com
 wrote:
 can anyone suggest interview questions for chronus corp...i have
 interview on august 1st...
 
 --
 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.



<    1   2