[algogeeks] Openings in Flipkart BLR

2015-09-01 Thread Sachin Chitale
Hi folks,

There are following open position in  flipkart if someone is interested do
send your resume.

1. SDE2/SDET 2/UI2 (2+ yrs)
2. APM/PM/EM
3. Engineering Directors
4. Architect
5. Data Scientist

Regards,
Sachin

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] Suggested the Data Structure to implement the solution in O(1)

2013-01-08 Thread Sachin Maheshwari
If you are using Java, you can go with LinkedHashMap.




On Sat, Jan 5, 2013 at 6:40 PM, Nishant Pandey  wrote:

> Give a Data structure to store Name-value pair like name-age
> "abc",12
> "xyz",34...
> such than insert(name,value), value = search(name), name = nthentry(n),
> delete(name); all can be perfomed in O(1).
> Note:- after deletion order should be maintained.Ex.
> "ds",12
> "df",78
> "teu",54
> "etr",12
> If delete("df") is called then nthentry(2) should return "teu"
>
>
> Please suggest the solution ..
>
> --
>
>
>



-- 
Regards,
Sachin Maheshwari
Cell phone: +91.7259917298

"If we admit that human life can be ruled by reason; the possibility of
life is destroyed." - Alexander Supertramp

-- 




Re: [algogeeks] perfect square condition checking....

2012-12-27 Thread Sachin Maheshwari
Are you asking for an algorithm for checking perfect square condition
without using library functions like sqrt?


On Sun, Dec 23, 2012 at 9:07 PM, Anil Sharma wrote:

> please suggest some efficient solution to check perfect square condition .
> no matter how much large number is... eg..i/p-8949 o/p-93
>
>
> --
>
>
>



-- 
Regards,
Sachin Maheshwari
Cell phone: +91.7259917298

"If we admit that human life can be ruled by reason; the possibility of
life is destroyed." - Alexander Supertramp

-- 




Re: [algogeeks] Trie Implementaion Issues

2012-12-27 Thread Sachin Maheshwari
Hi Aditya,
 In C++ member variables gets initialized to garbage values. So in
child function T->Symbol is garbage and is not null so it returns because
of null check. Next in your insert method you try to access that garbage
value. This will cause a crash.

When you remove the cmnt1, you intialize symbol field properly and hence
you see no crash.

As a general practice, always initialize member variables in C++ to some
value. I believe that was your intention of calling child method from
makeTrie function.

Regards,
Sachin


On Sun, Dec 23, 2012 at 5:48 AM, Aditya Raman wrote:

> Hello everyone,
> I was trying to implement Trie in c++ for the first time and got some
> issues in coding its implementation.
> The code has 2 commented lines namely cmnt1 and cmnt 2.
> I dont understand how does it make a difference if i use cmnt1 instead of
> cmnt2 .
> Both lines are intended to check if a node in the Trie has childs never
> initialized before.
>
> - Code Below
> ---
>
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> using namespace std;
> struct TrieNode
> {
>bool leaf;
>  TrieNode* symbol;
>};
>
> void child(TrieNode* T)
> {
>  
> cmnt1
>
>  if( T->symbol != NULL)return;
>
> ///
>
>  T->symbol=(TrieNode*)malloc(26*sizeof(TrieNode));
>
>   for(int i=0;i<26;i++)
>  { T->symbol[i].leaf=false;
>  T->symbol[i].symbol=NULL;
>   }
> }
>
> TrieNode* makeTrie( )
> {
>   TrieNode* T=(TrieNode*)malloc(sizeof(TrieNode));
>   T->leaf=false;
>   child(T);
>return T;
>   }
>
> void insert(string A,TrieNode* root)
> {TrieNode* temp=root;
>  int i;
>for(i=0;i{temp=&(temp->symbol[A[i]-'A']);
>
>
> //cmnt2//
>  if( temp->symbol== NULL)
>
>  
> /
>  child(temp);
>   }
>temp=&(temp->symbol[A[i]-'A']);
>temp->leaf=true;
>  }
>  vector display;
> void print(TrieNode* T)
> {
>if(T->leaf==true){ for(int i=0;i ";cout<if(T==NULL)return;
>   if(T->symbol!=NULL){
>for(int i=0;i<26;i++)
>{
>  display.push_back('A'+i);
>  print(&T->symbol[i]);
>  display.pop_back(); }
>}
>  }
>
>  int main()
>  {
>  TrieNode* root=makeTrie();
>  insert("ADI",root);
>  insert("CAT",root);
>  insert("ADII",root);
>  print(root);
>   //   system("pause");
>  }
>
> -end of code-
>
>
> if i  remove code of cmnt 1(like in the pasted code) and directly use the
> code of cmnt 2 then trie code runs smooth .But if do the opposite case
> ,which is logically the same ,the code fails to run. kindly help!
>
> --
>
>
>



-- 
Regards,
Sachin Maheshwari
Cell phone: +91.7259917298

"If we admit that human life can be ruled by reason; the possibility of
life is destroyed." - Alexander Supertramp

-- 




Re: [algogeeks] Pthread and Semaphore

2012-11-25 Thread Sachin Maheshwari
Hi Jagannath,
 pthread_join function call will suspend the execution of the current
thread till the new thread (whose id you provide to this function) has
completed.

So in your example when you say pthread_join(tid[i],NULL), the current
thread (ie the main thread) will remain suspended till thread created by
you in the previous line pthread_create (with thread id tid[i]) completes.

Regards,
Sachin


On Mon, Nov 26, 2012 at 9:46 AM, Jagannath Prasad Das
wrote:

> @Naveen: I didn't understand your point . Can you please throw more light
> on join operation
>
> On Sun, Nov 25, 2012 at 10:47 PM, vIGNESH v wrote:
>
>> You can use mutex instead of semaphores if you need to execute only one
>> case at a time.
>>
>> FROM,
>>
>> V.VIGNESH.
>> M.Sc Theoretical Computer Science.
>> PSG College of Technology
>>
>>
>>
>> On 25 November 2012 22:37, jagannath  wrote:
>>
>>>  Folks, I have one pthread question.I know that its not the right place
>>> but i thought this is the right place to post this. Code snippet:
>>> #include 
>>> #include 
>>>
>>> #include  /* defines _POSIX_THREADS if pthreads are available
>>> */
>>> #ifdef _POSIX_THREADS
>>> # include 
>>> #endif
>>>
>>> #include 
>>>
>>> void *text(void *arg);
>>>
>>> int code[] = { 4, 6, 3, 1, 5, 0, 2 };
>>>
>>> int main()
>>> {
>>> int i;
>>> pthread_t tid[7];
>>>
>>> for (i = 0; i < 7; i++)
>>> {
>>> pthread_create(&tid[i], NULL, text, (void*)&code[i]);
>>> pthread_join(tid[i],NULL);
>>> }
>>>
>>> return 0;
>>> }
>>>
>>> void *text(void *arg)
>>> {
>>> int n = *(int*)arg;
>>>
>>> switch (n)
>>> {
>>> case 0:
>>> printf("A semaphore S is an integer-valued variable which can take only
>>> non-negative\n");
>>> printf("values. Exactly two operations are defined on a
>>> semaphore:\n\n");
>>> break;
>>>
>>> case 1:
>>> printf("Signal(S): If there are processes that have been suspended on
>>> this semaphore,\n");
>>> printf(" wake one of them, else S := S+1.\n\n");
>>> break;
>>>
>>> case 2:
>>> printf("Wait(S): If S>0 then S:=S-1, else suspend the execution of this
>>> process.\n");
>>> printf(" The process is said to be suspended on the semaphore S.\n\n");
>>> break;
>>>
>>> case 3:
>>> printf("The semaphore has the following properties:\n\n");
>>> break;
>>>
>>> case 4:
>>> printf("1. Signal(S) and Wait(S) are atomic instructions. In particular,
>>> no\n");
>>> printf(" instructions can be interleaved between the test that S>0 and
>>> the\n");
>>> printf(" decrement of S or the suspension of the calling process.\n\n");
>>> break;
>>>
>>> case 5:
>>> printf("2. A semaphore must be given an non-negative initial
>>> value.\n\n");
>>> break;
>>>
>>> case 6:
>>> printf("3. The Signal(S) operation must waken one of the suspended
>>> processes. The\n");
>>> printf(" definition does not specify which process will be
>>> awakened.\n\n");
>>> break;
>>> }
>>>
>>> pthread_exit(0);
>>> }
>>>
>>> The threads are not synchronized and therefore the text output is
>>> garbled. How to add semaphores of POSIX to this program to synchronize the
>>> threads.?
>>>
>>> primitives to rejig your memory:
>>>
>>> sem_init(), sem_wait(),sem_post(),sem_destroy().
>>>
>>> --
>>>
>>>
>>>
>>
>>  --
>>
>>
>>
>
>  --
>
>
>



-- 
Regards,
Sachin Maheshwari
Cell phone: +91.7259917298

"If we admit that human life can be ruled by reason; the possibility of
life is destroyed." - Alexander Supertramp

-- 




Re: [algogeeks] Re: Largest contigious subarray with average greather than k

2012-11-23 Thread Sachin Chitale
@ bharat, koup

Sorry I missed this condition...
Algo can tweaked little bit further to cover all conditions..
Algorithm-->
1. Find out start and end index of contiguous subarray which* has sum >0 *
O(n)
2.Once u have start and end index calculate avg if it satisfies the
condition then done O(n)
  2.1 other wise run a loop through start to end index and remove trailing
elements by increasing start
 2.2 simultaneously check avg..this will lead to proper subarray.
3. In similar fashion start reducing end valuse keeping start
constant.do it sub steps of 2...

Check out the code...Time Com.. O(n) Space  O(1)
compare result of 2 and 3 and choose d best one...

public class LongestConArrMaxAvg{
static int maxAvgSum(int a[], float k) {
int max_so_far = 0, max_ending_here = 0, avg = 0, s = -1, e = -1, ts, te,
tsum;
boolean flag = false;

for (int i = 0; i < a.length; i++) {

if (max_ending_here == 0)
s = e = i;

max_ending_here = max_ending_here + a[i];

if (max_ending_here < 0) {
max_ending_here = 0;
s = e = -1;
}
if ( max_ending_here>0) {
max_so_far = max_ending_here;

e = i;
}

}

if (avgGreater(max_so_far, s, e, k)){
System.out.println("Result subarray start index:" + s
+ " End index:" + e);
return max_so_far;
}
/*This will generate two sequence use optimal time complexity of this algo
is O(n)
 *
 *
 */
 if (s >= 0 && !avgGreater(max_so_far, s, e, k)) {
max_ending_here = max_so_far;
ts = s;
te = e;

while (ts < te) {

max_ending_here -= a[ts];
if (avgGreater(max_ending_here, ts+1, te, k)) {
ts++;
System.out.println("Result subarray start index:" + ts
+ " End index:" + te);
break;
}
ts++;
}
ts = s;
te = e;
max_ending_here = max_so_far;
while (ts < te) {

max_ending_here -= a[te];
if (avgGreater(max_ending_here, ts, te-1, k)) {
te--;
System.out.println("Result subarray start index:" + ts
+ " End index:" + te);
break;
}
te--;
}

}

return max_so_far;
}

static boolean avgGreater(int sum, int s, int e, float k) {
float t= (float) (sum / (e - s + 1));
 return t>=k? true : false;
}

public static void main(String[] args) {

int[] a = {7,10,-1};
maxAvgSum(a, 5);
}

}


On Fri, Nov 23, 2012 at 4:14 PM, bharat b wrote:

> @ sachin : again u misunderstood the question .. question says *longest*..
>
> As per u'r algo ..
> 1. Find out start and end index of contiguous subarray which has max sum
> O(n)
> 2.Once u have start and end index calculate avg if it satisfies the
> condition then done O(n)
>   *NO -- > even if it satisifies, that may not be the longest *
> *Ex: {7,10,-1} and k=5 => as per u'r algo .. ans would be {7,10}-> avg is
> >5. But and is {7,10,-1}-> avg is >5.*
>
>
>
> On Wed, Nov 21, 2012 at 11:51 PM, Sachin Chitale <
> sachinchital...@gmail.com> wrote:
>
>> Implementation
>>
>> public class Kadanes {
>> static int maxAvgSum(int a[], float k) {
>> int max_so_far = 0, max_ending_here = 0, avg = 0, s = -1, e = -1, ts, te,
>> tsum;
>>  boolean flag = false;
>>
>> for (int i = 0; i < a.length; i++) {
>>
>>  if (max_ending_here == 0)
>>  s = e = i;
>>
>> max_ending_here = max_ending_here + a[i];
>>
>> if (max_ending_here < 0) {
>>  max_ending_here = 0;
>> s = e = -1;
>> }
>>  if (max_so_far < max_ending_here) {
>>  max_so_far = max_ending_here;
>>
>> e = i;
>> }
>>
>> }
>>
>> if (avgGreater(max_so_far, s, e, k)){
>> System.out.println("Result subarray start index:" + s
>>  + " End index:" + e);
>> return max_so_far;
>>  }
>> /*This will generate two sequence use optimal time complexity of this
>> algo is O(n)
>>  *
>>  *
>>  */
>>  if (s >= 0 && !avgGreater(max_so_far, s, e, k)) {
>>  max_ending_here = max_so_far;
>> ts = s;
>> te = e;
>>
>> while (ts < te) {
>>
>> max_ending_here -= a[ts];
>> if (avgGreater(max_ending_here, ts+1, te, k)) {
>>  ts++;
>> System.out.println("Result subarray start index:" + ts
>> + " End index:" + te);
>>  break;
>> }
>> ts++;
>> }
>>  ts = s;
>> te = e;
>> max_ending_here = max_so_far;
>>  while (ts < te) {
>>
>> max_ending_here -= a[te];
>> if (avgGreater(max_ending_here, ts, te-1, k)) {
>>  te--;
>> System.out.println("Result subarray start index:" + ts
>> + " End index:" + te);
>>  break;
>> }
>> te--;
>> }
>>
>> }
>>
>> return max_so_far;
>> }
>>
>> static boolean avgGreater(int sum, int s, int e, float k) {
>> float t= (float) (sum / (e - s + 1));
>>  return t&g

Re: [algogeeks] Re: Largest contigious subarray with average greather than k

2012-11-21 Thread Sachin Chitale
Implementation

public class Kadanes {
static int maxAvgSum(int a[], float k) {
int max_so_far = 0, max_ending_here = 0, avg = 0, s = -1, e = -1, ts, te,
tsum;
boolean flag = false;

for (int i = 0; i < a.length; i++) {

if (max_ending_here == 0)
s = e = i;

max_ending_here = max_ending_here + a[i];

if (max_ending_here < 0) {
max_ending_here = 0;
s = e = -1;
}
if (max_so_far < max_ending_here) {
max_so_far = max_ending_here;

e = i;
}

}

if (avgGreater(max_so_far, s, e, k)){
System.out.println("Result subarray start index:" + s
+ " End index:" + e);
return max_so_far;
}
/*This will generate two sequence use optimal time complexity of this algo
is O(n)
 *
 *
 */
 if (s >= 0 && !avgGreater(max_so_far, s, e, k)) {
max_ending_here = max_so_far;
ts = s;
te = e;

while (ts < te) {

max_ending_here -= a[ts];
if (avgGreater(max_ending_here, ts+1, te, k)) {
ts++;
System.out.println("Result subarray start index:" + ts
+ " End index:" + te);
break;
}
ts++;
}
ts = s;
te = e;
max_ending_here = max_so_far;
while (ts < te) {

max_ending_here -= a[te];
if (avgGreater(max_ending_here, ts, te-1, k)) {
te--;
System.out.println("Result subarray start index:" + ts
+ " End index:" + te);
break;
}
te--;
}

}

return max_so_far;
}

static boolean avgGreater(int sum, int s, int e, float k) {
float t= (float) (sum / (e - s + 1));
 return t>=k? true : false;
}

public static void main(String[] args) {

int[] a = { 100, 10, -1, -1, 4, -1, 7, 2, 8 };
System.out.println(maxAvgSum(a, 5));
}
}


On Wed, Nov 21, 2012 at 10:07 PM, Sachin Chitale
wrote:

> Hello,
>
> Algorithm-->
> 1. Find out start and end index of contiguous subarray which has max sum
> O(n)
> 2.Once u have start and end index calculate avg if it satisfies the
> condition then done O(n)
>   2.1 other wise run a loop through start to end index and remove trailing
> elements by increasing start
>  2.2 simultaneously check avg..this will lead to proper subarray.
> 3. In similar fashion start reducing end valuse keeping start
> constant.do it sub steps of 2...
>
> compare result of 2 and 3 and choose d best one...
> give me some time to write code
>
>
> On Wed, Nov 21, 2012 at 12:29 AM, Koup  wrote:
>
>> To be correct I need the longest subarray that has an average greater
>> than k but my main problem here is to find the longest one. Thank you !
>>
>> --
>>
>>
>>
>
>
>
> --
> Regards,
> Sachin Chitale
> Application Engineer SCJP, SCWCD
> Contact# : +91 8086284349, 9892159511
> Oracle Corporation
>



-- 
Regards,
Sachin Chitale
Application Engineer SCJP, SCWCD
Contact# : +91 8086284349, 9892159511
Oracle Corporation

-- 




Re: [algogeeks] Re: Largest contigious subarray with average greather than k

2012-11-21 Thread Sachin Chitale
Hello,

Algorithm-->
1. Find out start and end index of contiguous subarray which has max sum
O(n)
2.Once u have start and end index calculate avg if it satisfies the
condition then done O(n)
  2.1 other wise run a loop through start to end index and remove trailing
elements by increasing start
 2.2 simultaneously check avg..this will lead to proper subarray.
3. In similar fashion start reducing end valuse keeping start
constant.do it sub steps of 2...

compare result of 2 and 3 and choose d best one...
give me some time to write code


On Wed, Nov 21, 2012 at 12:29 AM, Koup  wrote:

> To be correct I need the longest subarray that has an average greater than
> k but my main problem here is to find the longest one. Thank you !
>
> --
>
>
>



-- 
Regards,
Sachin Chitale
Application Engineer SCJP, SCWCD
Contact# : +91 8086284349, 9892159511
Oracle Corporation

-- 




Re: [algogeeks] Largest contigious subarray with average greather than k

2012-11-20 Thread Sachin Chitale
Sorry Koup,
Plz ignore previous code, it has errors use below code
public class Kadanes {
static int maxAvgSum(int a[], int k) {
int max_so_far = 0, max_ending_here = 0, c = 0;
 boolean flag=false;
 for (int i = 0; i < a.length; i++) {
max_ending_here = max_ending_here + a[i];
if (max_ending_here < 0)
max_ending_here = 0;
if (max_so_far < max_ending_here) {
max_so_far = max_ending_here;
c++;
}

}
if(max_so_far>0){
  flag = (max_so_far / c) > k ? true : false;
}

System.out.println(flag);

return max_so_far;
}

public static void main(String[] args) {

int[] a = { -5, 6, 2, 100, 80 };
System.out.println(maxAvgSum(a, 13));
}
}

expln http://www.geeksforgeeks.org/archives/576


On Tue, Nov 20, 2012 at 11:37 PM, Sachin Chitale
wrote:

> Koup, your target should be to get contiguous array which hcodeas max sum.
> Then find out average and check whether its greater than given number
> check out below code.
>
> public class Kadanes {
>  static int maxAvgSum(int a[],int k) {
> int start, end, sum, curSum = 0;
> start = end = -1;
>  sum = 0;
> for (int i = 0; i < a.length; i++) {
>
> if (a[i] > 0) {
>  if (sum == 0) {
> start  = i;
> }
> sum += a[i];
>  end = i;
>  } else {
> curSum = sum + a[i];
>  if (curSum < 0) {
> start = end = -1;
> sum = 0;
>  } else {
> sum = curSum;
> }
> }
>  }
> boolean flag=(sum/(end-start+1))>k?true:false;
>  System.out.println(start + " : " + end+" : "+ flag);
>
> return sum;
>  }
>
> It's in Java returning max sum.
> Thanks,
> Sachin
>
>
> On Tue, Nov 20, 2012 at 10:58 PM, Koup  wrote:
>
>> Yeah i have worked on modifying that algorithm for some hours.But I have
>> problem when the sum is negative but the next element is a positive integer
>> that will make my sum correct. In that case the algorithm makes my sum zero
>> cause it was negative. Any help on that?
>>
>>
>> On Tuesday, November 20, 2012 7:17:32 PM UTC+2, Sachin Chitale wrote:
>>
>>> Use Kadane's algorithm to solve this with time complexity O(n) and Space
>>> O(1)
>>> http://www.algorithmist.com/**index.php/Kadane's_Algorithm<http://www.algorithmist.com/index.php/Kadane's_Algorithm>
>>>
>>> Need to modify a bit.
>>>
>>>
>>> --
>>> Regards,
>>> Sachin Chitale
>>> Application Engineer SCJP, SCWCD
>>> Contact# : +91 8086284349, 9892159511
>>> Oracle Corporation
>>>
>>> On Tue, Nov 20, 2012 at 10:43 PM, Koup  wrote:
>>>
>>>> Consider an array of N integers. Find the longest contiguous subarray
>>>> so that the average of its elements is greater than a given number k
>>>>
>>>> I know the general brute force solution in O(N^2). Is there any
>>>> efficient solution using extra space?
>>>>
>>>> --
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>   --
>>
>>
>>
>
>
>
> --
> Regards,
> Sachin Chitale
> Application Engineer SCJP, SCWCD
> Contact# : +91 8086284349, 9892159511
> Oracle Corporation
>



-- 
Regards,
Sachin Chitale
Application Engineer SCJP, SCWCD
Contact# : +91 8086284349, 9892159511
Oracle Corporation

-- 




Re: [algogeeks] Largest contigious subarray with average greather than k

2012-11-20 Thread Sachin Chitale
Koup, your target should be to get contiguous array which hcodeas max sum.
Then find out average and check whether its greater than given number
check out below code.

public class Kadanes {
static int maxAvgSum(int a[],int k) {
int start, end, sum, curSum = 0;
start = end = -1;
sum = 0;
for (int i = 0; i < a.length; i++) {

if (a[i] > 0) {
if (sum == 0) {
start  = i;
}
sum += a[i];
end = i;
 } else {
curSum = sum + a[i];
if (curSum < 0) {
start = end = -1;
sum = 0;
} else {
sum = curSum;
}
}
}
boolean flag=(sum/(end-start+1))>k?true:false;
 System.out.println(start + " : " + end+" : "+ flag);

return sum;
}

It's in Java returning max sum.
Thanks,
Sachin


On Tue, Nov 20, 2012 at 10:58 PM, Koup  wrote:

> Yeah i have worked on modifying that algorithm for some hours.But I have
> problem when the sum is negative but the next element is a positive integer
> that will make my sum correct. In that case the algorithm makes my sum zero
> cause it was negative. Any help on that?
>
>
> On Tuesday, November 20, 2012 7:17:32 PM UTC+2, Sachin Chitale wrote:
>
>> Use Kadane's algorithm to solve this with time complexity O(n) and Space
>> O(1)
>> http://www.algorithmist.com/**index.php/Kadane's_Algorithm<http://www.algorithmist.com/index.php/Kadane's_Algorithm>
>>
>> Need to modify a bit.
>>
>>
>> --
>> Regards,
>> Sachin Chitale
>> Application Engineer SCJP, SCWCD
>> Contact# : +91 8086284349, 9892159511
>> Oracle Corporation
>>
>> On Tue, Nov 20, 2012 at 10:43 PM, Koup  wrote:
>>
>>> Consider an array of N integers. Find the longest contiguous subarray
>>> so that the average of its elements is greater than a given number k
>>>
>>> I know the general brute force solution in O(N^2). Is there any
>>> efficient solution using extra space?
>>>
>>> --
>>>
>>>
>>>
>>
>>
>>
>>   --
>
>
>



-- 
Regards,
Sachin Chitale
Application Engineer SCJP, SCWCD
Contact# : +91 8086284349, 9892159511
Oracle Corporation

-- 




Re: [algogeeks] Largest contigious subarray with average greather than k

2012-11-20 Thread Sachin Chitale
Use Kadane's algorithm to solve this with time complexity O(n) and Space
O(1)
http://www.algorithmist.com/index.php/Kadane's_Algorithm

Need to modify a bit.


-- 
Regards,
Sachin Chitale
Application Engineer SCJP, SCWCD
Contact# : +91 8086284349, 9892159511
Oracle Corporation

On Tue, Nov 20, 2012 at 10:43 PM, Koup  wrote:

> Consider an array of N integers. Find the longest contiguous subarray
> so that the average of its elements is greater than a given number k
>
> I know the general brute force solution in O(N^2). Is there any
> efficient solution using extra space?
>
> --
>
>
>

-- 




[algogeeks] Fwd: IVY comptech campus visit

2012-10-25 Thread sachin singh
Can anyone tell about the selection proceedure for IVY comptech? I have
heard they have visited NIT Bhopal. Please reply back with the questions
that were asked in the written exam,

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: finding element in array with minimum of comparing

2012-10-08 Thread Sachin
@empo I believe you missed the point where Dave is setting arr[0] as elem. 
So this while condition will break at size = 0.

Thanks
Sachin

-- 
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/-/rkfWJrK9N1kJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] C output

2012-10-08 Thread Sachin
@rahul According to C specification, half filled array will be filled with 
value 0. In your example you are setting str[0] as 'g' and str[1] as 'k'. 
So the compiler sets str[29] as 0. So you string str becomes
{'g', 'k', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}

Confusion is arising from the fact that you have created an array of 10 
elements.

To answer you original question "gk" is inherently {'g', 'k', '\0'} and has 
size 3 while {'g', 'k'} has size 2.

Regards,
Sachin

On Saturday, October 6, 2012 9:34:30 PM UTC+5:30, rahul sharma wrote:
>
> #include
>
>
> int main()
> {
> char str[10]={'g','k'};
> char str1[10]="gh";
> int i;
> for(i=0;str1[i]!=NULL;i++)
> printf("%c",str[i]);
> getchar();
> }
>
> NUll is there in character array also...make clear me...
>
> On Sat, Oct 6, 2012 at 9:22 PM, rahul sharma 
> > wrote:
>
>> int main()
>> {
>> char str[10]={'g','k'};
>> char str1[10]="gh";
>>
>>
>> printf("%s",str);
>> printf("%s",str1);
>> getchar();
>> }
>> then how does this work???
>> str printing gk...then NULL is automatically appended in this also...plz 
>> tell
>>
>>
>> On Sat, Oct 6, 2012 at 6:33 PM, Rathish Kannan 
>> 
>> > wrote:
>>
>>> For string, C appends '\0' internally. hence sizeof(str) returned the 
>>> value 3.
>>> str1 is char array with two character. hence sizeof(str1) returned the 
>>> value 2.
>>>
>>> --  RK :)
>>>
>>>
>>> On Sat, Oct 6, 2012 at 5:53 PM, rahul sharma 
>>> 
>>> > wrote:
>>>
>>>> char str[]="ab"; 
>>>> char str1[]={'a','b'};
>>>>
>>>> sizeof(str) ...o/p is 3
>>>> sizeof(str1)o/p is 2..
>>>>
>>>> Why so
>>>> plz explain...
>>>>  
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algo...@googlegroups.com
>>>> .
>>>> To unsubscribe from this group, send email to 
>>>> algogeeks+...@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 algo...@googlegroups.com
>>> .
>>> To unsubscribe from this group, send email to 
>>> algogeeks+...@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 view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/65EsWyTnMlEJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Fwd: Snapdeal placement proceedure

2012-08-28 Thread sachin singh
-- Forwarded message --
From: sachin singh 
Date: Tue, Aug 28, 2012 at 10:23 PM
Subject: Snapdeal placement proceedure
To: algogeeks@googlegroups.com



Can anyone tell about the recruitment process of snapdeal?
I mean how to prepare for the written test?What kind of written test it
would be?
What are they asking in interview? And some pointers on what skills they
are basically looking at when they come to hire at colleges

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: [Google] Finds all the elements that appear more than n/3 times

2012-07-10 Thread sachin goyal
To Mr. B
how will you find median in O(n) time? please elaborate.

On Wednesday, July 11, 2012 4:01:43 AM UTC+5:30, Mr.B wrote:
>
> I found a similar solution looking somewhere else.
>
> The solution for this problem is:
> a. There can be atmost 3 elements (only 3 distinct elements with each 
> repeating n/3 times) -- check for this and done. -- O(n) time.
> b. There can be atmost 2 elements if not above case.
>
> 1. Find the median of the input. O(N)
> 2. Check if median element is repeated N/3 times or more -- O(n) - *{mark 
> for output if yes}*
> 3. partition the array based on median found above. - O(n)  -- {partition 
> is single step in quicksort}
> 4. find median in left partition from (3). - O(n)
> 5. check if median element is repeared n/3 times or more - O(n)  *{mark 
> for output if yes}* 
> 6. find median in right partition from (3). - O(n)
> 7.  check if median element is repeared n/3 times or more - O(n)  *{mark 
> for output if yes}*  
>
> its 7*O(N) => O(N) solution. Constant space.
>
> we need not check further down or recursively. {why? reason it.. its 
> simple}
>
>
> On Wednesday, 27 June 2012 18:35:12 UTC-4, Navin Kumar wrote:
>>
>>
>> Design an algorithm that, given a list of n elements in an array, finds 
>> all the elements that appear more than n/3 times in the list. The algorithm 
>> should run in linear time
>>
>> ( n >=0 ).
>>
>> You are expected to use comparisons and achieve linear time. No 
>> hashing/excessive space/ and don't use standard linear time deterministic 
>> selection algo.
>>
>>

-- 
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/-/PxIJd3So3tkJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Array problem

2012-03-14 Thread sachin sabbarwal
now i get this!! i thought we have to calculate the sum upto (i-1)th index.
thanx for the clarifiacation.

On Wed, Mar 14, 2012 at 3:07 PM, Dheeraj Sharma  wrote:

> you have to calculate the sum of elements which are less than..that
> particular element...this is not the question of calculating cumulative sum
>
>
> On Wed, Mar 14, 2012 at 11:22 AM, sachin sabbarwal <
> algowithsac...@gmail.com> wrote:
>
>> @gaurav popli:  how about this one??
>>
>> findsummat(int arr[],int n)
>> {
>>int *sum ;
>>  sum =(int*)malloc(sizeof(int)*n);
>>
>> for(int i=0;i>   sum[i] = 0;
>>
>> for(int i=0;i>sum[i] = sum[i-1] + arr[i-1];
>> //now print the sum array
>>
>> }
>>
>> it works very well
>> plz tell me if anything is wrong with this solution.
>>
>>
>> On Tue, Mar 13, 2012 at 12:03 PM, atul anand wrote:
>>
>>> @piyush : sorry dude , didnt get your algo . actually you are using
>>> different array and i get confused which array to be considered when.
>>>
>>>
>>>
>>> On Mon, Mar 12, 2012 at 5:19 PM, Piyush Kapoor wrote:
>>>
>>>> 1)First map the array numbers into the position in which they would be,
>>>> if they are sorted,for example
>>>> {30,50,10,60,77,88} ---> {2,3,1,4,5,6}
>>>> 2)Now for each number ,find the cumulative frequency of index ( = the
>>>> corresponding number in the map - 1).
>>>> 3)Output the cumulative frequency and increase the frequency  at the
>>>> position (=the corresponding number in the map) by the number itself.
>>>> Example
>>>> {3,5,1,6,7,8}  Map of which would be {2,3,1,4,5,6}
>>>> Process the numbers now,
>>>> 1)3 comes ,find the cumulative frequency at index 1 ( = 2-1) which is
>>>> 0. so output 0
>>>>Increase the frequency at index 2 to the number 3.
>>>> 2)5 comes,find the CF at index 2( = 3-1) which is equal to 3 .output 3.
>>>>Increase the frequency at index 3 to the number 5.
>>>> 3)1 comes,CF at index 0 (=1-1) = 0 so output 0.increase the F at
>>>> position 1 by 1.
>>>> Similarly for others.
>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from 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.
>>
>
>
>
> --
> *Dheeraj Sharma*
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] Array problem

2012-03-13 Thread sachin sabbarwal
@gaurav popli:  how about this one??

findsummat(int arr[],int n)
{
   int *sum ;
 sum =(int*)malloc(sizeof(int)*n);

for(int i=0;iwrote:

> @piyush : sorry dude , didnt get your algo . actually you are using
> different array and i get confused which array to be considered when.
>
>
>
> On Mon, Mar 12, 2012 at 5:19 PM, Piyush Kapoor wrote:
>
>> 1)First map the array numbers into the position in which they would be,
>> if they are sorted,for example
>> {30,50,10,60,77,88} ---> {2,3,1,4,5,6}
>> 2)Now for each number ,find the cumulative frequency of index ( = the
>> corresponding number in the map - 1).
>> 3)Output the cumulative frequency and increase the frequency  at the
>> position (=the corresponding number in the map) by the number itself.
>> Example
>> {3,5,1,6,7,8}  Map of which would be {2,3,1,4,5,6}
>> Process the numbers now,
>> 1)3 comes ,find the cumulative frequency at index 1 ( = 2-1) which is 0.
>> so output 0
>>Increase the frequency at index 2 to the number 3.
>> 2)5 comes,find the CF at index 2( = 3-1) which is equal to 3 .output 3.
>>Increase the frequency at index 3 to the number 5.
>> 3)1 comes,CF at index 0 (=1-1) = 0 so output 0.increase the F at position
>> 1 by 1.
>> Similarly for others.
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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: Microsoft Question

2011-10-29 Thread sachin goyal
On 10/29/11, praveen raj  wrote:
> Priority Queue:
> when popped ... returns the max priority element and if the priorities
> of two or more elements are same...then they will popped as they are
> inserted ..
> when pushed the element : puts the element in the list according to the
> priority...
>
>
> For making priority queue into Queue::
> on popping : make priority of every element same... so  on popping... the
> element...(popped according to which they are inserted)
> on pushing : insert the element as same priority as other inserted
> elements
>
> For making priority queue into stack..:
> make priority of elements in increasing order... .. so on popping the
> element... will pop the topmost element(with the highest priority
> value)..
> on pushing the element... push the element... with the priority value more
> than topmost priority value...
>
> With regards,
>
> Praveen Raj
> DCE-IT 3rd yr
> 735993
> praveen0...@gmail.com
>
>
>
> On Thu, Sep 15, 2011 at 6:37 PM, Yogesh Yadav  wrote:
>
>> For Stack:
>>
>> just make a structure:
>>
>> struct stack_with_priorityqueue
>> {
>>   int num;
>>   int priority;
>>   struct stack_with_priorityqueue *ptr;
>> }
>>
>> now when we add another number just increase the priority...
>> priority++
>>
>>
>> For Queue:
>>
>> do same...just decrease priority...priority--
>>
>>
>>
>> ...
>>
>>
>> On Wed, Sep 14, 2011 at 4:41 PM, bharatkumar bagana <
>> bagana.bharatku...@gmail.com> wrote:
>>
>>> The well known examples of priority queue is minheap and maxheap..
>>> i guess the question is how do we implement one of these(at least) using
>>> queue?
>>>
>>>
>>> On Wed, Sep 14, 2011 at 9:08 AM, Ankuj Gupta  wrote:
>>>
 I guess the functionality of priority should be maintained

 On Sep 13, 11:59 pm, Ankur Garg  wrote:
 > But dude are u saying stack will be implemented as a map with
 > 
 >
 > and then choose element based on priority ?
 >
 > regards
 > Ankur
 >
 >
 >
 >
 >
 >
 >
 > On Tue, Sep 13, 2011 at 10:16 PM, Ankuj Gupta 
 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  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.


>>>
>>>
>>> --
>>>
>>> **Please do not print this e-mail until urgent requirement. Go Green!!
>>> Save Papers <=> Save Trees
>>> *BharatKumar Bagana*
>>> **http://www.google.com/profiles/bagana.bharatkumar
>>> *
>>> Mobile +91 8056127652*
>>> 
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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 

Re: [algogeeks] remove duplicate words from a string

2011-10-11 Thread sachin goyal
lets take an example...
hello naveen how are you naveen?
how we can store  the word each seperated by space into array if we are
considering binary tree???
how we can measure which is smaller than other according to
property??
if we store each word into hash table then how we can get those words stored
at different places in hash table???
how we know about the indexes where we have store the word because in the
end we have to combine all the wordinto string.
please tell perfect solution...

On Tue, Oct 11, 2011 at 11:00 AM, rahul sharma wrote:

> if the string is sorted then
>
> int rmvDup(char arr[],int arrLen)
> {
> int i,j;
> for (i =1,j=0; i< arrLen;i++)
> {
> if (arr[j] != arr[i])
> {
> arr[j+1] = arr[i];
> j = j+1;
> }
> }
>
>  arr[j]='\0';
> return j+1;
> }
>
>
> On Tue, Oct 11, 2011 at 9:18 AM, sunny agrawal wrote:
>
>> @Ankur
>> in Trie at each Node there will be 26 Pointers Stored, and Most of them
>> would be NULL, thats why i think it will waste space,
>>
>> in Balanced Binary Tree i was thinking of storing the Complete Words at a
>> Node.
>>
>> But now i think this is Better -> Ternary Search 
>> Tries
>>
>>
>>
>>
>>
>> --
>> Sunny Aggrawal
>> B.Tech. V year,CSI
>> Indian Institute Of Technology,Roorkee
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] remove duplicate words from a string

2011-10-10 Thread sachin goyal
remove duplicate words from a string with min. complexityy.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Amdocs

2011-10-02 Thread sachin goyal
they provide first one year job in puneif your profile is testing then
it may be at gurgaon

On Mon, Oct 3, 2011 at 12:13 AM, Anika Jain  wrote:

> hiii... ok i meant job offer is for Pune or NCR area ??if u knw..
>
> On Oct 2, 11:29 pm, sachin goyal  wrote:
> > h anika.amdocs in coming to thapar on 7 oct.
> >
> >
> >
> >
> >
> >
> >
> > On Sun, Oct 2, 2011 at 11:01 PM, Anika Jain 
> wrote:
> > > hey sachin: amdocs is coming for job at wich location??
> >
> > > On Oct 2, 8:55 pm, gaurav yadav  wrote:
> > > > my number= +919939569122
> > > > gtalk id=gauravyadav1...@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Amdocs

2011-10-02 Thread sachin goyal
h anika.amdocs in coming to thapar on 7 oct.

On Sun, Oct 2, 2011 at 11:01 PM, Anika Jain  wrote:

> hey sachin: amdocs is coming for job at wich location??
>
> On Oct 2, 8:55 pm, gaurav yadav  wrote:
> > my number= +919939569122
> > gtalk id=gauravyadav1...@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] Amdocs

2011-10-02 Thread sachin goyal
hey gaurav bhai
please provide me your phone number..amdocs visiting thapar on 7
oct.

On Sun, Oct 2, 2011 at 7:45 PM, gaurav yadav wrote:

> I cracked amdocs interview...u need to stress on following topics..
>
> *ONLINE TEST*
>
> 1)UNIX
> Questions on various commands.Important ones are ls,tr,head,tail,tee,gzip
> and questions on bash script.
> 2)SQL
> Questions on access levels for diff. users,outer join,inner join,left and
> right join,ddl and dml commands(like delete,truncate,etc)
> 3)C/C++/Java
> I choose C...questions were based on finding outputs mainly on
> pointers,switch,1 question was also about unions.
> 4)Basic aptitude questions
> 5)Learning ability
> A paragraph will be given to you,based on that 3-4 questions were asked.You
> will have enough time to read to read and answer.
>
> *INTERVIEW*
>
> *TECHNICAL*
>
> 1)C language(pointers mainly) or any other language u choose mainly from
> c/c++/java.
> 2)sql(various dml and ddl commands)
> 3)data strucures
> 4)basic knowlegde of automata theory(including its mathematical
> representations)
>
> *HR*
>
> Just introduce yourself nicely and also him questions when needed to
> pretend that u are really interested in joining and are flexible with the
> location and working hours.
>
>
> So ,that's it.Best of Luck !!!
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Min no of moves

2011-09-05 Thread sachin goyal
it means we r considring d value for 2*n...so need total n passes...

On Mon, Sep 5, 2011 at 1:33 PM, aditya kumar
wrote:

> @dheeraj : u are right . i dint read the question properly . i thot there
> are total n glasses so i answerd : n/4 swaps . bt since we have 2n glass so
> we need n/2 swaps . i guess gopi did the same mistake
> @sachin : yes u are also correct since the glasses are identical the order
> of swapping doesnt matter . yes u can do that way also . the onli thing is
> dat u will require n/2 swaps .
>
>
>
> On Mon, Sep 5, 2011 at 12:12 PM, Dheeraj Sharma <
> dheerajsharma1...@gmail.com> wrote:
>
>> i thnk n/2 swaps are required... 1/4 is of the total glasses present..
>> i.e. 2n/4 ..=n/2
>>
>>
>> On Mon, Sep 5, 2011 at 11:52 AM, sachin goyal wrote:
>>
>>> PLEASE CORRECT ME ADITYA
>>>
>>>
>>> On Mon, Sep 5, 2011 at 11:52 AM, sachin goyal wrote:
>>>
>>>> 12345|12345
>>>> F|E
>>>> WE HAVE TO CREATE THE PATTERN LIKE
>>>> F E F E F E F E F E
>>>> ACCORDING TO MY UNDERSTANDING WE CAN DIRECTLY REPLACE THE 2ND WITH
>>>> SECOND AND 4TH WITH 4TH
>>>> TELL CORRECT ME IF I AM WRONG AND I AM TRATING WRONG???
>>>>
>>>>
>>>>
>>>> On Sun, Sep 4, 2011 at 8:04 PM, *$*  wrote:
>>>>
>>>>> yes n/4 swaps are required. +1 aditya kumar
>>>>>
>>>>>
>>>>> On Sun, Sep 4, 2011 at 6:32 PM, aditya kumar <
>>>>> aditya.kumar130...@gmail.com> wrote:
>>>>>
>>>>>> swap n/2-1 with n/2+1 , and then n/2-3 with n/2+3 till we reach n-1 .
>>>>>> so we need n/4 swaps .
>>>>>>
>>>>>>
>>>>>> On Sun, Sep 4, 2011 at 5:28 PM, Anup Ghatage wrote:
>>>>>>
>>>>>>> That's interesting.
>>>>>>>
>>>>>>> when n = 3
>>>>>>>
>>>>>>> We have been given this :F F F | E E E
>>>>>>>
>>>>>>> Swap the middle element and it becomes: F E F | E F E
>>>>>>>
>>>>>>> Which is what you want, but when n = 5
>>>>>>>
>>>>>>> F F F F F | E E E E E
>>>>>>>
>>>>>>> And you swap the middle element it becomes: F F E F F | E E F E E
>>>>>>>
>>>>>>> So the same startegy doesn't apply.
>>>>>>>
>>>>>>> But if you do with from the center for every alternate element, it
>>>>>>> works
>>>>>>>
>>>>>>> for n = 3
>>>>>>>
>>>>>>> F F F | E E E > F F E | F E E > E F E | E F E
>>>>>>>
>>>>>>> It also works for n = 5 etc. So, It is a more uniform solution if you
>>>>>>> may.
>>>>>>>
>>>>>>>  --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Algorithm Geeks" group.
>>>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>>>> To unsubscribe from 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.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Thx,
>>>>> --Gopi
>>>>>
>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubs

Re: [algogeeks] Min no of moves

2011-09-04 Thread sachin goyal
PLEASE CORRECT ME ADITYA

On Mon, Sep 5, 2011 at 11:52 AM, sachin goyal  wrote:

> 12345|12345
> F|E
> WE HAVE TO CREATE THE PATTERN LIKE
> F E F E F E F E F E
> ACCORDING TO MY UNDERSTANDING WE CAN DIRECTLY REPLACE THE 2ND WITH SECOND
> AND 4TH WITH 4TH
> TELL CORRECT ME IF I AM WRONG AND I AM TRATING WRONG???
>
>
>
> On Sun, Sep 4, 2011 at 8:04 PM, *$*  wrote:
>
>> yes n/4 swaps are required. +1 aditya kumar
>>
>>
>> On Sun, Sep 4, 2011 at 6:32 PM, aditya kumar <
>> aditya.kumar130...@gmail.com> wrote:
>>
>>> swap n/2-1 with n/2+1 , and then n/2-3 with n/2+3 till we reach n-1 .
>>> so we need n/4 swaps .
>>>
>>>
>>> On Sun, Sep 4, 2011 at 5:28 PM, Anup Ghatage  wrote:
>>>
>>>> That's interesting.
>>>>
>>>> when n = 3
>>>>
>>>> We have been given this :F F F | E E E
>>>>
>>>> Swap the middle element and it becomes: F E F | E F E
>>>>
>>>> Which is what you want, but when n = 5
>>>>
>>>> F F F F F | E E E E E
>>>>
>>>> And you swap the middle element it becomes: F F E F F | E E F E E
>>>>
>>>> So the same startegy doesn't apply.
>>>>
>>>> But if you do with from the center for every alternate element, it works
>>>>
>>>> for n = 3
>>>>
>>>> F F F | E E E > F F E | F E E > E F E | E F E
>>>>
>>>> It also works for n = 5 etc. So, It is a more uniform solution if you
>>>> may.
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from 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.
>>>
>>
>>
>>
>> --
>> Thx,
>> --Gopi
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

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



Re: [algogeeks] Please provide Code to Find kth Smallest or kth Largest element in unsorted array in liner time ?

2011-09-04 Thread sachin goyal
PLEASE TELL ME HOW WE CAN USE QUICK SORT TO FIND THE ELEMENT
BECAUSE IN QUICK SORT ONE ELEMENT IN SHIFT IN ITS RIGHT POSITION ALL LEFTS
ARE SMALLER AND ALL RIGHT ARE BIG

On Mon, Sep 5, 2011 at  POSIT11:55 AM, sachin goyal
wrote:

> PLEASE TELL HOW
>
>
> On Sun, Sep 4, 2011 at 7:23 PM, sarath prasath wrote:
>
>> another sol which i learned from my friend is
>> think of heap sort...
>>
>> On Sun, Sep 4, 2011 at 6:28 PM, learner  wrote:
>>
>>> something I Know using quick sort randomization function we can find
>>> kt smallest/largest in unsorted array , but i am not able to write
>>> code , please help me in this and provide the code for the same.?
>>>
>>>
>>> Thanks
>>> Nimish K.
>>> 1st Year
>>> IITR
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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] Please provide Code to Find kth Smallest or kth Largest element in unsorted array in liner time ?

2011-09-04 Thread sachin goyal
PLEASE TELL HOW

On Sun, Sep 4, 2011 at 7:23 PM, sarath prasath wrote:

> another sol which i learned from my friend is
> think of heap sort...
>
> On Sun, Sep 4, 2011 at 6:28 PM, learner  wrote:
>
>> something I Know using quick sort randomization function we can find
>> kt smallest/largest in unsorted array , but i am not able to write
>> code , please help me in this and provide the code for the same.?
>>
>>
>> Thanks
>> Nimish K.
>> 1st Year
>> IITR
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Min no of moves

2011-09-04 Thread sachin goyal
12345|12345
F|E
WE HAVE TO CREATE THE PATTERN LIKE
F E F E F E F E F E
ACCORDING TO MY UNDERSTANDING WE CAN DIRECTLY REPLACE THE 2ND WITH SECOND
AND 4TH WITH 4TH
TELL CORRECT ME IF I AM WRONG AND I AM TRATING WRONG???


On Sun, Sep 4, 2011 at 8:04 PM, *$*  wrote:

> yes n/4 swaps are required. +1 aditya kumar
>
>
> On Sun, Sep 4, 2011 at 6:32 PM, aditya kumar  > wrote:
>
>> swap n/2-1 with n/2+1 , and then n/2-3 with n/2+3 till we reach n-1 .
>> so we need n/4 swaps .
>>
>>
>> On Sun, Sep 4, 2011 at 5:28 PM, Anup Ghatage  wrote:
>>
>>> That's interesting.
>>>
>>> when n = 3
>>>
>>> We have been given this :F F F | E E E
>>>
>>> Swap the middle element and it becomes: F E F | E F E
>>>
>>> Which is what you want, but when n = 5
>>>
>>> F F F F F | E E E E E
>>>
>>> And you swap the middle element it becomes: F F E F F | E E F E E
>>>
>>> So the same startegy doesn't apply.
>>>
>>> But if you do with from the center for every alternate element, it works
>>>
>>> for n = 3
>>>
>>> F F F | E E E > F F E | F E E > E F E | E F E
>>>
>>> It also works for n = 5 etc. So, It is a more uniform solution if you
>>> may.
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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.
>>
>
>
>
> --
> Thx,
> --Gopi
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] Re: MICROSOFT

2011-09-04 Thread sachin goyal
@anup,@sukran ithink u both are right in case of binary search tree...
we can traverse and then easily find the value...
but in case of heap first we have to create the heap and accordingly apply
the algo the create min heap.
it will be the complex program
so simple is bst just traverse by inorder and compare
if anyone has simple solution or any other case then plz tell.

On Sun, Sep 4, 2011 at 9:56 PM, monish001  wrote:

> ALGO:
> 1. For each element 1 to k:
>   insert in into min-heap
> 2. for each element k+1 to n
>   delete the root of min-heap and insert this item into the min-
> heap
> 3. Finally you have a min-heap of k largest numbers and the root is
> your answer
>
> COMPLEXITY: O(n logn)
>
> -Monish
>
> On Sep 3, 3:03 pm, teja bala  wrote:
> > //Asked in MS please help me with the coding or Give an algorithm
> >
> > Write code to return the kth largest element in a tree ...>>> function
> > prototype is int fucnkth(node *root,int k)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] C output

2011-08-31 Thread sachin goyal
2 3 because d is pointer avriable

On Wed, Aug 31, 2011 at 9:25 PM, aditi garg wrote:

> 8 3
>
>
> On Wed, Aug 31, 2011 at 9:22 PM, rohit  wrote:
>
>> output??
>>
>> int main()
>> {
>> char *d = "abc\0def\0";
>> printf("%d %d",sizeof(d),strlen(d));
>> getch();
>> }
>>
>> --
>> 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/-/nf_M_Yoep_EJ.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] what is the error???

2011-08-31 Thread sachin goyal
extern try to find the definition of variable var but not able to find so
gives the error

On Wed, Aug 31, 2011 at 8:26 PM, Rajesh Kumar wrote:

> What we do to remove error??
> #include
> extern int var;
> main()
> {
>  var=10;
>  return 0;
> }
>
> Regards
> Rajesh Kumar
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] unsorted array problem

2011-08-25 Thread sachin sabbarwal
We have an array which contains integer numbers (not any fixed range). Only
two numbers are repeated odd number of times and remaining even number of
times. Find the 2 numbers.

like

arr[]={1,2,5,1,5,1,1,3,2,2}

1 -> 4 times(even)
2-> 3 times(odd)
3-> 1 times(odd)
5-> 2 times(even)

output 2 3

m not able to come up with a non-hashing solution which is faster than n^2,
plz suggest both type of solutions viz. hashing and non-hashing one's.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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 complexity

2011-08-25 Thread sachin sabbarwal
yeah!! i've read this problem from geeksforgeeks,
there the most satisfactory solution said that complexity would be
logarithmic,i guess you are right.

On Thu, Aug 25, 2011 at 11:54 PM, icy`  wrote:

> isnt this logarithmic?regular loop  1..n   runs in  n/(1 step each
> time)  -> O(n)
> this loop  n/(k + k^2 each time) ->   ln(n)/ ( ln(k) + k ln(2) )  ->
> ln(n-k) ->  O(ln(n))   or something like that ;P   I was going from
> memory.  Please confirm, but I feel like it approaches logarithmic
> speed.
>
> On Aug 25, 1:46 pm, sachin sabbarwal  wrote:
> > what will be the time complexity??
> >
> > sum=1
> > for(k=0; k > sum=sum+sum;
> > end
> > print(sum);
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Reverse dutch flag problem

2011-08-25 Thread sachin sabbarwal
one solution might be:
to traverse whole list counting no of zeros and 1's.
and then make another string(or overwrite the same) with the required
pattern,append any other characters(suppose all 0's exhausted and some 1's
and 2's were left) left at the end.
is there any better solution??

On Sat, Aug 20, 2011 at 4:20 PM, sukran dhawan wrote:

> i that .ink the soln for this problem is given in geeksforgeeks.com
>
>
> On Sat, Aug 20, 2011 at 3:27 PM, Sanjay Rajpal  wrote:
>
>> Suppose we are given a string .
>>
>> Make it 012012012012 in O(n) time and O(1) space.
>> Sanju
>> :)
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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] find the complexity

2011-08-25 Thread sachin sabbarwal
what will be the time complexity??

sum=1
for(k=0; khttp://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Benefits of using Private or Protected Virtual Functions ?

2011-08-23 Thread sachin sabbarwal
i can't come up with benefits...
but a potential use is here
class c1
{
private:
c1()
 {
 }

public:
static c1* makeobject(accept credentials)
{

//check for privileges
//if requester is privileged then make an object.(check credentials)
//make an object by calling constructor explicitly

return object;


}



};


int main()
{
c1 *obj1;

obj1 = c1::makeobject(my credentials);




}

//as constructor is private , we can't make an object directly. we'll let
the class decide who can make an object of it.
// if the class finds the requester privileged then it would let it create
an object otherwise give error.

correct me if i'm wrong, or tell me if you need more explanation.

On Mon, Aug 22, 2011 at 9:42 AM, Decipher  wrote:

>
>  --
> 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/-/TSCBDch6GdYJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: Adobe Interview - 20/08/2011

2011-08-22 Thread Sachin Jain
If an array is rotated a number of unknown times , then how to find an
element in O(log n)

For the above question, is the array already sorted???

On Mon, Aug 22, 2011 at 2:50 PM, vikas  wrote:

> using interval tree/segment tree will solve this in straightforward
> fashion
>
> On Aug 22, 12:41 pm, Jagannath Prasad Das  wrote:
> > for the stick prob is the stick length required?
> >
> > On Mon, Aug 22, 2011 at 12:48 PM, Jagannath Prasad Das
> > wrote:
> >
> >
> >
> >
> >
> >
> >
> > > i think find max and min of all time-stamps respectively
> >
> > > On Mon, Aug 22, 2011 at 12:44 PM, saurabh agrawal <
> saurabh...@gmail.com>wrote:
> >
> > >> How did u solved :
> >
> > >> 3) There is a list containing the checkin and checkout time of every
> > >> person in a party . The checkin time is in ascending order while the
> > >> checkout is random .
> >
> > >> Eg:
> >
> > >>Check_inCheck_out
> >
> > >> Person 1 8.00  9.00
> >
> > >> Person 2 8.15  8.30
> >
> > >> Person 3 8.30  9.20
> >
> > >> On Mon, Aug 22, 2011 at 9:14 AM, Decipher 
> wrote:
> >
> > >>> Hi,
> >
> > >>> This is my Adobe interview experience for freshers :
> >
> > >>>  *Written Test:*
> >
> > >>> Engineering   – 45 Minutes - Data Structures, Algorithms,
> > >>> Operating Systems
> >
> > >>> C/C++  – 45 Minutes - C/C++ Fundamentals &
> Coding***
> > >>> *
> >
> > >>> Aptitude– 45 Minutes – Quantitative & Analytical
> >
> > >>> * *
> >
> > >>> *On clearing the Test, 3 Technical Interviews + HR discussion on the
> > >>> same day.*
> >
> > >>> *
> > >>> *
> >
> > >>> *Interview 1: *
> >
> > >>> 1) Insert an element in a linked list at the end , given the *start *
> > >>> pointer.
> >
> > >>> 2) Write a function to Swap pointers .
> >
> > >>> 3) There is a list containing the checkin and checkout time of every
> > >>> person in a party . The checkin time is in ascending order while the
> > >>> checkout is random .
> >
> > >>> Eg:
> >
> > >>>Check_inCheck_out
> >
> > >>> Person 1 8.00  9.00
> >
> > >>> Person 2 8.15  8.30
> >
> > >>> Person 3 8.30  9.20
> >
> > >>> and so on ...
> > >>> Now , give an optimized solution to find at what time the maximum
> number
> > >>> of people will be in the party . My solution - O(nlogn) time and O(n)
> space
> > >>> . He gave another O(nlogn) time and O(n) space solution .
> >
> > >>> and some other questions that I can't recal ..
> >
> > >>> *Interview 2:*
> > >>> 1) Base class contains 2 functions and Derived class (with Private
> > >>> Inheritance from Base) also contains 2 functions (same name as those
> in Base
> > >>> cass), then he asked me the effect by changing the Inheritance type
> and
> > >>>  making different functions virtual like - virtual func in Base then
> in
> > >>> Derived and then both .
> >
> > >>> 2) Same question appended- A derived class *A* derived from Derived
> and
> > >>> Base , now
> >
> > >>> A a = new A;
> > >>> Base *b =  a;
> > >>> Derived *d = a;
> >
> > >>> b = d;
> >
> > >>> and b = (Base *) d;
> >
> > >>> then which functions can I call ?
> >
> > >>> 3) Convert a tree into its mirror without using extra memory - O(1)
> space
> > >>> .
> >
> > >>> 4) If an array is rotated a number of unknown times , then how to
> find an
> > >>> element in O(log n)
> >
> > >>> 5) There are 3 sticks placed at right angles to each other and a
> sphere
> > >>> is placed between the sticks . Now another sphere is placed in the
> gap
> > >>> between the sticks and Larger sphere . Find the radius of smaller
> sphere in
> > >>> terms of radius of larger sphere .
> >
> > >>> *This is as far I can remember so please don't ask any questions
> > >>> regarding 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/-/K0ws20ht-pkJ.
> > >>> To post to this group, send email to algogeeks@googlegroups.com.
> > >>> To unsubscribe from 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
> "A

Re: [algogeeks] c programe explain

2011-08-21 Thread sachin sabbarwal
error in c++ but runs in c(tested in dev cpp)

On Sun, Aug 21, 2011 at 11:13 PM, Puneet Chawla
wrote:

> @Naman :In codeblocks it's o/p is Interviewi exactly thought the same
> way but now i think that it depends upon compiler to compiler i don't know
> the reason behind it.
>
>
> On Sun, Aug 21, 2011 at 11:10 PM, Sanjay Rajpal  wrote:
>
>> but in the question, it is const char * to char *.
>>
>> Sanju
>> :)
>>
>>
>>
>> On Sun, Aug 21, 2011 at 10:38 AM, Naman Mahor wrote:
>>
>>> const char* into char * is error not warning
>>> i hv run it on DEV c++;
>>>
>>>
>>> On Sun, Aug 21, 2011 at 11:01 PM, Sanjay Rajpal wrote:
>>>
  i didnt run it, this concept is given in J.K.Chhabra book.


 Sanju
 :)



 On Sun, Aug 21, 2011 at 10:29 AM, Puneet Chawla <
 puneetchawla...@gmail.com> wrote:

> ohh srry.i didn't run it...sry again..
>
>
> On Sun, Aug 21, 2011 at 10:58 PM, Sanjay Rajpal wrote:
>
>>  it is a warning dear, not an error :)
>>
>>
>> Sanju
>> :)
>>
>>
>>
>> On Sun, Aug 21, 2011 at 10:27 AM, Puneet Chawla <
>> puneetchawla...@gmail.com> wrote:
>>
>>> okk tht i knew bt my point is We are converting const char* into char
>>> * here means "Interview" const char* into char *
>>>
>>>
>>> On Sun, Aug 21, 2011 at 10:55 PM, Sanjay Rajpal wrote:
>>>
  See precedence of ++ is greater than that of +=.

 so ii=7.
 Now in the statement funct(ii+++"Campus Interview"), when +++ will
 be parsed, it'll be ++ +, so
 ii++ + "Campus Interview" will be 7 + "Campus Interview" , which is
 equivalent to "Campus Interview"[7].

 Now to the function address passed starts from Interview.

 hence the result.
 Sanju
 :)



 On Sun, Aug 21, 2011 at 10:23 AM, Sanjay Rajpal 
 wrote:

>  the o/p wil be Interview.
>
>
>
> Sanju
> :)
>
>
>
> On Sun, Aug 21, 2011 at 10:20 AM, SuDhir mIsHra <
> sudhir08.mis...@gmail.com> wrote:
>
>>  funct(char* str)
>> {
>> printf("%s\n",str);
>> }
>> main()
>> {
>> static int ii = 1;
>> int jj = 5;
>> ii+=++jj;
>> funct(ii+++"Campus 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.

>>>
>>>
>>>
>>> --
>>> With regards
>>>   
>>> Puneet Chawla
>>> Computer Engineering Student
>>> NIT Kurukshetra
>>>
>>> --
>>>  You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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.
>>
>
>
>
> --
> With regards
>   
> Puneet Chawla
> Computer Engineering Student
> NIT Kurukshetra
>
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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 t

Re: [algogeeks] Challenge

2011-08-20 Thread sachin sabbarwal
your matrix isn't sorted!!!
a sorted matrix is
0001
0011

etc
-- Forwarded message --
From: rashmi i 
Date: Sun, Aug 21, 2011 at 11:52 AM
Subject: Re: [algogeeks] Challenge
To: algogeeks@googlegroups.com


will your solution work for:
0001
0010
0100
0110
1000


On Sun, Aug 21, 2011 at 10:29 AM, sachin sabbarwal  wrote:

> yes ,your example is sorted.
>
> On Sun, Aug 21, 2011 at 10:24 AM, Jagannath Prasad Das
>  wrote:
> > what does sorted row means???
> > is it
> > 00011
> > 0
> > 1
> > 0
> > where each row is sorted or among the rows also?
> > On Sun, Aug 21, 2011 at 9:51 AM, Sanjay Rajpal  wrote:
> >>
> >> hey see this array is not sorted, I forgot to mention this in my first
> >> post, but cleared this in subsequent posts that the rows in the array
> are
> >> sorted.
> >>
> >> Plz see above posts.
> >> Sanju
> >> :)
> >>
> >>
> >>
> >> On Sat, Aug 20, 2011 at 9:05 PM, Abhishek <
> mailatabhishekgu...@gmail.com>
> >> wrote:
> >>>
> >>> will this solution also work for..
> >>>
> >>> 
> >>> 0101
> >>> 1011
> >>> 11010100
> >>> 0100
> >>> 1001
> >>> 0111
> >>> 
> >>> plz clear your logic bit more..
> >>>
> >>> --
> >>> 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/-/A8HrLEBIIF8J.
> >>> To post to this group, send email to algogeeks@googlegroups.com.
> >>> To unsubscribe from 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.
> >
>
>
>
> --
> Sachin Sabbarwal
> Nit Kurukshetra
> III year
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
R@$!-!
"DoN'T LimIt Ur cHaLlEngeS, ChAlLenGe uR LImItS."

-- 
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] c++

2011-08-20 Thread sachin sabbarwal
class X()
{

X()
{
}



X fun()
{
return X();  //error or what?? because constructor never returns
anything so what this return statement will receive after executing x() and
what it will return??
}


};

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] sql help

2011-08-20 Thread sachin sabbarwal
plz suggest some link where i can get questions on sql queries to practice.
thanks in advance!!

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Challenge

2011-08-20 Thread sachin sabbarwal
yes ,your example is sorted.

On Sun, Aug 21, 2011 at 10:24 AM, Jagannath Prasad Das
 wrote:
> what does sorted row means???
> is it
> 00011
> 0
> 1
> 0
> where each row is sorted or among the rows also?
> On Sun, Aug 21, 2011 at 9:51 AM, Sanjay Rajpal  wrote:
>>
>> hey see this array is not sorted, I forgot to mention this in my first
>> post, but cleared this in subsequent posts that the rows in the array are
>> sorted.
>>
>> Plz see above posts.
>> Sanju
>> :)
>>
>>
>>
>> On Sat, Aug 20, 2011 at 9:05 PM, Abhishek 
>> wrote:
>>>
>>> will this solution also work for..
>>>
>>> 
>>> 0101
>>> 1011
>>> 11010100
>>> 0100
>>> 1001
>>> 0111
>>> 
>>> plz clear your logic bit more..
>>>
>>> --
>>> 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/-/A8HrLEBIIF8J.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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.
>



-- 
Sachin Sabbarwal
Nit Kurukshetra
III year

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: C dot

2011-08-19 Thread sachin sabbarwal
they ask very easy questions in interviews.
i had faced their interview.
first of all they asked me if i had done any project work.
then they asked about the platform used and why i had chosen it.
then few easy questions about algo of the project.

they questioned me on bubble sort.
then i was asked to write a program to reverse the words of a string.
for example "hi how r u"
reversed-> "u r how hi"

some other questions they asked some of my friends were
->how to declare an integer pointer.
->what is .net.
->what are features of opp(object oriented prog).

On Aug 19, 6:56 pm, aditi garg  wrote:
> Do u knw wat type of ques asked in interviews?
> Plz post a few as example if u knw...please...
> On Fri, Aug 19, 2011 at 7:25 PM, aditi garg wrote:
>
>
>
>
>
>
>
>
>
> > k thanx :)
>
> > On Fri, Aug 19, 2011 at 7:19 PM, Sanjay Rajpal 
> > wrote:
>
> >> In our college, students were shortlisted on the basis of GPA.Then Direct
> >> interview was conducted.
>
> >> *Regards
>
> >> Sanju
>
> >> Happy to Help :)*
>
> >> On Fri, Aug 19, 2011 at 6:44 AM, aditi garg 
> >> wrote:
>
> >>> Does anyone know the placement procedure of C Dot?
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups
> >>> "Algorithm Geeks" group.
> >>> To post to this group, send email to algogeeks@googlegroups.com.
> >>> To unsubscribe from 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.
>
> > --
> > 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.



Re: [algogeeks] important question on ADT

2011-08-19 Thread sachin sabbarwal
yes!! c is the correct answer.

On Fri, Aug 19, 2011 at 11:10 PM, Sanjay Rajpal  wrote:

> I think c is the answer.
>
> Sanju
> :)
>
>
>
> On Fri, Aug 19, 2011 at 10:27 AM, ghsjgl k  wrote:
>
>> An abstract data type is
>> (a) same as abstract class
>> (b) a datatype that cannot be instantiated
>> (c) a datatype for which only the operations defined on it can be used but
>> none else
>> (d) all of the above
>>
>>
>> what is the answer 
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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] Pointer Question

2011-08-12 Thread Sachin Jain
Explanation please

On Fri, Aug 12, 2011 at 9:33 AM, Dipankar Patro  wrote:

> b.
>
>
> On 11 August 2011 23:20, arvind kumar  wrote:
>
>> b.
>>
>>
>> On Thu, Aug 11, 2011 at 11:18 PM, Mani Bharathi 
>> wrote:
>>
>>> int(* fun()) [row][ Col];
>>> What should be the statement the for the above declarations
>>> a.fun() points to a two dimensional array
>>> b.pointer *fun() points to a two dimensional array
>>> c.pointer *fun() points to 1-dimensional array
>>>
>>> --
>>> 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/-/3xkodl3aLvcJ.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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.
>>
>
>
>
> --
>
> ___
>
> 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.



Re: [algogeeks] os

2011-08-08 Thread sachin sharma
http://en.wikipedia.org/wiki/Shared_memory

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] os

2011-08-08 Thread sachin sharma
Shared Memory...

On Mon, Aug 8, 2011 at 5:36 PM, Kamakshii Aggarwal wrote:

>
> Fastest IPC mechanism is
>
>1.   ?shared memory
>2.   ?pipes
>3.   ?named pipes
>4.   ?Semaphores
>
> --
> Regards,
> Kamakshi
> kamakshi...@gmail.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Best Wishes
Sachin Sharma | Software Trainee | Information Mosaic
New York | Dublin | London | Luxembourg | New Delhi | Singapore | Melbourne
|
e-mail: sachinku...@informationmosaic.com
Web:www.informationmosaic.com<http://www.informationmosaic.com/> |  t:
www.twitter.com/infomosaic
Winner 2009 Banking Technology Readers' Choice Award for Best Corporate
Actions Automation Solution

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



Re: [algogeeks] Duplicates in a string

2011-08-05 Thread Sachin Jain
We can do it in just one pass.
Start scanning the array and whichever element gets scanned just store some
kind of marker in the additional array that this element has been
vsisted.Next time you get some element if that element (or character) is not
visited earlier than mark it as visited and print it or if it was visited
earlier just skip it.

On Fri, Aug 5, 2011 at 8:30 PM, nishaanth  wrote:

> Store the frequency of all the letters in an array in one scan(like
> counting sort). In the next pass remove the duplicates and appropriately
> shift . takes 2 O(n) passes i guess
>
>
> On Fri, Aug 5, 2011 at 4:50 PM, priya v  wrote:
>
>>
>> Remove duplicate alphabets from a string and compress it in the same
>> string. For
>> example, MISSISSIPPI becomes MISP. O (n2) is not acceptable.
>> For this problem is it a good idea to sort the array using a sorting
>> technique with efficiency O(nlogn)
>> and remove the duplicates?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> S.Nishaanth,
> Computer Science and engineering,
> IIT Madras.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] C question.. sizeof operator

2011-08-03 Thread sachin sharma
output would be 10
size of just calculate the type of the expression not the value


Best Wishes
Sachin Sharma

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



Re: [algogeeks] compilation error

2011-08-02 Thread sachin sharma
/* fmod example */#include #include 
int main (){
  printf ("fmod of 5.3 / 2 is %lf\n", fmod (5.3,2) );
  printf ("fmod of 18.5 / 4.2 is %lf\n", fmod (18.5,4.2) );
  return 0;}



Best Wishes
Sachin Sharma

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



Re: [algogeeks] compilation error

2011-08-02 Thread sachin sharma
use fmod function on float


Best Wishes
Sachin Sharma

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



Re: [algogeeks] complexity

2011-07-27 Thread sachin sharma
it is O(plg5)


Best Wishes
Sachin Sharma

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



Re: [algogeeks] Poison River

2011-07-25 Thread sachin sharma
@Someshwar Chandrasekaran

yea I think you are right. because to cross river, in the last we must have
one person new and other person who came back from other end.
this happens only in case of three.

Solution is possible up two three persons.
when you have four person in the last move you are left with one person who
dont have shoe in last because it is on the other end
or the two person who have already taken their chance.


Best Wishes
Sachin Sharma
University 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.



Re: [algogeeks] Re: Yahoo Question

2011-07-10 Thread sachin sharma
@vaibhav

Overflow problem in case of big number in option b.
the best and simple one is option a.

Best Wishes
Sachin Sharma | Software Trainee | Information Mosaic
New York | Dublin | London | Luxembourg | New Delhi | Singapore | Melbourne
|
e-mail: sachinku...@informationmosaic.com
Web:www.informationmosaic.com<http://www.informationmosaic.com/> |  t:
www.twitter.com/infomosaic
Winner 2009 Banking Technology Readers' Choice Award for Best Corporate
Actions Automation Solution

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



Re: [algogeeks] Google Question

2011-07-08 Thread sachin sharma
>
> if no of waiting process is required, it can be obtained by length of
> listen queue on server.
>
   if no of running process is required , it can be done by getting process
id's currently running,
   if no of hits in a time range is required, it can be done by server log
as well.
-- 
Best Wishes
Sachin Sharma
University of 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.



Re: [algogeeks] Re: Amazon

2011-07-08 Thread sachin sharma
@Sachin: What if the milestones were, A1-A3-A2-A0 in this order?

Miles tone may be in any order. you only take the pair of milestone,
their distances then u name all milestone so that you can sort the first
column. You can change the order of element in the array of distance. it
will not effect the solution

Best Wishes
Sachin Sharma

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



Re: [algogeeks] Re: Amazon

2011-07-07 Thread sachin sharma
What about this:

First you have the list of distances between two milestones. Let’s form a
table

Start milestone

End Milestone

Distances

A1

A0

7

A0

A3

10

A1

A2

5

A2

A3

2

A0

A2

8

A0

A1

3



I have taken above variable A0, A1, A2, A3 for a, b, c, d respectively. Now
we sort the first column. If we find two entries same then sort also on
based on second column.

After processing you will get the following table

Start milestone

End Milestone

Distances

A0

A1

3

A0

A2

8

A0

A3

10

A1

A0

7

A1

A2

5

A2

A3

2



When you get this table:

1)  Start with A0 and search for next milestone which is A1. Add this to
your milestone list or just print.

2)  Move to A1 in the first column and add the first entry which does
not contains previously visited milestone. That is A2 whose distance is 5.
You cannot add A1-A0 since it is already visited.

3)  Repeat the above process till the end of list in table. Now
following this step you come to A2 and you add A3 in the milestone list
whose distance is 2.

4)   Now you get the list of milestone…and distances. Output you get is
3-5-2 or 2-5-3.

I hope this will work.



Best Wishes
Sachin Sharma | Software Trainee | Information Mosaic
New York | Dublin | London | Luxembourg | New Delhi | Singapore | Melbourne
|
e-mail: sachinku...@informationmosaic.com
Web:www.informationmosaic.com<http://www.informationmosaic.com/> |  t:
www.twitter.com/infomosaic
Winner 2009 Banking Technology Readers' Choice Award for Best Corporate
Actions Automation Solution

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



Re: [algogeeks] preprocessor query

2011-06-29 Thread sachin sharma
@Anika Jain


#include#define FUN(a,b,c)c t; t=a;a=b;b=t;

int main(){
int a=2,b=3;
int *x,*y;
x=&a,y=&b;
printf("%d %d \n",a,b);
printf("%u %u \n",x,y);
FUN(x,y,int *);
printf("%d %d \n",a,b);
printf("%u %u \n",x,y);
return 0;}



Output:

1234

2 3
3212851908 3212851904
2 3
3212851904 3212851908




it is working fine. see the output.


Best Wishes
Sachin Sharma
University of 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.



Re: [algogeeks] OS

2011-06-22 Thread sachin sharma
@Rahul

Threads within a process share the same virtual memory space but each has a
separate stack, and possibly "thread-local storage". this thread local
storage is register and other private data. They are *lightweight* because a
context switch is simply a case of switching the stack pointer and program
counter and restoring other registers, wheras a *process*context switch
involves switching the MMU context as well.

Moreover, communication between threads within a process is
*lightweight* because
they share an address space.

Now

Option A is not right as it says Only register.

Option B is wrong as it directly opposes

Option C is correct as Threads share address space of Process. Virtually
memory is concerned with processes not with Threads

Option D is wrong as it says only scheduling and accounting.


Best Wishes
Sachin Sharma
University of 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.



Re: [algogeeks] MS

2011-06-18 Thread Sachin Jain
Sukhmeet can you please explain your approach ?

On Fri, Jun 17, 2011 at 3:48 PM, sukhmeet singh wrote:

> Can be done by any standard disk scheduling methods.. i guess
>
> On Tue, Jun 14, 2011 at 2:01 PM, Akshata Sharma  > wrote:
>
>> Design an elevator system for a 100 story building. Address all issues,
>> like number of elevators, speed of each (Not numerically), waiting times
>> etc. There would be 100-200 people living/working on each floor. (You don't
>> need to discuss the traffic patterns.)
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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] Design questions practice

2011-06-02 Thread Sachin Agarwal
Hi,
Can someone recommend me good resources (books/websites etc.) for
design interview questions.

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.



Re: [algogeeks] MS Q

2011-06-02 Thread Sachin Jain
Can you please tell What are we testing here ?.
I mean to ask what is the output of the function..

On Thu, Jun 2, 2011 at 7:49 PM, Ashish Goel  wrote:

> Given a function to draw a circle with input paramters as co-ordinates of
> centre of the circle and r is the radius of the circle.
> How will you test this function,  what will be additional non-functional
> test cases
>
>
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] MS question

2011-06-02 Thread Sachin Jain
Can someone please explain how is this working ??

On Thu, Jun 2, 2011 at 11:24 PM, Harshal  wrote:

> what do they want to test by asking such a question!
>
> On Thu, Jun 2, 2011 at 11:17 PM, Senthil S  wrote:
>
>> Output
>>
>> Hello! how is this? super
>> That is C!
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Harshal Choudhary,
> III Year B.Tech CSE,
> NIT Surathkal, Karnataka, India.
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Pile of nuts in an Oasis

2011-04-01 Thread Sachin Agarwal
A pile of nuts is in an oasis, across a desert from a town. The pile
contains 'N' kg of nuts, and the town is 'D' kilometers away from the
pile.
The goal of this problem is to write a program that will compute 'X',
the maximum amount of nuts that can be transported to the town.
The nuts are transported by a horse drawn cart that is initially next
to the pile of nuts. The cart can carry at most 'C' kilograms of nuts
at any one time. The horse uses the nuts that it is carrying as fuel.
It consumes 'F' kilograms of nuts per kilometer travelled regardless
of how much weight it is carrying in the cart. The horse can load and
unload the cart without using up any nuts.
Your program should have a function that takes as input 4 real numbers
D,N,F,C and returns one real number: 'X'
Do not worry about drinking water, or other "real world" issues.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: algo for mirror a tree

2011-03-13 Thread Sachin Agarwal
assuming its a binary tree

Node* mirror(Node* root){
   if(root==NULL)
return;

Node* mirrorLeft = mirror(root->left)'
Node* mirrorRight = mirror(root->right);

 root->left = mirrorRight;
 root->right=mirrorLeft;

 return root;
}

On Mar 11, 4:50 am, AKS  wrote:
> can u elaborate a bit ??
> with sm example if possible
>
> On Mar 11, 4:52 am, priyank desai  wrote:
>
>
>
>
>
>
>
> > Do a post order traversal of the tree and swap its child instead of
> > printing the node values.
>
> > On Mar 10, 8:19 am, Subhransupanigrahi 
> > wrote:
>
> > > Hey guys,
> > >  you guys have came across many time with mirror a tree. if  anyone has 
> > > effective ways interms of memory & efficiency way to implement mirror of 
> > > a tree.
>
> > > Sent from my iPhone

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: 9march

2011-03-09 Thread Sachin Agarwal
suppose the original length was 'x' cm and original width was 'y' cm.
After 3 wishes, the final length will be x/8 cm and width will be
reduced to x/27 cm

y=9 cm (given)
(x/8) * (y/27) = 4, solve for x whch will be 96cm

On Mar 9, 12:06 am, Lavesh Rawat  wrote:
> *Magic Belt Problem Solution*
> *
> *A magic wish-granting rectangular belt always shrinks to 1/2 its length and
> 1/3 its width whenever its owner makes a wish. After three wishes, the
> surface area of the belt's front side was 4 cm2.
> What was the original length, if the original width was 9 cm?
>
> *Update Your Answers at *: Click
> Here
>
> *Solution:*
> Will be updated after 1 day
>
> --
>
>                     "Never explain yourself. Your friends don’t need it and
> your enemies won’t believe 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.



[algogeeks] Re: Who Loves Circus .....

2011-03-03 Thread Sachin Agarwal
1. sort the pairs with key as one of the parameters
2. find the longest increasing sub-sequence (not necessarily
contiguous) from the sorted list with key the the other parameter.

Sachin

On Mar 1, 3:02 pm, bittu  wrote:
> A circus is designing a tower routine consisting of people standing
> atop one another’s
> shoulders. For practical and aesthetic reasons, each person must be
> both shorter and lighter than the person below him or her. Given the
> heights and weights of each person in the circus, write a method to
> compute the largest possible number of people
> in such a tower.
>
> for example
> Input (ht, wt): (65, 100) (70, 150) (56, 90) (75, 190) (60, 95) (68,
> 110)
> output..??
>
> Thanks & Regards
> Shashank

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: printing without loop

2011-03-02 Thread Sachin Midha
The method that I have given you, can print as many numbers as you
want, depending upon how many objects you create.
Yes with this method you'll have to create 100 objects of the dummy
class,
& that can be easily created using dummy d[100]
So that makes the method very effective & shows how much you can play
with C++...;-)

On Mar 1, 4:47 pm, gaurav gupta <1989.gau...@googlemail.com> wrote:
> @bittu
>
> please read the thread carefully. It was mentioned not to use GOTO
> statement.
>
>
>
>
>
>
>
>
>
> On Tue, Mar 1, 2011 at 5:13 PM, bittu  wrote:
> > here we go
>
> > void main()
> > {
> > int i;
>
> > i=1;
>
> > loop:
> > printf("%d", i)
> > (i<100)? i++: return 0;
> > go to loop;
>
> > }
>
> > Thanks & Regards
> > Shashank Mani >> "The Best Way to Escape From The Problem is to Solve
> > 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.
>
> --
> Thanks & Regards,
> Gaurav Gupta
> 7676-999-350
>
> "Quality is never an accident. It is always result of intelligent effort" -
> John Ruskin

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: printing without loop

2011-03-01 Thread Sachin Midha
Rather than iostream, include stdio.h, because we can't call main()
from main() in c++, but we can do that in C.

Best Regards,
Sachin Midha

On Mar 1, 10:49 pm, Himanshu Sachdeva 
wrote:
> #include
> int i=1;
> int main()
> {
> printf("%d\n",i++);
> return i==101?0:main();
>
> }
>
> On 3/1/11, Logic King  wrote:
>
>
>
>
>
>
>
>
>
> > yes..the solution given by sunny is awesome...well done !!
>
> > On Tue, Mar 1, 2011 at 6:25 PM, priya mehta wrote:
>
> >> @sunny This is awesome
>
> >> On Tue, Mar 1, 2011 at 6:25 PM, priya mehta
> >> wrote:
>
> >>> This is awesome 
>
> >>> On Tue, Mar 1, 2011 at 1:27 PM, sunny agrawal
> >>> wrote:
>
> >>>> int i=1;
> >>>> #define PRINT1 cout< >>>> #define PRINT2 PRINT1 PRINT1
> >>>> #define PRINT4 PRINT2 PRINT2
> >>>> #define PRINT8 PRINT4 PRINT4
> >>>> #define PRINT16 PRINT8 PRINT8
> >>>> #define PRINT32 PRINT16 PRINT16
> >>>> #define PRINT64 PRINT32 PRINT32
>
> >>>> int main()
> >>>> {
> >>>>      //as 100 = (1100100); we need to use PRINT64, PRINT32, and PRINT4
> >>>>      PRINT64;
> >>>>      PRINT32;
> >>>>      PRINT4;
> >>>> }
>
> >>>> This will print 1 to 100. You can use this code to print from 1 to x
> >>>> (x<=128). You can extend it to larger numbers, by adding PRINT128,
> >>>> PRINT256...etc.
>
> >>>> On 3/1/11, preetika tyagi  wrote:
> >>>> > May be we can use *goto *statement?
>
> >>>> > On Mon, Feb 28, 2011 at 10:36 PM, gaurav gupta
> >>>> > <1989.gau...@googlemail.com>wrote:
>
> >>>> >> Questions is : You have to print 1 to n without using any loop( for,
> >>>> >> while,
> >>>> >> do-while, goto ) and recursion.
>
> >>>> >> Any suggestion?
>
> >>>> >> On Tue, Mar 1, 2011 at 10:52 AM, preetika tyagi
> >>>> >> wrote:
>
> >>>> >>> Can you elaborate on it and provide more details?
>
> >>>> >>> On Mon, Feb 28, 2011 at 10:14 PM, Subhransupanigrahi <
> >>>> >>> subhransu.panigr...@gmail.com> wrote:
>
> >>>> >>>> Is there any way to print 1 to 10 (taking an example, it can also
> >>>> extend
> >>>> >>>> to 100) without using loop, recursion.
>
> >>>> >>>> Sent from my iPhone
>
> >>>> >>>> --
> >>>> >>>> You received this message because you are subscribed to the Google
> >>>> >>>> Groups
> >>>> >>>> "Algorithm Geeks" group.
> >>>> >>>> To post to this group, send email to algogeeks@googlegroups.com.
> >>>> >>>> To unsubscribe from 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.
>
> >>>> >> --
> >>>> >> Thanks & Regards,
> >>>> >> Gaurav Gupta
> >>>> >> 7676-999-350
>
> >>>> >> "Quality is never an accident. It is always result of intelligent
> >>>> effort"
> >>>> >> -
> >>>> >> John Ruskin
>
> >>>> > --
> >>>> > You received this message because you are subscribed to the Google
> >>>> Groups
> >>>> > "Algorithm Geeks" group.
> >>>> > To post to this group, send email to algogeeks@googlegroups.com.
> >>>&

[algogeeks] Re: Storing 1 million phone numbers

2011-03-01 Thread Sachin Midha
a trie can be considered as a tree with 26 child nodes, i.e. from 'a'
to 'z'where each node consists of a character.
E.g. to represent sachin, we create a trie which has s->a->c->h->i->n,
i.e. 6 nodes. Now when we want to add sachim into the database, we
just create another child node of i, which would be m. Now there are
two nodes going out from i.
This way we keep on adding nodes as and when required.
Now to detect each word, we end the word with a spl character, which
will be inserted after the last child node so that whenever we
encounter that character, we know that we have reached the end of a
word.

I hope my explanation was helpful...Do let me know in case you found
something difficult to understand...

Best Regards,
Sachin Midha

On Mar 1, 3:33 am, Sudhir mishra  wrote:
> please explain what is trie

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: printing without loop

2011-03-01 Thread Sachin Midha
Hey all...
I have another method, which will use the power of c++...

class dummy{
static int objectCount;
dummy(){ cout << ++objectCount <
wrote:
> Is there any way to print 1 to 10 (taking an example, it can also extend to 
> 100) without using loop, recursion.
>
> Sent from my iPhone

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Meetings puzzle

2011-02-08 Thread Sachin Agarwal
didn't quite get it, can you please elaborate.
thanks

On Feb 8, 10:38 pm, Ujjwal Raj  wrote:
> Use dynamic programming:
> 1) Sort the events in order of finishing time.
> f1, f2, f3, f4, ... fn
>
> E(fn) = E(sn) + 1;
> Solve the above recursion
> sn is start time of event n
>
> On Wed, Feb 9, 2011 at 11:30 AM, Sachin Agarwal
> wrote:
>
>
>
>
>
>
>
> > Suppose I have a room and I want to schedule meetings in it. You're
> > given a list of meeting start and end times. Find a way to schedule
> > the maximum number of meetings in the room.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algogeeks@googlegroups.com.
> > To unsubscribe from 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] Meetings puzzle

2011-02-08 Thread Sachin Agarwal
Suppose I have a room and I want to schedule meetings in it. You're
given a list of meeting start and end times. Find a way to schedule
the maximum number of meetings in the room.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: fork() problem

2010-09-06 Thread Sachin Midha
The answer is 19, but it is compiler dependent, ill explain that at
the very end.

L1 - Fork(1);
L2 - Fork(2) && Fork (3) || Fork (4);
L3 - Fork (5);

Suppose our initial process was P0.
After L1, we have P0 & its child P1. This is pretty clear.
At L2, after first fork(), P0 creates P2, P2's work for L2 is
finished, since it returns a 0(fork gives a 0 to child & child's pid
to parent), and due to C's short circuiting technique, nothing after
&& executes.(since 0 && ..., C does not evaluate any further).
At L2, after 2nd fork(), P0 creates P3, P0's work for L2 is finished,
since (true && true) becomes true & does not evaluate any further the
|| part.
At L2, after 3rd fork(), P3 creates P4.
Work at L2 done.
After L3, P0 to P4, create children from P5 to P9,i.e., 10 processes
in total.
Similarly for the first child of P0, P1, 10 processes are created,
totalling 20 processes, out of which if we remove the original
process, we get 19 processes.

Now, the compiler dependent part.
L2 - Fork(2) && Fork (3) || Fork (4);

if we look at this statement, we'll find that this can be interpreted
in two ways.
(fork() && fork()) || fork() -- if this is how it is interpreted by
the compiler, answer will be different.
or
fork() && fork() || fork() -- this is the interpreted expr for our
solution, the way we have reached it -- if first fork() evaluates to
false, nothing after that executes on the line.

But what I feel is that the interpreted expression should be first &
not the second, and ans should not be 19. But again I think it is the
way complier interprets it, hence compiler dependent. I hope some of
you would have got my point. If still you feel that it is not complier
dependent, please post here with some facts.(I still feel it should
not be compiler dependent but first expr, but b'coz diff people are
getting diff ans, this supports the fact that it is compiler
dependent).


On Sep 6, 11:27 am, jayesh  wrote:
> and on running this code the process is printd 17 times, how is the
> answer 19??im getting 31(including the initial process).plz
> explain.
>
> On Sep 6, 7:07 am, PremShankar Kumar  wrote:
>
>
>
> > @Sachin, @Mohit:-
>
> > You are right 19 new processes will get created. Thanks guys.
>
> > #include 
> > #include
>
> > using namespace std;
>
> > int Fork(int i)
> > {
> >           //cout< >           return fork();}
>
> > int main()
> > {
> >            Fork(1);
> >            Fork(2) && Fork (3) || Fork (4);
> >            Fork (5);
> >            cout<
> > Regards,
> > Prem
>
> > On Sun, Sep 5, 2010 at 9:35 PM, sachin  wrote:
> > > Yes, you are right mohit, the no of processes is indeed 20.
> > > but the question asks for the no of new processes created, not the
> > > total no of processes.
> > > Hence, we subtract the initial process from the final ans, we get 19.,
> > > which is the required answer...:-) :-)
>
> > > On Sep 4, 11:10 pm, "MOHIT "  wrote:
> > > > Fork() && fork () || fork ();
> > > > Fork return 0 in child process and non-zero in parent
> > > > so in child process Fork()&& only executed not fork()||fork();(&& stop
> > > > working if get 0 as previous input);
>
> > > > if we get parent after parent only fork of (&& ) and initial fork of ||
> > > get
> > > > executed;(|| stops if one input is 1 next one not evaluated).
>
> > > > if we get child after parent whole fork && fork()|| fork() get executed.
>
> > > > but answer comes 20.
> > > > plz correct me if i am wrong
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Algorithm Geeks" group.
> > > To post to this group, send email to algoge...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > algogeeks+unsubscr...@googlegroups.com > >  .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 algoge...@googlegroups.com.
To unsubscribe from 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: fork() problem

2010-09-05 Thread sachin
Yes, you are right mohit, the no of processes is indeed 20.
but the question asks for the no of new processes created, not the
total no of processes.
Hence, we subtract the initial process from the final ans, we get 19.,
which is the required answer...:-) :-)

On Sep 4, 11:10 pm, "MOHIT "  wrote:
> Fork() && fork () || fork ();
> Fork return 0 in child process and non-zero in parent
> so in child process Fork()&& only executed not fork()||fork();(&& stop
> working if get 0 as previous input);
>
> if we get parent after parent only fork of (&& ) and initial fork of || get
> executed;(|| stops if one input is 1 next one not evaluated).
>
> if we get child after parent whole fork && fork()|| fork() get executed.
>
> but answer comes 20.
> plz correct me if i am wrong

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from 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: Adobe Questions

2010-08-20 Thread sachin
The answer for first question would be a segmentation fault...since
none of a or b has been allocated any memory.
Had it been A *a=new A; then the call to a->print() would not result
into a segmentation fault.

I think the purpose of this question was to know about this pointer
concept about dynamic allocation and the statement A *b=NULL; was only
given to puzzle someone.


On Aug 19, 4:56 pm, luckyzoner  wrote:
> 1. Suppose a class A is given as :
>
> class A
>        {
>           public :
>                      void print()
>                        {
>                             cout<<"Hello";
>                        }
>       }
>
>  int main()
>     {
>        A * a;
>        A* b = NULL;
>
>       a->print();
>       b->print();
>
>  }
>
> What is the output?
>
> 2. Given an array containing 0,1,2 in any order. Sort the array in a
> single pass.
> 3. Write a code to implement spiral traversal of the BST.
> 4. Given a string containing the binary representation of a number.
> Write a code to find the 2s complement of the  number.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from 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: Median of two arrays..

2010-08-13 Thread sachin
If the ranges of the arrays are 1..n & 1..m, then we can solve it this
way

if ((m+n)&1){
  we can go with the method same as rahul patil's and in the condition
we can use count<=(m+n)/2+1, the median will be stored in res.
}
else{
  we can go with the method same as rahul patil's and in the condition
we can use count<=(m+n)/2+1 and the median in this case will be the
average of elements at count (m+n)/2 & at count (m+n)/2+1.So, we will
have to store the last element in this case.
}

On Aug 11, 5:25 pm, rahul patil  wrote:
> is there any time complexity?
>
> the also can be like this
>
> char *res;
> char *ptr1 =arr1;
> char *ptr2 =arr2;
> int count =0, n= len(arr1) ,m=len(arr2);
> while(1){
>          while(*ptr1 > *ptr2){
>                   ptr2++;
>                   count ++;
>                   if( count == (n+m)/2 ){
>                        res=ptr1;
>                        break out of outer while loop;
>                   }
>          }
>
>          while(*ptr1 < *ptr2){
>                   ptr1++;
>                   count ++;
>                   if( count == (n+m)/2 ){
>                        res=ptr2;
>                        break out of outer while loop;
>                   }
>          }
>
> }
>
> On Aug 6, 7:20 pm, Manjunath Manohar  wrote:
>
> > will this work in two sorted arrays of equal length..

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from 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] Call a function before main() in C

2010-06-30 Thread sachin sharma
THIS CODE IS GIVES EXPECTED OUTPUT ON TURBO ONLY

On Wed, Jun 30, 2010 at 1:22 PM, anand verma wrote:

> i tried this c code on gcc compiler...
>
> this code doesn't give expected output.
>
> OUTPUT: i  m inside main
>
> y?
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from 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...
Sachin Sharma

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from 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] Call a function before main() in C

2010-06-29 Thread sachin sharma
yes u can do in c using the pragma Directive


there are two directive that allowes u to runyour function before the call
to main or termination of the main
1) #pragma startup
2) #pragma exit



implementation:

void beforemain();
void aftermain();


#pragma  startup beforemain
#pragma  startup aftermain



int main()
{
   printf("\ni  m inside main\n");
return 0;
}



void beforemain()
{
printf("\ni m before the main and is executing.!!!\n");
}



void aftermain()
{
printf("\ni m after termination of main and is
executing.!!!\n");
}

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from 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: Finding the mode in a set of integers

2010-04-15 Thread sachin
I feel gaurav's solution does it in O(n) time & cons space
but there is a case that when there is no element with n/2+1
appearances the method might fail(eg 1 1 1 2 3 4 and in many other
cases as well...)
but as the problem states that there is atleast 1 element with n/2+1
appearancesthis algo provides the answer to above question.

On Apr 15, 1:09 pm, Rohit Saraf  wrote:
> *FINAL SOLUTION* :
>
> I gave a second thought :
>
> A large amount of space(but finite constant and bounded and within practical
> limits) will eventually be required for my hashing based solution to be
> worst case O(n).
> So this problem has an linear time solution..
>
> BUT can we do better in terms of space maintaining the time complexity?
> Well, I claim that we cannot ! :(
>
> Can anyone disprove/prove that we can do better ??
> I don't think the 2 solutions above work
>
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14
>
> On Thu, Apr 15, 2010 at 10:13 AM, Rohit Saraf
> wrote:
>
>
>
> > the implementation of the hashmap in prev soln(to achieve constant time) is
> > non-trivial and is based on some exercise of Cormen.
>
> > better  and simple:
>
> > Think of these points as nodes of the graph
> > use the UnionFind(quickunion) data structure... and everytime a union is
> > done add 1 to the component united.
> > find the one with count>500
>
> > --
> > Rohit Saraf
> > Second Year Undergraduate,
> > Dept. of Computer Science and Engineering
> > IIT Bombay
> >http://www.cse.iitb.ac.in/~rohitfeb14
>
> > On Thu, Apr 15, 2010 at 9:16 AM, Rohit Saraf 
> > wrote:
>
> >> I agree But that worst case will never come here. There are
> >> between 2 and 500 keys. And all keys are different So how would
> >> the worst case come??
>
> >> On 4/14/10, gaurav kishan  wrote:
> >> > This will be done in one pass i.e O(n).
> >> > On Wed, Apr 14, 2010 at 10:17 PM, gaurav kishan
> >> > wrote:
>
> >> >> Can everyone check this out and let me the issues ?
>
> >> >> int[] i=new
> >> >> int[]{11,2,3,11,4,11,76,11,11,65,11,44,78,11,13,11,79,11,11,11,56};
> >> >> int count=1,element=i[0];
> >> >>  for(int j=1;j >> >>  {
> >> >>    if(element==i[j])
> >> >>      count++;
> >> >>    else
> >> >>    {
> >> >>      count--;
> >> >>     if(count==0)
> >> >>      {
> >> >>        element=i[j];
> >> >>          count=1;
> >> >>       }
> >> >>      }
>
> >> >>  }
> >> >>   System.out.println("Mode is "+element);
> >> >>   }
>
> >> >> Regards,
> >> >> Gaurav Kishan
>
> >> >> On Wed, Apr 14, 2010 at 10:01 PM, sharad kumar
> >> >> wrote:
>
> >> >>> ya over here its >501 rite?
>
> >> >>> On Wed, Apr 14, 2010 at 8:24 PM, Prakhar Jain 
> >> wrote:
>
> >>  If m thinking right,
> >>  That works if mode occurs >=n/2 times in the array
>
> >>  Best,
> >>  Prakhar Jain
> >> http://web.iiit.ac.in/~prakharjain/
>
> >>    On Wed, Apr 14, 2010 at 8:12 PM, sharad kumar <
> >> aryansmit3...@gmail.com
> >>  > wrote:
>
> >> >  can we make use of majority VOTE ALGORITHM?
>
> >> > On Wed, Apr 14, 2010 at 4:14 PM, Gauri  wrote:
>
> >> >> Say If I have an array of 1,000 32-bit integers .And one of the
> >> value
> >> >> is occuring 501 number of times or more in the array. Can someone
> >> help
> >> >> me devise an efficient algorithm for the same ?
>
> >> >> Thanks & Regards
> >> >> Gauri
>
> >> >> --
> >> >> You received this message because you are subscribed to the Google
> >> >> Groups "Algorithm Geeks" group.
> >> >> To post to this group, send email to algoge...@googlegroups.com.
> >> >> To unsubscribe from this group, send email to
> >> >> algogeeks+unsubscr...@googlegroups.com >> >>  .com>
> >>  >>  roups.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 algoge...@googlegroups.com.
> >> > To unsubscribe from this group, send email to
> >> > algogeeks+unsubscr...@googlegroups.com >> >  .com>
> >>  >>  roups.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 algoge...@googlegroups.com.
> >>  To unsubscribe from this group, send email to
> >>  algogeeks+unsubscr...@googlegroups.com >>   .com>
> >>  >>  roups.com>
>
> >>  .
> >>  For more options, visit this group at
> >> http://groups.google.com/group/algogeeks?hl=en.
>
> >> >>> --
> >> >>>  You re

[algogeeks] Re: Algorithm intensive Please solve

2010-02-13 Thread sachin
We can make a spanning tree for these 2N points and then find the
minimum spanning tree
keeping in mind that a node can only be considered in one edge and not
more than once.
This will give you the minimum total sum of all the pairs.
You can use kruskal's min spanning tree algorithm to find the minimum
spanning tree because
kruskal's method works by finding the least cost edges & then
proceeding towards the max cost edges.
I hope it solves your problem.

Regards,
Sachin


On Feb 12, 9:20 am, GentLeBoY  wrote:
> given 2N points in a plane. Pair up to obtain N distinct pairs such
> that total sum of paired distances is minimum.
> N can be atmost 50.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from 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: missing integers in an unsorted array

2010-02-01 Thread sachin
A way to solve this problem would be using xor(exclusive OR)
xor all the elements from 1 to n.Call it A
xor all the elements of the array into a variable B
Now missing element = A xor B
It works this way
xor-ing an element with itself gives 0(p xor p=0)
xor-ing an element with 0 gives the element itself(p xor 0=p)
xor-ing an element with 1 gives the complement of element(p xor
1=complement(p))

Now suppose you are given 4 elements and you have to find the missing
5th element
A=1 xor 2 xor 3 xor 4 xor 5;
B=ar[1] xor ar[2] xor ar[3] xor ar[4];

let array be {2,5,3,1}
thus, B=1 xor 2 xor 3 xor 5;

Now A xor B = (1 xor 1) xor (2 xor 2) xor (3 xor 3)  xor (5 xor 5) xor
4 = 0 xor 0 xor 0 xor 0 xor 4 = 4(the missing element).

Regards
Sachin

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from 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: HONEYWELL TECH WALKIN ON 5 MAY 2007,HURRY!

2007-05-03 Thread sachin shenoy

Oh yeah!

On May 2, 11:03 am, "smita arora" <[EMAIL PROTECTED]> wrote:
> *HONEYWELL  TECH WALKIN  ON 5 MAY 2007*
>
> Diverse, focused, committed and fun - that is what HTSL's work culture is
> like. Working at HTSL is not about work, work and more work. Pursuing higher
> education, presenting papers, taking a 'sabbatical' besides participating in
> a host of 'beyond work' activities where one's families are also an integral
> part is just a brief glimpse of one's working life at HTSL. Here, building
> relationships while exploring your full potential comes easy. Being
> recognized, being rewarded and having the right balance between work and
> play is all a part of the ethos of HTSL.
> *
> To View the content and to apply
>  http://www.discussionsworld.com/forum_posts.asp?TID=11513
>
>  *
>
> *PS: Have you received your FREE Freshers Guide 2007 Edition. If not, get it
> free once you register at DiscussionsWorld.com. 50,000 members already
> received it free!http://www.discussionsworld.com/registration_rules.asp?FID=0*


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: algo problem

2007-04-15 Thread Sachin

http://en.wikipedia.org/wiki/Longest_increasing_subsequence_problem

This link depicts an algorithm, which is O(nlogn) algo.
Approach: dynamic programming.

On 4/15/07, Daniel Bastidas <[EMAIL PROTECTED]> wrote:
> if you can find the programming challenge book, there is a Longest
> Increasing Subsequence algorithm
>
> On 4/14/07, Muntasir Azam Khan <[EMAIL PROTECTED]> wrote:
> >
> >  This is a very common problem. Search for 'Longest Increasing
> > Subsequence' at Google.
> >
> > Muntasir
> >
> > - Original Message -
> >
> > *From:* monty 1987 <[EMAIL PROTECTED]>
> > *To:* algogeeks@googlegroups.com
> > *Sent:* Saturday, April 14, 2007 5:52 PM
> > *Subject:* [algogeeks] algo problem
> >
> > My problem is to find out longest subsequence of integers in increasing
> > order in an array of integers.
> > If any one have solution tell it to me.
> >
> > >
> >
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---