Re: [algogeeks] direct i

2011-07-27 Thread ankit sambyal
O(n^2) algo is trivial. Can anybody think of a better approach ???

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

2011-07-27 Thread Anand Saha
I don't think so. Try it on {2, 5, 1, 7} and {5, 7, 1, 2}

-- 


On Wed, Jul 27, 2011 at 10:33 AM, Sonal Maheshwari sonal...@gmail.comwrote:

 i think the following shud work:

 i=j=0;
 while(i n  jn) // n is the number of elements in the array
 {
   if ( a[i]  b[j] )
   {
   pos= find(b, a[i]); ///find the position of a[i] in
 array b
   swap ( b[j], b[pos] ); //swapping the two numbers
   }
   else if ( a[i]  b[j] )
   {
   pos= find(a, b[j]); ///find the position of b[j] in
 array a
   swap ( a[i], a[pos] ); //swapping the two numbers
   }
   i++;
   j++;
 }

 Correct me if m wrong...

 On Jul 27, 8:46 am, siva viknesh sivavikne...@gmail.com wrote:
  Given two arrays
  a[] = {1,3,2,4}
  b[] = {4,2,3,1}
  both will have the same numbers but in different combination.
  We have to sort them . The condition is that you cannot compare only
  elements within the same array.You can compare element of one array
  with
  another only.
 
  On Jul 27, 8:45 am, sivaviknesh s sivavikne...@gmail.com wrote:
 
 
 
 
 
 
 
   -- Forwarded message --
   From: Padmaja Sridharan padmaja...@yahoo.in
   Date: Wed, Jul 27, 2011 at 5:15 AM
   Subject: SORTING ARRAYS
   To: mitcse08i...@googlegroups.com
 
   Given two arrays
   a[] = {1,3,2,4}
   b[] = {4,2,3,1}
   both will have the same numbers but in different combination.
   We have to sort them . The condition is that you cannot compare only
   elements within the same array.You can compare element of one array
 with
   another only.
 
   ~With Regards
   Padmaja
 
   --
   Regards,
   $iva

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



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



Re: [algogeeks] Re: AMAZON Q

2011-07-27 Thread Rajeev Kumar
Hey ankit, i gave java code also...didn't u check it in the link...anyway i
am explaining here.

*Note : Position count starts from 0. *
*ex: {1,2,3,4} ...position of '1' is zero*
*
*
*In the below approach,we are checking element position in the modified
list(after deletion operation in the previous iteration).*

given array is : ar[]= {1,3,2,4,5,4,2}.
construct a list with array elements and sort it.Now list contains
:1,2,2,3,4,4,5

Now traverse through array elements from i=0 to n-1(start to end)
store result in result[] array.

list is *1*-2-2-3-4-4-5
for i=0, a[0]=1,search for a[0] position in the list(right
occurrence).a[0]=1 position in list is '0'
add '0' to result.===result[0]=0;
remove the element a[0] from the list.now list contains 2-2-*3*-4-4-5

for i=1,a[1]=3,search for a[1] position in the list(right occurence).a[1]=3
position in list is '2'
  add '2' to resultresult[1]=2
remove the element a[1] from the list.now list contains 2-*2*-4-4-5


for i=2,a[2]=2,search for a[2] position in the list(right occurence).a[2]=2
position in list is '1'
  add '1' to resultresult[2]=1
remove the element a[2] from the list.now list contains 2-4-*4*-5


for i=3,a[3]=4,search for a[3] position in the list(right occurence).a[3]=4
position in list is '2'
  add '2' to resultresult[3]=2
remove the element a[3] from the list.now list contains 2-4-5


for i=4,a[4]=5,search for a[4] position in the list(right occurence).a[4]=5
position in list is '2'
  add '2' to resultresult[4]=2
remove the element a[4] from the list.now list contains 2-*4*


for i=5,a[5]=4,search for a[5] position in the list(right occurence).a[5]=4
position in list is '1'
  add '1' to resultresult[5]=1
remove the element a[5] from the list.now list contains 2


for i=6,a[6]=2,search for a[6] position in the list(right occurence).a[6]=2
position in list is '0'
  add '0' to resultresult[6]=0
remove the element a[6] from the list.now list is empty.


resultant array contains :
from all conditions :
add '0' to result.===result[0]=0;
add '2' to resultresult[1]=2
add '1' to resultresult[2]=1
add '1' to resultresult[3]=2
add '2' to resultresult[4]=2
add '1' to resultresult[5]=1
add '0' to resultresult[6]=0

expected result   {0,2,1,2,2,1,0}
actual result =={0,2,1,2,2,1,0}


I hope u r clear now.Please let me know if you still have
doubts...

U can execute the java code given in link :
http://rajeevprasanna.blogspot.com/2011/07/count-number-of-min-elements-on-right.html

I will be more happy if you give me failed cases...



On Wed, Jul 27, 2011 at 11:25 AM, ankit sambyal ankitsamb...@gmail.comwrote:

 @rajeev :try the example given in the question. And explain ur algo with
 that example




-- 
Thank You
Rajeev 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.



Re: [algogeeks] Re: Amazon Question

2011-07-27 Thread sunny agrawal
@shiva viknesh
this is a different Question...

@saurabh
how is nlgn possible, total no of possible substrings are n^2


this is the O(n^2) solutionOn Wed, Jul 27, 2011 at 8:09 AM, saurabh singh

for(int l = 0; l  len; l++){
                for(int i = 0; i  len-l; i++){
                        int j = i+l;
                        char temp = s[j+1];
                        s[j+1] = 0;
                        printf(%s\n, s+i);
                        s[j+1] = temp;
                }
        }

saurab...@gmail.com wrote:

 using suffix tree this can be done in o(nlogn) though will take extra space.

 On Wed, Jul 27, 2011 at 12:47 AM, siva viknesh sivavikne...@gmail.com wrote:

 http://geeksforgeeks.org/?p=767

 On Jul 26, 11:49 pm, Pratz mary pratima.m...@gmail.com wrote:
  how?
 
  On 26 July 2011 23:18, ankit sambyal ankitsamb...@gmail.com wrote:
 
   @vivin : Suffix trees are memory intensive..
 
   This problem can be solved just by running 2 nested loops in O(1)
   space and O(n^2) time
 
   --
   You received this message because you are subscribed to the Google Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  regards Pratima :)

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




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD


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



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

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



[algogeeks] MS interview:

2011-07-27 Thread geek forgeek
Function to display the directory structure in a user friendly way taking
root dir as arg
for a general OS. You may assume and state some basic APIs available in that
OS

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

2011-07-27 Thread geek forgeek
anyone??

On Tue, Jul 26, 2011 at 11:36 PM, geek forgeek geekhori...@gmail.comwrote:

 Function to display the directory structure in a user friendly way taking
 root dir as arg
 for a general OS. You may assume and state some basic APIs available in
 that OS


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

2011-07-27 Thread salvador_cerinza
Best case : O(n)
Worst case : O(n^2)
can be done using stack.

Thinking of better solution. .

On Wed, Jul 27, 2011 at 11:50 AM, ankit sambyal ankitsamb...@gmail.comwrote:

 O(n^2) algo is trivial. Can anybody think of a better approach ???

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

2011-07-27 Thread Pankaj
Even in array best case can be O(n). Why use stack?
On Wed, Jul 27, 2011 at 12:14 PM, salvador_cerinza 
vishwakarma.ii...@gmail.com wrote:

 Best case : O(n)
 Worst case : O(n^2)
 can be done using stack.

 Thinking of better solution. .


 On Wed, Jul 27, 2011 at 11:50 AM, ankit sambyal ankitsamb...@gmail.comwrote:

 O(n^2) algo is trivial. Can anybody think of a better approach ???

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

2011-07-27 Thread salvador_cerinza
i m  suggesting stack  not just for best case only .

On Wed, Jul 27, 2011 at 12:16 PM, Pankaj jatka.oppimi...@gmail.com wrote:

 Even in array best case can be O(n). Why use stack?
 On Wed, Jul 27, 2011 at 12:14 PM, salvador_cerinza 
 vishwakarma.ii...@gmail.com wrote:

 Best case : O(n)
 Worst case : O(n^2)
 can be done using stack.

 Thinking of better solution. .


 On Wed, Jul 27, 2011 at 11:50 AM, ankit sambyal 
 ankitsamb...@gmail.comwrote:

 O(n^2) algo is trivial. Can anybody think of a better approach ???

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


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


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


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



Re: [algogeeks] direct i

2011-07-27 Thread Pankaj
Can you please elaborate a little about your stack based solution. I was
thinking of using queue but was unable to make a perfect algo.

On Wed, Jul 27, 2011 at 12:18 PM, salvador_cerinza 
vishwakarma.ii...@gmail.com wrote:

 i m  suggesting stack  not just for best case only .


 On Wed, Jul 27, 2011 at 12:16 PM, Pankaj jatka.oppimi...@gmail.comwrote:

 Even in array best case can be O(n). Why use stack?
 On Wed, Jul 27, 2011 at 12:14 PM, salvador_cerinza 
 vishwakarma.ii...@gmail.com wrote:

 Best case : O(n)
 Worst case : O(n^2)
 can be done using stack.

 Thinking of better solution. .


 On Wed, Jul 27, 2011 at 11:50 AM, ankit sambyal 
 ankitsamb...@gmail.comwrote:

 O(n^2) algo is trivial. Can anybody think of a better approach ???

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


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


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


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


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



Re: [algogeeks] direct i

2011-07-27 Thread salvador_cerinza
Let say stack S.
1.insert elements in S of A[] from right to left.
2.int val = S.top();
3.S.pop();
4.now check val with S.top() until u find any element smaller than val.
5.Note down the element pop it from stack
6.if step 4 is true , the push val in stack S and all elements which were
popped in the order they were popped except the last matched candidate
element.

Yeah..dis algo is not very efficient..

On Wed, Jul 27, 2011 at 12:20 PM, Pankaj jatka.oppimi...@gmail.com wrote:

 Can you please elaborate a little about your stack based solution. I was
 thinking of using queue but was unable to make a perfect algo.


 On Wed, Jul 27, 2011 at 12:18 PM, salvador_cerinza 
 vishwakarma.ii...@gmail.com wrote:

 i m  suggesting stack  not just for best case only .


 On Wed, Jul 27, 2011 at 12:16 PM, Pankaj jatka.oppimi...@gmail.comwrote:

 Even in array best case can be O(n). Why use stack?
 On Wed, Jul 27, 2011 at 12:14 PM, salvador_cerinza 
 vishwakarma.ii...@gmail.com wrote:

 Best case : O(n)
 Worst case : O(n^2)
 can be done using stack.

 Thinking of better solution. .


 On Wed, Jul 27, 2011 at 11:50 AM, ankit sambyal ankitsamb...@gmail.com
  wrote:

 O(n^2) algo is trivial. Can anybody think of a better approach ???

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


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


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


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


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


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



Re: [algogeeks] Re: Fwd: SORTING ARRAYS

2011-07-27 Thread ankit sambyal
Following is the working code :Time complexity : O(n^2)  Space
complexity : O(1)


void swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}
/*num is the number which is searched in the array arr[]. index is the index
in the array arr[] by which the searched number is to be replaced*/
int searchAndReplace(int arr[],int size,int num,int index)
{
int i=index+1;
while(isize)
{
if(arr[i]==num)
break;
i++;
}
if(isize)
swap(arr[i],arr[index]);
}
void sort(int arr1[],int arr2[],int size)
{
int i=0,j;
while(isize)
{
j=0;
while(jsize)
{
if(arr2[j]arr1[i])
searchAndReplace(arr1,size,arr2[j],i);
j++;
}
i++;
}
}
int main()
{
int arr1[]={2,5,1,7};
int arr2[]={5,7,1,2};
sort(arr1,arr2,4);
int i;
for(i=0;i4;i++)
printf(%d  ,arr1[i]);
return 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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] quick sort query

2011-07-27 Thread prateek gupta
void quicksort( T[] A, Integer left, Integer right)
if ( left  right )
q = partition( A, left, right) ;
quicksort ( A, left, q–1);
quicksort ( A, q+1, right) ;

Integer partition( T[] A, Integer left, Integer right)
m = left + right / 2;
swap( A[left],  A[m]);
pivot = A[left] ;
lo = left+1; hi = right;
while ( lo ≤ hi )
while ( A[hi]  pivot )
  hi = hi – 1;
while ( lo ≤ hi and A[lo] 
∼ pivot )
  lo = lo + 1;
if ( lo ≤ hi )
  swap( A[lo], A[hi]);
   lo = lo + 1;  hi = hi – 1;
swap( A[left], A[hi]);
return hi

plz tell me the case for (lo=hi) in while loop in partition.

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

2011-07-27 Thread pacific :-)
O(nlogn)
1. precompute the minimum of [ i+1 N] and store in b[i]
2. Now do a binary search for a[i] in b[i+1] in the range of  b[i+1. N]

On Wed, Jul 27, 2011 at 12:27 PM, salvador_cerinza 
vishwakarma.ii...@gmail.com wrote:

 Let say stack S.
 1.insert elements in S of A[] from right to left.
 2.int val = S.top();
 3.S.pop();
 4.now check val with S.top() until u find any element smaller than val.
 5.Note down the element pop it from stack
 6.if step 4 is true , the push val in stack S and all elements which were
 popped in the order they were popped except the last matched candidate
 element.

 Yeah..dis algo is not very efficient..


 On Wed, Jul 27, 2011 at 12:20 PM, Pankaj jatka.oppimi...@gmail.comwrote:

 Can you please elaborate a little about your stack based solution. I was
 thinking of using queue but was unable to make a perfect algo.


 On Wed, Jul 27, 2011 at 12:18 PM, salvador_cerinza 
 vishwakarma.ii...@gmail.com wrote:

 i m  suggesting stack  not just for best case only .


 On Wed, Jul 27, 2011 at 12:16 PM, Pankaj jatka.oppimi...@gmail.comwrote:

 Even in array best case can be O(n). Why use stack?
 On Wed, Jul 27, 2011 at 12:14 PM, salvador_cerinza 
 vishwakarma.ii...@gmail.com wrote:

 Best case : O(n)
 Worst case : O(n^2)
 can be done using stack.

 Thinking of better solution. .


 On Wed, Jul 27, 2011 at 11:50 AM, ankit sambyal 
 ankitsamb...@gmail.com wrote:

 O(n^2) algo is trivial. Can anybody think of a better approach ???

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


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


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


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


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


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




-- 
regards,
chinna.

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



Re: [algogeeks] Re: MS interview:

2011-07-27 Thread sunny agrawal
There is a Book: Advance Programming in Unix Environment by Richard Stevens
in Chapter 2 i think there is a code that does the job of directory Listing
for given Directory

this is the code - for directory listing

*#include dirent.h
int main(int argc, char *argv[])
{
DIR *dp;
struct dirent *dirp;
if (argc != 2)
err_quit(usage: ls directory_name);
if ((dp = opendir(argv[1])) == NULL)
err_sys(can't open %s, argv[1]);
while ((dirp = readdir(dp)) != NULL)
printf(%s\n, dirp-d_name);
closedir(dp);
exit(0);
}*


for this Question u just need to change this code and use recursion for
directory inside Directories
there are some attributes that are used to identify some object as file,
directory, root directory and parent directory. so in recursion u will take
care for those

On Wed, Jul 27, 2011 at 12:13 PM, geek forgeek geekhori...@gmail.com
wrote:
 anyone??

 On Tue, Jul 26, 2011 at 11:36 PM, geek forgeek geekhori...@gmail.com
 wrote:

 Function to display the directory structure in a user friendly way taking
 root dir as arg
 for a general OS. You may assume and state some basic APIs available in
 that OS

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




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

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



Re: [algogeeks] Re: Amazon Question

2011-07-27 Thread surender sanke
@sunny
consider *uncompressed* suffix tree, even with distinct elements maximum
number of nodes with string length n formed will be 2n.
once suffix tree is constructed, needs to traverse in dfs order appending
the node found on the way.
total complexity would be O(construction of suffix tree ) + O(traverse
time).

surender


On Wed, Jul 27, 2011 at 12:00 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 @shiva viknesh
 this is a different Question...

 @saurabh
 how is nlgn possible, total no of possible substrings are n^2


 this is the O(n^2) solutionOn Wed, Jul 27, 2011 at 8:09 AM, saurabh singh

 for(int l = 0; l  len; l++){
 for(int i = 0; i  len-l; i++){
 int j = i+l;
 char temp = s[j+1];
 s[j+1] = 0;
 printf(%s\n, s+i);
 s[j+1] = temp;
 }
 }

 saurab...@gmail.com wrote:
 
  using suffix tree this can be done in o(nlogn) though will take extra
 space.
 
  On Wed, Jul 27, 2011 at 12:47 AM, siva viknesh sivavikne...@gmail.com
 wrote:
 
  http://geeksforgeeks.org/?p=767
 
  On Jul 26, 11:49 pm, Pratz mary pratima.m...@gmail.com wrote:
   how?
  
   On 26 July 2011 23:18, ankit sambyal ankitsamb...@gmail.com wrote:
  
@vivin : Suffix trees are memory intensive..
  
This problem can be solved just by running 2 nested loops in O(1)
space and O(n^2) time
  
--
You received this message because you are subscribed to the Google
 Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --
   regards Pratima :)
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
  --
  Saurabh Singh
  B.Tech (Computer Science)
  MNNIT ALLAHABAD
 
 
  --
  You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



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

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



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



Re: [algogeeks] The Google Resume

2011-07-27 Thread Prem Krishna Chettri
Anyone got this book?? pdf.. or URL link is highly appreciated.

Thx..

On Tue, Jul 26, 2011 at 8:37 PM, Ankur Garg ankurga...@gmail.com wrote:

 +1
 Me too looking out for the same :(


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

 +1

 Pls send to my email id as well..


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

 Anyone having the Google Resume book pdf?

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


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


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


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



Re: [algogeeks] Re: Amazon Question

2011-07-27 Thread sunny agrawal
But still Printing O(N^2) substrings will take O(N^2) time isn't it ?

On Wed, Jul 27, 2011 at 12:39 PM, surender sanke surend...@gmail.comwrote:



 @sunny
 consider *uncompressed* suffix tree, even with distinct elements maximum
 number of nodes with string length n formed will be 2n.
 once suffix tree is constructed, needs to traverse in dfs order appending
 the node found on the way.
 total complexity would be O(construction of suffix tree ) + O(traverse
 time).

 surender


 On Wed, Jul 27, 2011 at 12:00 PM, sunny agrawal 
 sunny816.i...@gmail.comwrote:

 @shiva viknesh
 this is a different Question...

 @saurabh
 how is nlgn possible, total no of possible substrings are n^2


 this is the O(n^2) solutionOn Wed, Jul 27, 2011 at 8:09 AM, saurabh singh

 for(int l = 0; l  len; l++){
 for(int i = 0; i  len-l; i++){
 int j = i+l;
 char temp = s[j+1];
 s[j+1] = 0;
 printf(%s\n, s+i);
 s[j+1] = temp;
 }
 }

 saurab...@gmail.com wrote:
 
  using suffix tree this can be done in o(nlogn) though will take extra
 space.
 
  On Wed, Jul 27, 2011 at 12:47 AM, siva viknesh sivavikne...@gmail.com
 wrote:
 
  http://geeksforgeeks.org/?p=767
 
  On Jul 26, 11:49 pm, Pratz mary pratima.m...@gmail.com wrote:
   how?
  
   On 26 July 2011 23:18, ankit sambyal ankitsamb...@gmail.com wrote:
  
@vivin : Suffix trees are memory intensive..
  
This problem can be solved just by running 2 nested loops in O(1)
space and O(n^2) time
  
--
You received this message because you are subscribed to the Google
 Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --
   regards Pratima :)
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
  --
  Saurabh Singh
  B.Tech (Computer Science)
  MNNIT ALLAHABAD
 
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



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

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


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




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

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



Re: [algogeeks] MS interview:

2011-07-27 Thread Anand Saha
Implement Preorder Traversal in the File system tree.

-- 



On Wed, Jul 27, 2011 at 12:06 PM, geek forgeek geekhori...@gmail.comwrote:

 Function to display the directory structure in a user friendly way taking
 root dir as arg
 for a general OS. You may assume and state some basic APIs available in
 that OS

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

2011-07-27 Thread Pankaj
I think it's wrong approach. Can you explain with an example?

On Wed, Jul 27, 2011 at 12:33 PM, pacific :-) pacific4...@gmail.com wrote:

 O(nlogn)
 1. precompute the minimum of [ i+1 N] and store in b[i]
 2. Now do a binary search for a[i] in b[i+1] in the range of  b[i+1. N]


 On Wed, Jul 27, 2011 at 12:27 PM, salvador_cerinza 
 vishwakarma.ii...@gmail.com wrote:

 Let say stack S.
 1.insert elements in S of A[] from right to left.
 2.int val = S.top();
 3.S.pop();
 4.now check val with S.top() until u find any element smaller than val.
 5.Note down the element pop it from stack
 6.if step 4 is true , the push val in stack S and all elements which were
 popped in the order they were popped except the last matched candidate
 element.

 Yeah..dis algo is not very efficient..


 On Wed, Jul 27, 2011 at 12:20 PM, Pankaj jatka.oppimi...@gmail.comwrote:

 Can you please elaborate a little about your stack based solution. I was
 thinking of using queue but was unable to make a perfect algo.


 On Wed, Jul 27, 2011 at 12:18 PM, salvador_cerinza 
 vishwakarma.ii...@gmail.com wrote:

 i m  suggesting stack  not just for best case only .


 On Wed, Jul 27, 2011 at 12:16 PM, Pankaj jatka.oppimi...@gmail.comwrote:

 Even in array best case can be O(n). Why use stack?
 On Wed, Jul 27, 2011 at 12:14 PM, salvador_cerinza 
 vishwakarma.ii...@gmail.com wrote:

 Best case : O(n)
 Worst case : O(n^2)
 can be done using stack.

 Thinking of better solution. .


 On Wed, Jul 27, 2011 at 11:50 AM, ankit sambyal 
 ankitsamb...@gmail.com wrote:

 O(n^2) algo is trivial. Can anybody think of a better approach ???

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


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


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


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


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


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




 --
 regards,
 chinna.

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

2011-07-27 Thread sunny agrawal
yes Preorder recursion will be good for displaying in User Friendly way...

On Wed, Jul 27, 2011 at 12:49 PM, Anand Saha anands...@gmail.com wrote:

 Implement Preorder Traversal in the File system tree.

 --



 On Wed, Jul 27, 2011 at 12:06 PM, geek forgeek geekhori...@gmail.comwrote:

 Function to display the directory structure in a user friendly way taking
 root dir as arg
 for a general OS. You may assume and state some basic APIs available in
 that OS

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




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

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



Re: [algogeeks] The Google Resume

2011-07-27 Thread malay chakrabarti
plz send it to my maid id also . thanks in advance :)


On Wed, Jul 27, 2011 at 12:46 PM, Prem Krishna Chettri
hprem...@gmail.comwrote:

 Anyone got this book?? pdf.. or URL link is highly appreciated.

 Thx..


 On Tue, Jul 26, 2011 at 8:37 PM, Ankur Garg ankurga...@gmail.com wrote:

 +1
 Me too looking out for the same :(


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

 +1

 Pls send to my email id as well..


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

 Anyone having the Google Resume book pdf?

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


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


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


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

2011-07-27 Thread geek forgeek
can some one give me the code plz?

On Wed, Jul 27, 2011 at 12:26 AM, sunny agrawal sunny816.i...@gmail.comwrote:

 yes Preorder recursion will be good for displaying in User Friendly way...


 On Wed, Jul 27, 2011 at 12:49 PM, Anand Saha anands...@gmail.com wrote:

 Implement Preorder Traversal in the File system tree.

 --



 On Wed, Jul 27, 2011 at 12:06 PM, geek forgeek geekhori...@gmail.comwrote:

 Function to display the directory structure in a user friendly way taking
 root dir as arg
 for a general OS. You may assume and state some basic APIs available in
 that OS

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




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

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


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



Re: [algogeeks] The Google Resume

2011-07-27 Thread Anand Saha
Here: http://goo.gl/pDG5s

(Yes, that's the correct link)
-- 



On Wed, Jul 27, 2011 at 1:18 PM, malay chakrabarti m1234...@gmail.comwrote:

 plz send it to my maid id also . thanks in advance :)


 On Wed, Jul 27, 2011 at 12:46 PM, Prem Krishna Chettri hprem...@gmail.com
  wrote:

 Anyone got this book?? pdf.. or URL link is highly appreciated.

 Thx..


 On Tue, Jul 26, 2011 at 8:37 PM, Ankur Garg ankurga...@gmail.com wrote:

 +1
 Me too looking out for the same :(


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

 +1

 Pls send to my email id as well..


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

 Anyone having the Google Resume book pdf?

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


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


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


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


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


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



Re: [algogeeks] Re: Amazon Question

2011-07-27 Thread surender sanke
*
 /  \\
   a bc
  /\
b  c
/
c

prints *a*
comes to b, appends a with bprints *ab*
comes to c ,appends ab with c   prints *abc*
starts with new child
prints *b*
prints *bc*
prints *c*

surender


On Wed, Jul 27, 2011 at 12:46 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 But still Printing O(N^2) substrings will take O(N^2) time isn't it ?

 On Wed, Jul 27, 2011 at 12:39 PM, surender sanke surend...@gmail.comwrote:



 @sunny
 consider *uncompressed* suffix tree, even with distinct elements maximum
 number of nodes with string length n formed will be 2n.
  once suffix tree is constructed, needs to traverse in dfs order appending
 the node found on the way.
 total complexity would be O(construction of suffix tree ) + O(traverse
 time).

 surender


 On Wed, Jul 27, 2011 at 12:00 PM, sunny agrawal 
 sunny816.i...@gmail.comwrote:

 @shiva viknesh
 this is a different Question...

 @saurabh
 how is nlgn possible, total no of possible substrings are n^2


 this is the O(n^2) solutionOn Wed, Jul 27, 2011 at 8:09 AM, saurabh singh

 for(int l = 0; l  len; l++){
 for(int i = 0; i  len-l; i++){
 int j = i+l;
 char temp = s[j+1];
 s[j+1] = 0;
 printf(%s\n, s+i);
 s[j+1] = temp;
 }
 }

 saurab...@gmail.com wrote:
 
  using suffix tree this can be done in o(nlogn) though will take extra
 space.
 
  On Wed, Jul 27, 2011 at 12:47 AM, siva viknesh sivavikne...@gmail.com
 wrote:
 
  http://geeksforgeeks.org/?p=767
 
  On Jul 26, 11:49 pm, Pratz mary pratima.m...@gmail.com wrote:
   how?
  
   On 26 July 2011 23:18, ankit sambyal ankitsamb...@gmail.com
 wrote:
  
@vivin : Suffix trees are memory intensive..
  
This problem can be solved just by running 2 nested loops in O(1)
space and O(n^2) time
  
--
You received this message because you are subscribed to the Google
 Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --
   regards Pratima :)
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
  --
  Saurabh Singh
  B.Tech (Computer Science)
  MNNIT ALLAHABAD
 
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



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

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


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




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

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


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

2011-07-27 Thread sagar pareek
selection sort is best to do this
find the number of elements smaller or equal then the ith element of ather
array and swap it accordingly

On Wed, Jul 27, 2011 at 12:28 PM, ankit sambyal ankitsamb...@gmail.comwrote:

 Following is the working code :Time complexity : O(n^2)  Space
 complexity : O(1)


 void swap(int *a,int *b)
 {
 int temp;
 temp=*a;
 *a=*b;
 *b=temp;
 }
 /*num is the number which is searched in the array arr[]. index is the
 index in the array arr[] by which the searched number is to be replaced*/
 int searchAndReplace(int arr[],int size,int num,int index)
 {
 int i=index+1;
 while(isize)
 {
 if(arr[i]==num)
 break;
 i++;
 }
 if(isize)
 swap(arr[i],arr[index]);
 }
 void sort(int arr1[],int arr2[],int size)
 {
 int i=0,j;
 while(isize)
 {
 j=0;
 while(jsize)
 {
 if(arr2[j]arr1[i])
 searchAndReplace(arr1,size,arr2[j],i);
 j++;
 }
 i++;
 }
 }
 int main()
 {
 int arr1[]={2,5,1,7};
 int arr2[]={5,7,1,2};
 sort(arr1,arr2,4);
 int i;
 for(i=0;i4;i++)
 printf(%d  ,arr1[i]);
 return 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
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




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

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



Re: [algogeeks] Re: Fwd: SORTING ARRAYS

2011-07-27 Thread Anand Saha
Another point of view:

Since both the arrays have same elements, sorting one sorts both.
Hence we can use elements of array1 to build a min-heap in array2.
Then read mins from array2 into array1,  getting array1 sorted.
Copy array1 to array2.

Does this violate the comparison rule set?
-- 



On Wed, Jul 27, 2011 at 1:46 PM, sagar pareek sagarpar...@gmail.com wrote:

 selection sort is best to do this
 find the number of elements smaller or equal then the ith element of ather
 array and swap it accordingly


 On Wed, Jul 27, 2011 at 12:28 PM, ankit sambyal ankitsamb...@gmail.comwrote:

 Following is the working code :Time complexity : O(n^2)  Space
 complexity : O(1)


 void swap(int *a,int *b)
 {
 int temp;
 temp=*a;
 *a=*b;
 *b=temp;
 }
 /*num is the number which is searched in the array arr[]. index is the
 index in the array arr[] by which the searched number is to be replaced*/
 int searchAndReplace(int arr[],int size,int num,int index)
 {
 int i=index+1;
 while(isize)
 {
 if(arr[i]==num)
 break;
 i++;
 }
 if(isize)
 swap(arr[i],arr[index]);
 }
 void sort(int arr1[],int arr2[],int size)
 {
 int i=0,j;
 while(isize)
 {
 j=0;
 while(jsize)
 {
 if(arr2[j]arr1[i])
 searchAndReplace(arr1,size,arr2[j],i);
 j++;
 }
 i++;
 }
 }
 int main()
 {
 int arr1[]={2,5,1,7};
 int arr2[]={5,7,1,2};
 sort(arr1,arr2,4);
 int i;
 for(i=0;i4;i++)
 printf(%d  ,arr1[i]);
 return 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
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




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

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


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



Re: [algogeeks] MS interview:

2011-07-27 Thread Anantha Krishnan
Here is a Java code :

*private static void _printTree(String root,int depth)
{
if(root==null || root.trim().length()==0)
return;
File f=new File(root);
if(f.isFile()==true)
{
printTab(depth);
System.out.printf(%s\n,f.getName());
return;
}
if(f.isDirectory()==true)
{
printTab(depth);
System.out.printf(%s\n,f.getName());
String[] filelist=f.list();
if(filelist==null)
return;
for(String file:filelist)
{
_printTree(root+File.separator+file, depth+1);
}
return;
}
return;
}

public static void printTree(String root)
{
_printTree(root, 0);
}*

Thanks  Regards
Anantha Krishnan

On Wed, Jul 27, 2011 at 1:21 PM, geek forgeek geekhori...@gmail.com wrote:

 can some one give me the code plz?


 On Wed, Jul 27, 2011 at 12:26 AM, sunny agrawal 
 sunny816.i...@gmail.comwrote:

 yes Preorder recursion will be good for displaying in User Friendly way...


 On Wed, Jul 27, 2011 at 12:49 PM, Anand Saha anands...@gmail.com wrote:

 Implement Preorder Traversal in the File system tree.

 --



 On Wed, Jul 27, 2011 at 12:06 PM, geek forgeek geekhori...@gmail.comwrote:

 Function to display the directory structure in a user friendly way
 taking root dir as arg
 for a general OS. You may assume and state some basic APIs available in
 that OS

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




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

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


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


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



Re: [algogeeks] Re: Amazon Question

2011-07-27 Thread sunny agrawal
i don't find difference between your suffix tree approach and my simple
O(N^2) method
in both cases printf statement will be executed O(N^2) times
and in Suffix Tree approach will take some extra time of construction of
tree and extra space too !

On Wed, Jul 27, 2011 at 1:45 PM, surender sanke surend...@gmail.com wrote:

 *
  /  \\
a bc
   /\
 b  c
 /
 c

 prints *a*
 comes to b, appends a with bprints *ab*
 comes to c ,appends ab with c   prints *abc*
 starts with new child
 prints *b*
 prints *bc*
 prints *c*

 surender


 On Wed, Jul 27, 2011 at 12:46 PM, sunny agrawal 
 sunny816.i...@gmail.comwrote:

 But still Printing O(N^2) substrings will take O(N^2) time isn't it ?

 On Wed, Jul 27, 2011 at 12:39 PM, surender sanke surend...@gmail.comwrote:



 @sunny
 consider *uncompressed* suffix tree, even with distinct elements maximum
 number of nodes with string length n formed will be 2n.
  once suffix tree is constructed, needs to traverse in dfs order
 appending the node found on the way.
 total complexity would be O(construction of suffix tree ) + O(traverse
 time).

 surender


 On Wed, Jul 27, 2011 at 12:00 PM, sunny agrawal sunny816.i...@gmail.com
  wrote:

 @shiva viknesh
 this is a different Question...

 @saurabh
 how is nlgn possible, total no of possible substrings are n^2


 this is the O(n^2) solutionOn Wed, Jul 27, 2011 at 8:09 AM, saurabh
 singh

 for(int l = 0; l  len; l++){
 for(int i = 0; i  len-l; i++){
 int j = i+l;
 char temp = s[j+1];
 s[j+1] = 0;
 printf(%s\n, s+i);
 s[j+1] = temp;
 }
 }

 saurab...@gmail.com wrote:
 
  using suffix tree this can be done in o(nlogn) though will take extra
 space.
 
  On Wed, Jul 27, 2011 at 12:47 AM, siva viknesh 
 sivavikne...@gmail.com wrote:
 
  http://geeksforgeeks.org/?p=767
 
  On Jul 26, 11:49 pm, Pratz mary pratima.m...@gmail.com wrote:
   how?
  
   On 26 July 2011 23:18, ankit sambyal ankitsamb...@gmail.com
 wrote:
  
@vivin : Suffix trees are memory intensive..
  
This problem can be solved just by running 2 nested loops in O(1)
space and O(n^2) time
  
--
You received this message because you are subscribed to the
 Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --
   regards Pratima :)
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
  --
  Saurabh Singh
  B.Tech (Computer Science)
  MNNIT ALLAHABAD
 
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



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

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


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




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

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


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

Re: [algogeeks] Re: Fwd: SORTING ARRAYS

2011-07-27 Thread ankit sambyal
@anand: How are you building minheap ??  Comparison of same array elements
is not allowed !

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



Re: [algogeeks] Re: Amazon Question

2011-07-27 Thread surender sanke
@ sunny , ur right!!

surender

On Wed, Jul 27, 2011 at 1:58 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 i don't find difference between your suffix tree approach and my simple
 O(N^2) method
 in both cases printf statement will be executed O(N^2) times
 and in Suffix Tree approach will take some extra time of construction of
 tree and extra space too !

 On Wed, Jul 27, 2011 at 1:45 PM, surender sanke surend...@gmail.comwrote:

 *
  /  \\
a bc
   /\
 b  c
 /
 c

 prints *a*
 comes to b, appends a with bprints *ab*
 comes to c ,appends ab with c   prints *abc*
 starts with new child
 prints *b*
 prints *bc*
 prints *c*

 surender


 On Wed, Jul 27, 2011 at 12:46 PM, sunny agrawal 
 sunny816.i...@gmail.comwrote:

 But still Printing O(N^2) substrings will take O(N^2) time isn't it ?

 On Wed, Jul 27, 2011 at 12:39 PM, surender sanke surend...@gmail.comwrote:



 @sunny
 consider *uncompressed* suffix tree, even with distinct elements
 maximum number of nodes with string length n formed will be 2n.
  once suffix tree is constructed, needs to traverse in dfs order
 appending the node found on the way.
 total complexity would be O(construction of suffix tree ) + O(traverse
 time).

 surender


 On Wed, Jul 27, 2011 at 12:00 PM, sunny agrawal 
 sunny816.i...@gmail.com wrote:

 @shiva viknesh
 this is a different Question...

 @saurabh
 how is nlgn possible, total no of possible substrings are n^2


 this is the O(n^2) solutionOn Wed, Jul 27, 2011 at 8:09 AM, saurabh
 singh

 for(int l = 0; l  len; l++){
 for(int i = 0; i  len-l; i++){
 int j = i+l;
 char temp = s[j+1];
 s[j+1] = 0;
 printf(%s\n, s+i);
 s[j+1] = temp;
 }
 }

 saurab...@gmail.com wrote:
 
  using suffix tree this can be done in o(nlogn) though will take extra
 space.
 
  On Wed, Jul 27, 2011 at 12:47 AM, siva viknesh 
 sivavikne...@gmail.com wrote:
 
  http://geeksforgeeks.org/?p=767
 
  On Jul 26, 11:49 pm, Pratz mary pratima.m...@gmail.com wrote:
   how?
  
   On 26 July 2011 23:18, ankit sambyal ankitsamb...@gmail.com
 wrote:
  
@vivin : Suffix trees are memory intensive..
  
This problem can be solved just by running 2 nested loops in
 O(1)
space and O(n^2) time
  
--
You received this message because you are subscribed to the
 Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
 .
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --
   regards Pratima :)
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
  --
  Saurabh Singh
  B.Tech (Computer Science)
  MNNIT ALLAHABAD
 
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



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

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


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




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

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


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

Re: [algogeeks] Re: Fwd: SORTING ARRAYS

2011-07-27 Thread Anand Saha
@ankit: you are right. While building is okay (item to insert is from other
array, hence comparison to that allowed), deletemin() will violate the
condition given.

-- 



On Wed, Jul 27, 2011 at 2:03 PM, ankit sambyal ankitsamb...@gmail.comwrote:

 @anand: How are you building minheap ??  Comparison of same array elements
 is not allowed !

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

2011-07-27 Thread kumar vr
Can anyone suggest some good resources to master multithreaded programming
in 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.



Re: Re : [algogeeks] Re: size of self referential structure

2011-07-27 Thread hary rathor
@sunny : what you means by machine dependent means 64 bit: you means by
compiler / operating system  /computer architecture ?
because i never get size of pointer 8 byte. if your statement true then tell
me which compiler / operating system  /computer architecture i should have
get this output 8.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Re : [algogeeks] Re: size of self referential structure

2011-07-27 Thread sunny agrawal
computer architecture !!!
64 bit machine has word size of 8 bytes so pointers are of 8 bytes

you never got size as 8 byte because u might be working on a 32 bit machine
!!

On Wed, Jul 27, 2011 at 2:18 PM, hary rathor harry.rat...@gmail.com wrote:

 @sunny : what you means by machine dependent means 64 bit: you means by
 compiler / operating system  /computer architecture ?
 because i never get size of pointer 8 byte. if your statement true then
 tell me which compiler / operating system  /computer architecture i should
 have get this output 8.


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




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

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



Re: Re : [algogeeks] Re: size of self referential structure

2011-07-27 Thread Anand Saha
On Wed, Jul 27, 2011 at 2:18 PM, hary rathor harry.rat...@gmail.com wrote:

 @sunny : what you means by machine dependent means 64 bit: you means by
 compiler / operating system  /computer architecture ?
 because i never get size of pointer 8 byte. if your statement true then
 tell me which compiler / operating system  /computer architecture i should
 have get this output 8.



A 64 bit machine running a 64 bit OS, on which using a compiler targeted for
64 bit executable will give you pointer size of 8.

--

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



Re: [algogeeks] Re: Amazon Question

2011-07-27 Thread saurabh singh
hmm o(nlogn) was for constructing the tree.Btw sorry for being unclear.
The best solution is the obvious one in this case.

On Wed, Jul 27, 2011 at 2:10 PM, surender sanke surend...@gmail.com wrote:

 @ sunny , ur right!!

 surender

 On Wed, Jul 27, 2011 at 1:58 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 i don't find difference between your suffix tree approach and my simple
 O(N^2) method
 in both cases printf statement will be executed O(N^2) times
 and in Suffix Tree approach will take some extra time of construction of
 tree and extra space too !

 On Wed, Jul 27, 2011 at 1:45 PM, surender sanke surend...@gmail.comwrote:

 *
  /  \\
a bc
   /\
 b  c
 /
 c

 prints *a*
 comes to b, appends a with bprints *ab*
 comes to c ,appends ab with c   prints *abc*
 starts with new child
 prints *b*
 prints *bc*
 prints *c*

 surender


 On Wed, Jul 27, 2011 at 12:46 PM, sunny agrawal sunny816.i...@gmail.com
  wrote:

 But still Printing O(N^2) substrings will take O(N^2) time isn't it ?

 On Wed, Jul 27, 2011 at 12:39 PM, surender sanke 
 surend...@gmail.comwrote:



 @sunny
 consider *uncompressed* suffix tree, even with distinct elements
 maximum number of nodes with string length n formed will be 2n.
  once suffix tree is constructed, needs to traverse in dfs order
 appending the node found on the way.
 total complexity would be O(construction of suffix tree ) + O(traverse
 time).

 surender


 On Wed, Jul 27, 2011 at 12:00 PM, sunny agrawal 
 sunny816.i...@gmail.com wrote:

 @shiva viknesh
 this is a different Question...

 @saurabh
 how is nlgn possible, total no of possible substrings are n^2


 this is the O(n^2) solutionOn Wed, Jul 27, 2011 at 8:09 AM, saurabh
 singh

 for(int l = 0; l  len; l++){
 for(int i = 0; i  len-l; i++){
 int j = i+l;
 char temp = s[j+1];
 s[j+1] = 0;
 printf(%s\n, s+i);
 s[j+1] = temp;
 }
 }

 saurab...@gmail.com wrote:
 
  using suffix tree this can be done in o(nlogn) though will take
 extra space.
 
  On Wed, Jul 27, 2011 at 12:47 AM, siva viknesh 
 sivavikne...@gmail.com wrote:
 
  http://geeksforgeeks.org/?p=767
 
  On Jul 26, 11:49 pm, Pratz mary pratima.m...@gmail.com wrote:
   how?
  
   On 26 July 2011 23:18, ankit sambyal ankitsamb...@gmail.com
 wrote:
  
@vivin : Suffix trees are memory intensive..
  
This problem can be solved just by running 2 nested loops in
 O(1)
space and O(n^2) time
  
--
You received this message because you are subscribed to the
 Google Groups
Algorithm Geeks group.
To post to this group, send email to
 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --
   regards Pratima :)
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
  --
  Saurabh Singh
  B.Tech (Computer Science)
  MNNIT ALLAHABAD
 
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



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

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


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




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

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



[algogeeks] OUTPUT

2011-07-27 Thread Kamakshii Aggarwal
#includestdio.h
# define MAXROW 3
#define MAXCOL 4


int main()
{
int (*p)[MAXCOL];
p=(int(*)[MAXCOL])malloc(MAXROW*sizeof(*p));
printf(%d %d,sizeof(p),sizeof(*p));

 system(pause);

  return 0;
}

THE O/P IS 4 16.
I am not getting the reason.plss help

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

2011-07-27 Thread ramya reddy
The system on which u executed this will allocate 4 bytes for int type.
hence sizeof(p) gives 4 bytes and sizeof(*p) will contain 4 such integer
pointers( int *p[4] is the declaration)  which gives 4*4=16 bytes


Regards
Ramya

*Try to learn something about everything and everything about something*

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

2011-07-27 Thread Ankit
p is a pointer to an array of 4 ints.
sizeof(p) gives the size of the pointer which is an int and sizeof(*p)
gives the size of the array it points (4*4=16)

On Jul 27, 3:44 pm, Kamakshii Aggarwal kamakshi...@gmail.com wrote:
 #includestdio.h
 # define MAXROW 3
 #define MAXCOL 4

 int main()
 {
     int (*p)[MAXCOL];
     p=(int(*)[MAXCOL])malloc(MAXROW*sizeof(*p));
     printf(%d %d,sizeof(p),sizeof(*p));

  system(pause);

   return 0;

 }

 THE O/P IS 4 16.
 I am not getting the reason.plss help

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

2011-07-27 Thread Kamakshii Aggarwal
thanks ankit and ramya..:)


On Wed, Jul 27, 2011 at 5:42 PM, Ankit ankitchaudhar...@gmail.com wrote:

 p is a pointer to an array of 4 ints.
 sizeof(p) gives the size of the pointer which is an int and sizeof(*p)
 gives the size of the array it points (4*4=16)

 On Jul 27, 3:44 pm, Kamakshii Aggarwal kamakshi...@gmail.com wrote:
  #includestdio.h
  # define MAXROW 3
  #define MAXCOL 4
 
  int main()
  {
  int (*p)[MAXCOL];
  p=(int(*)[MAXCOL])malloc(MAXROW*sizeof(*p));
  printf(%d %d,sizeof(p),sizeof(*p));
 
   system(pause);
 
return 0;
 
  }
 
  THE O/P IS 4 16.
  I am not getting the reason.plss help

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




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

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



Re: [algogeeks] Re: OUTPUT

2011-07-27 Thread Kamakshii Aggarwal
one more question.
how to dynamically allocate memory for int *a[3]; ?

On Wed, Jul 27, 2011 at 5:57 PM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:

 thanks ankit and ramya..:)


 On Wed, Jul 27, 2011 at 5:42 PM, Ankit ankitchaudhar...@gmail.com wrote:

 p is a pointer to an array of 4 ints.
 sizeof(p) gives the size of the pointer which is an int and sizeof(*p)
 gives the size of the array it points (4*4=16)

 On Jul 27, 3:44 pm, Kamakshii Aggarwal kamakshi...@gmail.com wrote:
  #includestdio.h
  # define MAXROW 3
  #define MAXCOL 4
 
  int main()
  {
  int (*p)[MAXCOL];
  p=(int(*)[MAXCOL])malloc(MAXROW*sizeof(*p));
  printf(%d %d,sizeof(p),sizeof(*p));
 
   system(pause);
 
return 0;
 
  }
 
  THE O/P IS 4 16.
  I am not getting the reason.plss help

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




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




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



[algogeeks] Re: GATE C-Question

2011-07-27 Thread shiv narayan
value of k in any if case would be k=m+n-1, now analyse both of the
options
i)jm, k=n+j-1, and a[n-1]b[j] if i=n
ii)in,k=m+i-1, and b[m-`1]=a[i] if j=m

for 1st case k=n+j-1 and jm so km+n-1 which is false
for 2nd case k=m+i-1 and in so km+n-1 which is also false so both
statement are false

ans:c
correct me if i am wrong
On Jul 26, 8:42 pm, rajeev bharshetty rajeevr...@gmail.com wrote:
 C )

 On Tue, Jul 26, 2011 at 9:02 PM, Vijay Khandar vijaykhand...@gmail.comwrote:









  Consider the following C-function in which a[n] and b[m] are two
  sorted integer arrays and c[n+m] be an other integer array.

  void XYZ(int a[],int b[], int c[])
  {
  int i,j,k;
  i=j=k=0;
  while((in)(jm))
  {
  if (a[i]b[j])
   c[k++]=a[i++];
   else
   c[k++]=b[j++];

  }

  Which of the following condition(s) hold(s) after the termination of
  the while loop?

  i)jm, k=n+j-1, and a[n-1]b[j] if i=n

  ii)in,k=m+i-1, and b[m-`1]=a[i] if j=m

  A)only i
  B)only ii
  C)either i or ii but not both
  D)neither i nor ii

  Can I have to take any example

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

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

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



Re: [algogeeks] Re: MS c output ques

2011-07-27 Thread aditi garg
@rajeev
i ran dis code
int main()
{

char str[80];
strcpy(str,siva);
scanf(%[^india],str);
printf(%s,str);
return 0;


}
and i got the output as siva...instead of s as expected...can u plz point
out the error

On Tue, Jul 26, 2011 at 11:21 PM, siva viknesh sivavikne...@gmail.comwrote:

 @both...fantastic explanation...thanks :)

 On Jul 26, 10:34 pm, rajeev bharshetty rajeevr...@gmail.com wrote:
  So if the input is gujarat it scans gujarat to find the first character
 in
  gujarat which is also present in india . So the character in gujarat is a
 so
  it will stop on encountering a and prints the string scanned till then.
 
  If the input is india , it matches at first location so it prints the
  contents of str which is junk.
 
  Now consider rajeev it will print r because of a at second position. and
 for
  siva it will print s try it out.
 
  Hope you understood the concept.
 
 
 
 
 
 
 
 
 
  On Tue, Jul 26, 2011 at 10:54 PM, kc Liyan kcli...@gmail.com wrote:
   if U given input as gujarat the scanf will accept inputs as
   char's.but there s an ^ which means ex-or operation should be
   performed regular check of existance of any char of {india}...
   untill it get's the existance then it will stop the input
   getting..finally it prints as guj
 
   On 7/26/11, siva viknesh sivavikne...@gmail.com wrote:
main()
{
 
char str[80];
strcpy(str,junk);
scanf(%[^india],str);
printf(%s,str);
 
}
 
...input is gujarat.output is guj.plz explain how?
 
--
You received this message because you are subscribed to the Google
 Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  Regards
  Rajeev N B http://www.opensourcemania.co.cc

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




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

9718388816

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Blocked/Unrolled linked list with no duplicates and sorted

2011-07-27 Thread banu
Hi,
Basically I am trying to create a blocked linked list(unrolled linked
list) with following properties
- Configurable number of elements in each node
- No duplicate elements in the unrolled linked list
- Linked list is sorted either during insertion or after creating the
linked list
- In place

Assuming I need to create a sorted unrolled linked list with no
duplicate elements with block size say 2

Example: 10,2,4,2,5,7,9.11,11,5

Final blocked linked list: (2,4)-(5,7)-(9,10)-(11,x) or in reverse
order

Note: x means unutilized location in the array wihtin the node. In
case there are not enough elements to insert in a node, some memory
allocated for a node is unutilized

// Following is node structure
#define ARRAY_SZ 2
typedef struct node
{
struct node* next;
long long int elements[ARRAY_SZ];
long long int elemIndex;
}NODE, *NODE_PTR;

Can you suggest me a way to do this correctly and efficiently? It
could be an pseudo text or C-code.

Thanks
Varun

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

2011-07-27 Thread Prashant Gupta
Static variable needs to be defined outside cpp class. inside the class we
dint difine it but just declared it.
So size to be considered is just 1 int variable.

On Wed, Jul 27, 2011 at 2:29 AM, Piyush Sinha ecstasy.piy...@gmail.comwrote:

 http://www.cprogramming.com/tutorial/size_of_class_object.html

 On 7/27/11, TUSHAR tusharkanta.r...@gmail.com wrote:
  1.
  #includeiostream
  using namespace std;
  class abc
  {
  int x;
  static int y;
  };
  main()
  {
  abc a;
  coutsizeof(a);
  coutsizeof(abc);
  }
 
  why o/p is 4 4 ???
 
 
  2.
  class abc
  { };
  main()
  {
abc ob;
coutsizeof(ob);
  }
 
  why o/p is 1 ?
  some say o/p may vary from os to os .why ?? and what may be other
  o/p 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.
 
 


 --
 *Piyush Sinha*
 *IIIT, Allahabad*
 *+91-7483122727*
 * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY
 NEVER
 *

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




-- 
Prashant Gupta
B.Tech Final Year
Computer Science and Engineering
NIT Trichy
Phone : +91 9894462744

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

2011-07-27 Thread ramya reddy
int *a[3];
a= (int *[3]) malloc( 3*sizeof(*a));

Regards
Ramya
-- 
*Try to learn something about everything and everything about something*

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



Re: [algogeeks] Re: MS c output ques

2011-07-27 Thread rajeev bharshetty
@aditi : What is the string input you gave.?? it depends on that
If you have entered the string such as illeana then string illeana
matches at the first location , so it prints the previous value copied into
the str i.e siva .
Hope you understood .

On Wed, Jul 27, 2011 at 1:24 AM, aditi garg aditi.garg.6...@gmail.comwrote:

 @rajeev
 i ran dis code
 int main()
 {

 char str[80];
 strcpy(str,siva);
 scanf(%[^india],str);
 printf(%s,str);
 return 0;


 }
 and i got the output as siva...instead of s as expected...can u plz point
 out the error

 On Tue, Jul 26, 2011 at 11:21 PM, siva viknesh sivavikne...@gmail.comwrote:

 @both...fantastic explanation...thanks :)

 On Jul 26, 10:34 pm, rajeev bharshetty rajeevr...@gmail.com wrote:
  So if the input is gujarat it scans gujarat to find the first character
 in
  gujarat which is also present in india . So the character in gujarat is
 a so
  it will stop on encountering a and prints the string scanned till then.
 
  If the input is india , it matches at first location so it prints the
  contents of str which is junk.
 
  Now consider rajeev it will print r because of a at second position. and
 for
  siva it will print s try it out.
 
  Hope you understood the concept.
 
 
 
 
 
 
 
 
 
  On Tue, Jul 26, 2011 at 10:54 PM, kc Liyan kcli...@gmail.com wrote:
   if U given input as gujarat the scanf will accept inputs as
   char's.but there s an ^ which means ex-or operation should be
   performed regular check of existance of any char of {india}...
   untill it get's the existance then it will stop the input
   getting..finally it prints as guj
 
   On 7/26/11, siva viknesh sivavikne...@gmail.com wrote:
main()
{
 
char str[80];
strcpy(str,junk);
scanf(%[^india],str);
printf(%s,str);
 
}
 
...input is gujarat.output is guj.plz explain how?
 
--
You received this message because you are subscribed to the Google
 Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  Regards
  Rajeev N B http://www.opensourcemania.co.cc

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




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

 9718388816

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




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

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



Re: [algogeeks] Re: OUTPUT

2011-07-27 Thread Ankur Khurana
what do you exactly mean by
(int *[3])  ?

On Wed, Jul 27, 2011 at 6:27 PM, ramya reddy rmy.re...@gmail.com wrote:


 int *a[3];
 a= (int *[3]) malloc( 3*sizeof(*a));

 Regards
 Ramya
 --
 *Try to learn something about everything and everything about something*

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




-- 
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
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: OUTPUT

2011-07-27 Thread ramya reddy
int * [3] represents that 'a' is a integer  pointer array  of size 3.
-- 
Regards
Ramya
*
*
*Try to learn something about everything and everything about something*

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

2011-07-27 Thread sagar pareek
Do anybody of you  know what type of questions cisco ask from electronics
part?
Please if anybody know then tell me some sample questions. And if possible
what topics should i cover?

Thanks in advance

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

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



[algogeeks] Re: Cisco ??

2011-07-27 Thread Poised~
Well in my interview for internship I was mainly asked basic questions from 
Networking like FTP/HTTP, layers in networking, HTTPS, etc.
Some programming questions like what structures will you use in storing 
millions of data (basically how google stores web caches) ?, etc (normal 
like any other companies).

But I have seen some ALP (assembly language) questions in their papers for 
placements, so you should practice some ALP. ALP questions like examining 
and giving outputs and other stuffs.
Do post in questions that were asked to you in any company.

Best of Luck! :)

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

2011-07-27 Thread Kamakshii Aggarwal
@magesh:so acc to you the code below should give error?
#includestdio.h

int main(int argc,char *argv[])
{
  char const *s=;
 char str[]=hello;
 s=str;
 while(*s){
   printf(%c,*s++);
   }

 system(pause);

  return 0;
}


On Wed, Jul 27, 2011 at 7:12 PM, mageshthegr...@gmail.com wrote:

 ** Its not a const pointer. It is pointer to constant. So only modifying
 the value of s will cause error. For constant to pointer the const has to be
 between * and the keyword

 Sent from BlackBerry® on Airtel
 --
 *From: * Kamakshii Aggarwal kamakshi...@gmail.com
 *Sender: * algogeeks@googlegroups.com
 *Date: *Wed, 27 Jul 2011 19:09:20 +0530
 *To: *algogeeks@googlegroups.com
 *ReplyTo: * algogeeks@googlegroups.com
 *Subject: *[algogeeks] output

 #includestdio.h

 int main(int argc,char *argv[])
 {
  const char *s=;
  char str[]=hello;
  s=str;
  while(*s){
printf(%c,*s++);
}

  system(pause);

   return 0;
 }
 o/p is hello.
 why the above code is running normally even when constant char pointer is
 being incremented...??plss help...
 --
 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.

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




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

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



Re: [algogeeks] Re: Nagarro Coding Round Ques......

2011-07-27 Thread Ram CEG
checking for anagrams itself will  work for this question...
by using an array[[256];

On Wed, Jul 27, 2011 at 2:52 AM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote:

 I dint get wat are you speaking of.each alphabet is mapped onto
 ascii_val-'a' ie ascii of a=97. now check for odd and even occurence is
 performed. Work it on paper u'll get 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.


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

2011-07-27 Thread Ankur Khurana
if i declare a string constant inside another function
like let us say
,
int how()
{

char *s=hello;
return s;
}


so when how() get executed , the memory for hello will remain reserved or it
can be allocated to others. Will it amount to memory leak ?

-- 
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
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] output

2011-07-27 Thread Kamakshii Aggarwal
@piyush:thanks...i got my mistake

On Wed, Jul 27, 2011 at 7:30 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote:

 char const *s and const char *s are both same...try using char *const s..it
 will give error then


 On Wed, Jul 27, 2011 at 7:21 PM, Kamakshii Aggarwal kamakshi...@gmail.com
  wrote:

 @magesh:so acc to you the code below should give error?
 #includestdio.h

 int main(int argc,char *argv[])
 {
   char const *s=;
  char str[]=hello;
  s=str;
  while(*s){
printf(%c,*s++);
}

  system(pause);

   return 0;
 }


 On Wed, Jul 27, 2011 at 7:12 PM, mageshthegr...@gmail.com wrote:

 ** Its not a const pointer. It is pointer to constant. So only modifying
 the value of s will cause error. For constant to pointer the const has to be
 between * and the keyword

 Sent from BlackBerry® on Airtel
 --
 *From: * Kamakshii Aggarwal kamakshi...@gmail.com
 *Sender: * algogeeks@googlegroups.com
 *Date: *Wed, 27 Jul 2011 19:09:20 +0530
 *To: *algogeeks@googlegroups.com
 *ReplyTo: * algogeeks@googlegroups.com
 *Subject: *[algogeeks] output

 #includestdio.h

 int main(int argc,char *argv[])
 {
  const char *s=;
  char str[]=hello;
  s=str;
  while(*s){
printf(%c,*s++);
}

  system(pause);

   return 0;
 }
 o/p is hello.
 why the above code is running normally even when constant char pointer is
 being incremented...??plss help...
 --
 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.

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




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

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




 --
 *Piyush Sinha*
 *IIIT, Allahabad*
 *+91-7483122727*
 * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY
 NEVER
 *

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




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

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



[algogeeks] Re: C output 2

2011-07-27 Thread amit
hello is a string literal and this is what the C standard says about
string literals:

 The multibyte character sequence is then used to initialize an array of 
 static storage duration and length just
 sufficient to contain the sequence.

So memory will remain reserved for hello for the entire lifetime of
program.
Your program invokes undefined behavior because it causes a char
pointer to int conversion.

On Jul 27, 7:01 pm, Ankur Khurana ankur.kkhur...@gmail.com wrote:
 if i declare a string constant inside another function
 like let us say
 ,
 int how()
 {

 char *s=hello;
 return s;

 }

 so when how() get executed , the memory for hello will remain reserved or it
 can be allocated to others. Will it amount to memory leak ?

 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 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.



[algogeeks] Permutations in a string

2011-07-27 Thread Nikhil Gupta
Given a string of length 5 (example abcde), write a program to print all
the possible combinations OF LENGTH 3.

In this case : abc, abd, abe, acd, ace, ade, bcd, bce, bde, cde

Can someone provide a working code?

-- 
Nikhil Gupta
Senior Co-ordinator, Publicity
CSI, NSIT Students' Branch
NSIT, New Delhi, 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.



[algogeeks] Re: C output 2

2011-07-27 Thread Abhinav Arora
No it will not cause a memory leak as its a string literal and it behaves 
more like a read only entity.

-- 
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/-/_4FturgUv6cJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Permutations in a string

2011-07-27 Thread Rajeev Kumar
One more thread is running parallel on the same topic
Please refer :
http://comments.gmane.org/gmane.comp.programming.algogeeks/17279


On Wed, Jul 27, 2011 at 7:39 AM, Nikhil Gupta nikhilgupta2...@gmail.comwrote:

 Given a string of length 5 (example abcde), write a program to print all
 the possible combinations OF LENGTH 3.

 In this case : abc, abd, abe, acd, ace, ade, bcd, bce, bde, cde

 Can someone provide a working code?

 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, 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.




-- 
Thank You
Rajeev 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.



Re: [algogeeks] Re: Fwd: SORTING ARRAYS

2011-07-27 Thread DK
@All: Please pay attention to CodeHunter's answer. This is a standard Nuts 
and Bolts problem.
For those of you that are not aware, the Nuts and Bolts problem is as 
follows:

Given an array of nuts and another array of bolts, we need to match up all 
the nuts with all the bolts. 
The constraint is that a bolt cannot be compared to another bolt except by 
comparing their sizes with
respect to some nut. (A similar constraint on nuts vis a vis bolts).

The solution to this problem can be done in O(N log N) using a variant of 
quicksort.
The algorithm is as follows:

1. Select a random nut from the nuts array as the partition element
2. Partition the bolts array into 3 parts based on the nut: || nut|| == nut 
||  nut||
3. Select a bolt from the == nut array
4. Partition the nuts array into 3 parts based on the bolt: || bolt|| == 
bolt ||  bolt||
5. Recurse from step 1 on the two subarrays.

Expected Time Complexity: O(N log N)
Extra Space Required: O(1)

--
DK

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

-- 
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/-/bsBtugahyawJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] rotate a matrix NVIDIA question

2011-07-27 Thread Anika Jain
is it lyk for {1,2,3
   4,5,6,
   7,8,9}
to be {3,2,1,
 6,5,4,
 9,8,7}??

On Wed, Jul 27, 2011 at 9:37 AM, Deoki Nandan deok...@gmail.com wrote:

 rotate a 2D matrix by angle 180


 --
 **With Regards
 Deoki Nandan Vishwakarma

 *
 *

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

2011-07-27 Thread amit
#include cstdio
#include cstring
using namespace std;

const int MX = 1000;

int n, k;
char str[MX], partial[MX];

void solve(int pos, int aux) {
if(aux==k) {
partial[aux] = 0;
printf(%s\n, partial);
return;
}

for(int i = pos; i  n; i++) {
partial[aux] = str[i];
solve(i+1, aux+1);
}
}

int main() {
scanf(%s, str);
scanf(%d, k);
n = strlen(str);
solve(0, 0);
}


On Jul 27, 7:49 pm, Rajeev Kumar rajeevprasa...@gmail.com wrote:
 One more thread is running parallel on the same topic
 Please refer :http://comments.gmane.org/gmane.comp.programming.algogeeks/17279

 On Wed, Jul 27, 2011 at 7:39 AM, Nikhil Gupta 
 nikhilgupta2...@gmail.comwrote:





  Given a string of length 5 (example abcde), write a program to print all
  the possible combinations OF LENGTH 3.

  In this case : abc, abd, abe, acd, ace, ade, bcd, bce, bde, cde

  Can someone provide a working code?

  --
  Nikhil Gupta
  Senior Co-ordinator, Publicity
  CSI, NSIT Students' Branch
  NSIT, New Delhi, 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.

 --
 Thank You
 Rajeev 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.



Re: [algogeeks] Re: reverse a line.

2011-07-27 Thread somya mishra
m nt getting correct output for this program can any1 tell me wats the error

#includeiostream.h
#includeconio.h
#includestring.h
void main()
{
 char a[]=Hello daughter;
 couta\n;
 int l,i,j,k,c;
 int temp;
 l=strlen(a);
 for(i=0;il/2;i++)
 {
  temp=a[i];
  a[i]=a[l-i-1];
  a[l-i-1]=temp;
 }
 couta\n;
 k=0;
 c=0;
 a[l]='\0';
 for(i=0;i=l;i++)
 {
  if(a[i]!=' ')
  {
   c++;
   coutc=c\n;
  }
  else
  {
   for(j=i-1;j=c/2;j--)
   {
temp=a[j];
a[j]=a[k];
a[k]=temp;
k++;
   }
   c=0;
   k=i+1;
  }
 }
 couta;
}

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

2011-07-27 Thread Skand
Any idea about results ?

On Jul 26, 4:20 pm, Mukul Gupta mukulnit...@gmail.com wrote:
 here is one good tutorial on 
 topcoderhttp://www.topcoder.com/tc?module=Staticd1=tutorialsd2=usingTries May
  be
 this can help you.







 On Sun, Jul 24, 2011 at 3:51 AM, Akash Mukherjee akash...@gmail.com wrote:
  sorry if it seems to be off the topic, but any good resources for trie
  for a newbie??

  thanks :)

  On Sat, Jul 23, 2011 at 11:02 PM, varun pahwa varunpahwa2...@gmail.com
  wrote:
   Use trie tree and store word count also along with the pointer. So, that
   search could take at max word size time.

   On Sat, Jul 23, 2011 at 10:4 4 PM, rajeev bharshetty 
  rajeevr...@gmail.com
   wrote:

   Trie data structure can be used ? What you say guys??

   On Sat, Jul 23, 2011 at 10:43 PM, ankit sambyal ankitsamb...@gmail.com

   wrote:

   Use hashing with the words as key. Store the string of the word as the
   value..

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

   --
   Regards
   Rajeev N B

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

   --
   Varun Pahwa
   B.Tech (IT)
   7th Sem.
   Indian Institute of Information Technology Allahabad.
   Ph : 09793899112
   Official Email :: rit2008...@iiita.ac.in
   Another Email :: varunpahwa.ii...@gmail.com

   People who fail to plan are those who plan to fail.

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

2011-07-27 Thread Charlotte Swazki
Hi there,

I have two questions,

Why sizeof(main) == 1 ? (sizeof(func) == 1).
Not 4 bytes ?.sizeof(void) == 1 too.


And this code doesn't stackoverflow ?
int main() {

 sizeof(main());
}



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.



[algogeeks] Re: rotate a matrix NVIDIA question

2011-07-27 Thread amit
#include cstdio
#include algorithm
using namespace std;

const int MX = 1000;
int n, m;
int a[MX][MX];

int main() {
scanf(%d%d, n, m);
for(int i = 0; i  n; i++)
for(int j = 0; j  m; j++)
scanf(%d, a[i][j]);

for(int i = 0; i  n/2; i++)
for(int j = 0; j  m; j++)
swap(a[i][j], a[n-i-1][m-j-1]);
if(n1)
for(int j = 0; j  m/2; j++)
swap(a[n/2][j], a[n/2][m-j-1]);

for(int i = 0; i  n; i++) {
for(int j = 0; j  m; j++)
printf(%d , a[i][j]);
printf(\n);
}
}


On Jul 27, 7:54 pm, Anika Jain anika.jai...@gmail.com wrote:
 is it lyk for {1,2,3
                    4,5,6,
                    7,8,9}
 to be {3,2,1,
          6,5,4,
          9,8,7}    ??



 On Wed, Jul 27, 2011 at 9:37 AM, Deoki Nandan deok...@gmail.com wrote:
  rotate a 2D matrix by angle 180

  --
  **With Regards
  Deoki Nandan Vishwakarma

  *
  *

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

2011-07-27 Thread Abhinav Arora
I believe the method written is incorrect, it didnt work for me
i guess this is the right way...worked for me:

int **p;
p=malloc(3*sizeof(int *));

-- 
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/-/ATGevOaqMbUJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: OUTPUT

2011-07-27 Thread Kamakshii Aggarwal
i am not getting any of the ways..can u explain?

On Wed, Jul 27, 2011 at 9:06 PM, Abhinav Arora abhinavdgr8b...@gmail.comwrote:

 I believe the method written is incorrect, it didnt work for me
 i guess this is the right way...worked for me:

 int **p;
 p=malloc(3*sizeof(int *));

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

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




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

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



[algogeeks] Re: OUTPUT

2011-07-27 Thread amit
Hmm, I don't get the question.
 how to dynamically allocate memory for int *a[3]; ?
What do you mean by allocating memory for int *a[3];
Can you explain in some more details what exactly you want to do

On Jul 27, 8:39 pm, Kamakshii Aggarwal kamakshi...@gmail.com wrote:
 i am not getting any of the ways..can u explain?

 On Wed, Jul 27, 2011 at 9:06 PM, Abhinav Arora 
 abhinavdgr8b...@gmail.comwrote:





  I believe the method written is incorrect, it didnt work for me
  i guess this is the right way...worked for me:

  int **p;
  p=malloc(3*sizeof(int *));

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

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

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

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



Re: [algogeeks] sizeof() question.

2011-07-27 Thread Vishal Thanki
I am not sure about the first question, but if you use sizeof(main()),
it gives the ans 4.
vishal@ubuntu:~/progs/c\ 09:12:57 PM $ cat alg.c
#includestdio.h
int main()
{
printf(%d\n,sizeof(main()));
 return 0;
}
vishal@ubuntu:~/progs/c\ 09:13:00 PM $ gcc alg.c
vishal@ubuntu:~/progs/c\ 09:13:02 PM $ ./a.out
4
vishal@ubuntu:~/progs/c\ 09:13:03 PM $


The reason why it doesn't overflow is because sizeof() operator
calculates the size at compile time, and it doesn't really invoke
main().

Vishal

On Wed, Jul 27, 2011 at 9:02 PM, Charlotte Swazki
charlotteswa...@yahoo.fr wrote:
 Hi there,

 I have two questions,

 Why sizeof(main) == 1 ? (sizeof(func) == 1).
 Not 4 bytes ?.sizeof(void) == 1 too.


 And this code doesn't stackoverflow ?
 int main() {

  sizeof(main());
 }



 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.



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

2011-07-27 Thread Abhinav Arora
Look we wish to allocate memory for an array of 3 integer pointers.
so when we do dynamic allocation we always store the result in a pointer to 
the required data type.
for example if you wish to dynamically allocate int arr[3[]
u will write :

int *p=malloc(3*sizeof(int));

So now when you do it for an array of integer pointers the result of malloc 
should point to the first element of the dynamically allocated array. The 
elements of the array are pointers hence the memory allocated will be saved 
in a pointer that will correspond to the pointer to the first element. Since 
the elements are pointers so the result of malloc will be saved to a pointer 
to a pointer.

My sample program which i compiled in Dev C++ is as follows :


#includestdio.h
#includeconio.h
main()
{
  int a,b,c;
  int **p;
  p=malloc(3*sizeof(int *));
  a=b=c=1;
  p[0]=a;
  p[1]=b;
  p[2]=c;
  printf(%d %d %d,*p[0],*p[1],*p[2]);
  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/-/ScQJutsiThgJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] sizeof() question.

2011-07-27 Thread Charlotte Swazki
No. it's wrong.

sizeof(main()) == sizeof(int) because main return integer. 

i



- Mail original -
De : Vishal Thanki vishaltha...@gmail.com
À : algogeeks@googlegroups.com
Cc : 
Envoyé le : Mercredi 27 Juillet 2011 15h45
Objet : Re: [algogeeks] sizeof() question.

I am not sure about the first question, but if you use sizeof(main()),
it gives the ans 4.
vishal@ubuntu:~/progs/c\ 09:12:57 PM $ cat alg.c
#includestdio.h
int main()
{
    printf(%d\n,sizeof(main()));
return 0;
}
vishal@ubuntu:~/progs/c\ 09:13:00 PM $ gcc alg.c
vishal@ubuntu:~/progs/c\ 09:13:02 PM $ ./a.out
4
vishal@ubuntu:~/progs/c\ 09:13:03 PM $


The reason why it doesn't overflow is because sizeof() operator
calculates the size at compile time, and it doesn't really invoke
main().

Vishal

On Wed, Jul 27, 2011 at 9:02 PM, Charlotte Swazki
charlotteswa...@yahoo.fr wrote:
 Hi there,

 I have two questions,

 Why sizeof(main) == 1 ? (sizeof(func) == 1).
 Not 4 bytes ?.sizeof(void) == 1 too.


 And this code doesn't stackoverflow ?
 int main() {

  sizeof(main());
 }



 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.



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

2011-07-27 Thread Nikhil Gupta
Great solution amit. Thanks.

On Wed, Jul 27, 2011 at 8:30 PM, amit amit.codenam...@gmail.com wrote:

 #include cstdio
 #include cstring
 using namespace std;

 const int MX = 1000;

 int n, k;
 char str[MX], partial[MX];

 void solve(int pos, int aux) {
if(aux==k) {
partial[aux] = 0;
printf(%s\n, partial);
return;
}

for(int i = pos; i  n; i++) {
partial[aux] = str[i];
solve(i+1, aux+1);
}
 }

 int main() {
scanf(%s, str);
scanf(%d, k);
n = strlen(str);
solve(0, 0);
 }


 On Jul 27, 7:49 pm, Rajeev Kumar rajeevprasa...@gmail.com wrote:
  One more thread is running parallel on the same topic
  Please refer :
 http://comments.gmane.org/gmane.comp.programming.algogeeks/17279
 
  On Wed, Jul 27, 2011 at 7:39 AM, Nikhil Gupta nikhilgupta2...@gmail.com
 wrote:
 
 
 
 
 
   Given a string of length 5 (example abcde), write a program to print
 all
   the possible combinations OF LENGTH 3.
 
   In this case : abc, abd, abe, acd, ace, ade, bcd, bce, bde, cde
 
   Can someone provide a working code?
 
   --
   Nikhil Gupta
   Senior Co-ordinator, Publicity
   CSI, NSIT Students' Branch
   NSIT, New Delhi, 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.
 
  --
  Thank You
  Rajeev 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.




-- 
Nikhil Gupta
Senior Co-ordinator, Publicity
CSI, NSIT Students' Branch
NSIT, New Delhi, 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.



[algogeeks] Re: sizeof() question.

2011-07-27 Thread Abhinav Arora


The *sizeof* operator cannot be used with the following operands:

   - Functions. (However, *sizeof* can be applied to pointers to functions.)
   - Bit fields.
   - Undefined classes.
   - The type *void*.
   - Dynamically allocated arrays.
   - External arrays.
   - Incomplete types.
   - Parenthesized names of incomplete types


so when you use mainits the name of a function and not pointerin 
this case we get an implementational dependent unsigned integer which can be 
1 too...
if you write sizeof(main()) or sizeof(main)...you will get 4 which will be 
the size of a pointer

   - 

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

2011-07-27 Thread Vijay Khandar
#includestdio.h
#includeconio.h
void main()
{
clrscr();
int x=1,y=1,z=1;
x+=y+=z;
printf(\n %d\n ,xy?y:x);
printf(\n %d\n,xy?x++:y++);
printf(\n %d %d\n,x,y);
printf(\n %d\n,z+=xy?x++:y++);
printf(\n %d %d %d\n,x,y,z);
x=3;y=z=4;
printf(\n %d\n,z=y=x?1:0);
printf(\n %d\n,z=yy=x);
getch();
}

I m getting o/p as--
3
2
3 3
4
3 4 4
0
1

 I m confusing fm fourth printf...plz explain me..

Vijay.

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

2011-07-27 Thread amit karmakar
 sizeof(main()) == sizeof(int) because main return integer.
But main isn't invoked, sizeof does all thing at compile time.

On Wed, Jul 27, 2011 at 9:27 PM, Charlotte Swazki
charlotteswa...@yahoo.frwrote:

 No. it's wrong.

 sizeof(main()) == sizeof(int) because main return integer.

 i



 - Mail original -
 De : Vishal Thanki vishaltha...@gmail.com
 À : algogeeks@googlegroups.com
 Cc :
 Envoyé le : Mercredi 27 Juillet 2011 15h45
 Objet : Re: [algogeeks] sizeof() question.

 I am not sure about the first question, but if you use sizeof(main()),
 it gives the ans 4.
 vishal@ubuntu:~/progs/c\ 09:12:57 PM $ cat alg.c
 #includestdio.h
 int main()
 {
 printf(%d\n,sizeof(main()));
 return 0;
 }
 vishal@ubuntu:~/progs/c\ 09:13:00 PM $ gcc alg.c
 vishal@ubuntu:~/progs/c\ 09:13:02 PM $ ./a.out
 4
 vishal@ubuntu:~/progs/c\ 09:13:03 PM $


 The reason why it doesn't overflow is because sizeof() operator
 calculates the size at compile time, and it doesn't really invoke
 main().

 Vishal

 On Wed, Jul 27, 2011 at 9:02 PM, Charlotte Swazki
 charlotteswa...@yahoo.fr wrote:
  Hi there,
 
  I have two questions,
 
  Why sizeof(main) == 1 ? (sizeof(func) == 1).
  Not 4 bytes ?.sizeof(void) == 1 too.
 
 
  And this code doesn't stackoverflow ?
  int main() {
 
   sizeof(main());
  }
 
 
 
  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.
 
 

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

2011-07-27 Thread Charlotte Swazki
Thanks a lot !




De : Abhinav Arora abhinavdgr8b...@gmail.com
À : algogeeks@googlegroups.com
Cc : Charlotte Swazki charlotteswa...@yahoo.fr
Envoyé le : Mercredi 27 Juillet 2011 16h02
Objet : Re: sizeof() question.


The sizeof operator cannot be used with the following operands:
* Functions. (However, sizeof can be applied to pointers to functions.)
* Bit fields.
* Undefined classes.
* The type void.
* Dynamically allocated arrays.
* External arrays.
* Incomplete types.
* Parenthesized names of incomplete types

so when you use mainits the name of a function and not pointerin this 
case we get an implementational dependent unsigned integer which can be 1 too...
if you write sizeof(main()) or sizeof(main)...you will get 4 which will be the 
size of a pointer
* 

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



Re: [algogeeks] Facebook Interview question at NIT Warangal

2011-07-27 Thread Ankur Garg
Hi

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

Does anyone know any better solution ?

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

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


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

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


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

 Check this

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


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

 Here is the working code..

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

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



 On Tue, Jul 26, 2011 at 5:18 PM, praneethn praneeth...@gmail.com
 wrote:
 
  check this link:
 
  *http://www.stefan-pochmann.info/spots/tutorials/sets_subsets/*
 
  On Tue, Jul 26, 2011 at 11:59 AM, sumit sumitispar...@gmail.com
 wrote:
 
  Given an array of size n, print all the possible subset of array of
  size k.
  eg:-
  input:
  a[]={1,2,3,4}, k = 2
  output:
  1,2
  1,3
  1,4
  2,3
  2,4
  3,4
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 

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


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


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




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

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


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



Re : [algogeeks] Xplain the C code

2011-07-27 Thread Charlotte Swazki
it's 11.

i think you juste write out of the  a[] array, so '\0', can be at a[4], or a[7] 
etc... and strlen can change. (the output of this program is 11 for me).




De : Shantanu Sachdev shantanumn...@gmail.com
À : algogeeks@googlegroups.com
Envoyé le : Mercredi 27 Juillet 2011 16h08
Objet : [algogeeks] Xplain the C code



#includestdio.h
#includestring.h
int main()
{
        char a[3]=mnnitald;
        int x=strlen(a);
        printf(%d,x);
}

Plz xplain the output of this program. x comes out to be 7. if  u take a[2],den 
it comes to be 6 nd so on.and if a[7] is taken, size comes out to be 10. 
 Compiler - GCC.-- 
SHANTANU SACHDEV
20098080
MNNIT ALLAHABAD
-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

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



[algogeeks] BEST-WORST case time

2011-07-27 Thread Mani Bharathi
What is the BEST-WORST case time to add and remove elements from a queue 
that has been implemented with the help of 2 stacks.

-- 
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/-/xRSbK_Pag3MJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Logical operator question

2011-07-27 Thread Vijay Khandar
#includestdio.h
#includeconio.h
void main()
{
clrscr();
int x,y,z;
x=y=z=1;
printf(\n %d,++x||++y++z);
printf(\n %d %d %d ,x,y,z);
x=y=z=1;
printf(\n %d,++x++y||++z);
printf(\n %d %d %d,x,y,z);
x=y=z=1;
printf(\n %d,++x++y++z);
printf(\n %d %d %d,x,y,z);
x=y=z=-1;
printf(\n %d,++x++y||++z);
printf(\n %d %d %d,x,y,z);
x=y=z=-1;
printf(\n %d,++x||++y++z);
printf(\n %d %d %d,x,y,z);
x=y=z=-1;
printf(\n %d,++x++y++z);
printf(\n %d %d %d,x,y,z);
getch();
}

plz anyone provide the o/p for this program.I m very much
confusing

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

2011-07-27 Thread Jnana Sagar
what do u mean by o/p..actually what r u asking for..sorry to ask
so..i couldn't get u..

On 7/27/11, Vijay Khandar vijaykhand...@gmail.com wrote:
 #includestdio.h
 #includeconio.h
 void main()
 {
 clrscr();
 int x,y,z;
 x=y=z=1;
 printf(\n %d,++x||++y++z);
 printf(\n %d %d %d ,x,y,z);
 x=y=z=1;
 printf(\n %d,++x++y||++z);
 printf(\n %d %d %d,x,y,z);
 x=y=z=1;
 printf(\n %d,++x++y++z);
 printf(\n %d %d %d,x,y,z);
 x=y=z=-1;
 printf(\n %d,++x++y||++z);
 printf(\n %d %d %d,x,y,z);
 x=y=z=-1;
 printf(\n %d,++x||++y++z);
 printf(\n %d %d %d,x,y,z);
 x=y=z=-1;
 printf(\n %d,++x++y++z);
 printf(\n %d %d %d,x,y,z);
 getch();
 }

 plz anyone provide the o/p for this program.I m very much
 confusing

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

2011-07-27 Thread aditi garg
C i guess ur comfortable wid the frst 3...
now in fourth c the order of evaluation frst xy is evaluated as   has
higher precedence that +=...since both r 3...so condition is false and y++
is taken...so z+=y++ takes place...
z ws 1 and y=3...so z becomes 4 and it is printed... and after this y
becomes 4... and since x++ ws not evaluated it retains its value of 3...
in the next one z=y takes place frst( associativity of = is left to right)
,since it is true it become 1 now 1=x is false hence ans 0...
in the last both z=y and y=x are true hence 1
i hope it is clear...


hence the ans 3 4 4 fr the next printf

On Wed, Jul 27, 2011 at 9:33 PM, Vijay Khandar vijaykhand...@gmail.comwrote:

 #includestdio.h
 #includeconio.h
 void main()
 {
 clrscr();
 int x=1,y=1,z=1;
 x+=y+=z;
 printf(\n %d\n ,xy?y:x);
 printf(\n %d\n,xy?x++:y++);
 printf(\n %d %d\n,x,y);
 printf(\n %d\n,z+=xy?x++:y++);
 printf(\n %d %d %d\n,x,y,z);
 x=3;y=z=4;
 printf(\n %d\n,z=y=x?1:0);
 printf(\n %d\n,z=yy=x);
 getch();
 }

 I m getting o/p as--
 3
 2
 3 3
 4
 3 4 4
 0
 1

  I m confusing fm fourth printf...plz explain me..

 Vijay.

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

9718388816

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

2011-07-27 Thread Vijay Khandar
I m getting o/p
1
2 1 1
1
2 2 1
 but on wards when x=y=z= -1
then i m getting something different o/p.

On Wed, Jul 27, 2011 at 10:18 PM, Jnana Sagar supremeofki...@gmail.comwrote:

 what do u mean by o/p..actually what r u asking for..sorry to ask
 so..i couldn't get u..

 On 7/27/11, Vijay Khandar vijaykhand...@gmail.com wrote:
  #includestdio.h
  #includeconio.h
  void main()
  {
  clrscr();
  int x,y,z;
  x=y=z=1;
  printf(\n %d,++x||++y++z);
  printf(\n %d %d %d ,x,y,z);
  x=y=z=1;
  printf(\n %d,++x++y||++z);
  printf(\n %d %d %d,x,y,z);
  x=y=z=1;
  printf(\n %d,++x++y++z);
  printf(\n %d %d %d,x,y,z);
  x=y=z=-1;
  printf(\n %d,++x++y||++z);
  printf(\n %d %d %d,x,y,z);
  x=y=z=-1;
  printf(\n %d,++x||++y++z);
  printf(\n %d %d %d,x,y,z);
  x=y=z=-1;
  printf(\n %d,++x++y++z);
  printf(\n %d %d %d,x,y,z);
  getch();
  }
 
  plz anyone provide the o/p for this program.I m very much
  confusing
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

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



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



Re: [algogeeks] Re: MS c output ques

2011-07-27 Thread aditi garg
i made some mistake...and yea wid input siva output is s..:)

On Wed, Jul 27, 2011 at 6:26 PM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:

 but what input did u give??
 if u r giving i/p as siva o/p will be s only

 On Wed, Jul 27, 2011 at 1:24 AM, aditi garg aditi.garg.6...@gmail.comwrote:

 @rajeev
 i ran dis code
 int main()
 {

 char str[80];
 strcpy(str,siva);
 scanf(%[^india],str);
 printf(%s,str);
 return 0;


 }
 and i got the output as siva...instead of s as expected...can u plz point
 out the error

 On Tue, Jul 26, 2011 at 11:21 PM, siva viknesh sivavikne...@gmail.comwrote:

 @both...fantastic explanation...thanks :)

 On Jul 26, 10:34 pm, rajeev bharshetty rajeevr...@gmail.com wrote:
  So if the input is gujarat it scans gujarat to find the first character
 in
  gujarat which is also present in india . So the character in gujarat is
 a so
  it will stop on encountering a and prints the string scanned till then.
 
  If the input is india , it matches at first location so it prints the
  contents of str which is junk.
 
  Now consider rajeev it will print r because of a at second position.
 and for
  siva it will print s try it out.
 
  Hope you understood the concept.
 
 
 
 
 
 
 
 
 
  On Tue, Jul 26, 2011 at 10:54 PM, kc Liyan kcli...@gmail.com wrote:
   if U given input as gujarat the scanf will accept inputs as
   char's.but there s an ^ which means ex-or operation should be
   performed regular check of existance of any char of {india}...
   untill it get's the existance then it will stop the input
   getting..finally it prints as guj
 
   On 7/26/11, siva viknesh sivavikne...@gmail.com wrote:
main()
{
 
char str[80];
strcpy(str,junk);
scanf(%[^india],str);
printf(%s,str);
 
}
 
...input is gujarat.output is guj.plz explain how?
 
--
You received this message because you are subscribed to the Google
 Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  Regards
  Rajeev N B http://www.opensourcemania.co.cc

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




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

 9718388816

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




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

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




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

9718388816

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

2011-07-27 Thread siva viknesh
@DK.perfect explanation :)

On Jul 27, 8:14 pm, Rajeev Kumar rajeevprasa...@gmail.com wrote:
 @All : very good article on this 
 :http://tech-queries.blogspot.com/2011/01/nuts-and-bolts-algorithm.html









 On Wed, Jul 27, 2011 at 7:49 AM, DK divyekap...@gmail.com wrote:
  @All: Please pay attention to CodeHunter's answer. This is a standard Nuts
  and Bolts problem.
  For those of you that are not aware, the Nuts and Bolts problem is as
  follows:

  Given an array of nuts and another array of bolts, we need to match up all
  the nuts with all the bolts.
  The constraint is that a bolt cannot be compared to another bolt except by
  comparing their sizes with
  respect to some nut. (A similar constraint on nuts vis a vis bolts).

  The solution to this problem can be done in O(N log N) using a variant of
  quicksort.
  The algorithm is as follows:

  1. Select a random nut from the nuts array as the partition element
  2. Partition the bolts array into 3 parts based on the nut: || nut|| ==
  nut ||  nut||
  3. Select a bolt from the == nut array
  4. Partition the nuts array into 3 parts based on the bolt: || bolt|| ==
  bolt ||  bolt||
  5. Recurse from step 1 on the two subarrays.

  Expected Time Complexity: O(N log N)
  Extra Space Required: O(1)

  --
  DK

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

   --
  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/-/bsBtugahyawJ.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 Thank You
 Rajeev 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.



[algogeeks] direct i ..ques

2011-07-27 Thread siva viknesh
No. rectangles in NxN matrix

... is it   n^2 + (n-2) ??

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



[algogeeks] C-question

2011-07-27 Thread Vijay Khandar
#includestdio.h
#includeconio.h
int f(int n)
{
if(n=1)
{
printf( %d,n);
}
else
{
f(n/2);
printf( %d,n%2);
}
}

void main()
{
clrscr();
f(173);
getch();
}

o/p-1 0 1 0 1 1 0 1
but i m getting  1 0 1 1 0 1 0 1

plz explain 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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: OUTPUT

2011-07-27 Thread Kamakshii Aggarwal
@abhinav:thanks.:)

On Wed, Jul 27, 2011 at 9:23 PM, Abhinav Arora abhinavdgr8b...@gmail.comwrote:

 Look we wish to allocate memory for an array of 3 integer pointers.
 so when we do dynamic allocation we always store the result in a pointer to
 the required data type.
 for example if you wish to dynamically allocate int arr[3[]
 u will write :

 int *p=malloc(3*sizeof(int));

 So now when you do it for an array of integer pointers the result of malloc
 should point to the first element of the dynamically allocated array. The
 elements of the array are pointers hence the memory allocated will be saved
 in a pointer that will correspond to the pointer to the first element. Since
 the elements are pointers so the result of malloc will be saved to a pointer
 to a pointer.

 My sample program which i compiled in Dev C++ is as follows :


 #includestdio.h
 #includeconio.h
 main()
 {
   int a,b,c;
   int **p;
   p=malloc(3*sizeof(int *));
   a=b=c=1;
   p[0]=a;
   p[1]=b;
   p[2]=c;
   printf(%d %d %d,*p[0],*p[1],*p[2]);
   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/-/ScQJutsiThgJ.

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




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

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



Re: [algogeeks] Small Doubt

2011-07-27 Thread Anika Jain
no we cant..
coz when we do say int *p=4000;
its fine till now.. and if we do *p=10; it is segmentation fault..

On Wed, Jul 27, 2011 at 10:35 PM, rShetty rajeevr...@gmail.com wrote:

 Usually when I declare a variable it will be stored in memory location
 with some address .
 Such as  consider I declare int x=10 , it will stored in some address
 1003 (say).
 Now my question is can I control the address being assigned to a
 variable in C . Say, I want to store x in address in 4000 and not in
 1003 defined by the compiler .(Usually this can be done in assembly).
 Can I do that ? 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 algogeeks@googlegroups.com.
 To unsubscribe from 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] Re: direct i ..ques

2011-07-27 Thread Abhinav Arora
It will be (1+2+3+,,,+n)^2.u can verify it for a chess board hich will 
have 1296 rectangles for n=8

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

2011-07-27 Thread Muthu Raj
I am getting the proper output :) 1 0 1 0 1 1 0 1




*Muthuraj R.
4TH Year BE.**
Information Science Dept*
*PESIT, Bengaluru .
*




On Wed, Jul 27, 2011 at 11:19 PM, Vijay Khandar vijaykhand...@gmail.comwrote:

 #includestdio.h
 #includeconio.h
 int f(int n)
 {
 if(n=1)
 {
 printf( %d,n);
 }
 else
 {
 f(n/2);
 printf( %d,n%2);
 }
 }

 void main()
 {
 clrscr();
 f(173);
 getch();
 }

 o/p-1 0 1 0 1 1 0 1
 but i m getting  1 0 1 1 0 1 0 1

 plz explain 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
 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] Re: C output 2

2011-07-27 Thread private.joker
Passing a pointer across functions does not create any problem and doesn't 
cause memory leak. but passing an array ,for eg

int *fun()
{
int a[12];
return a;
}

this creates memory leak as the call stack no more holds the array. So, in 
essence, though int *a and int a[]  behave quite similarly on 
many occasions, subtle differences do occur bw the two

-- 
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/-/wvABGZ6uAH0J.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: rotate a matrix NVIDIA question

2011-07-27 Thread Puneet Gautam
Can anyone give an O(n) solution pls...??
I think the above code is an O(n^2) solution..
if i am not wrong...!!!



On 7/27/11, amit amit.codenam...@gmail.com wrote:
 #include cstdio
 #include algorithm
 using namespace std;

 const int MX = 1000;
 int n, m;
 int a[MX][MX];

 int main() {
 scanf(%d%d, n, m);
 for(int i = 0; i  n; i++)
 for(int j = 0; j  m; j++)
 scanf(%d, a[i][j]);

 for(int i = 0; i  n/2; i++)
 for(int j = 0; j  m; j++)
 swap(a[i][j], a[n-i-1][m-j-1]);
 if(n1)
 for(int j = 0; j  m/2; j++)
 swap(a[n/2][j], a[n/2][m-j-1]);

 for(int i = 0; i  n; i++) {
 for(int j = 0; j  m; j++)
 printf(%d , a[i][j]);
 printf(\n);
 }
 }


 On Jul 27, 7:54 pm, Anika Jain anika.jai...@gmail.com wrote:
 is it lyk for {1,2,3
                    4,5,6,
                    7,8,9}
 to be {3,2,1,
          6,5,4,
          9,8,7}    ??



 On Wed, Jul 27, 2011 at 9:37 AM, Deoki Nandan deok...@gmail.com wrote:
  rotate a 2D matrix by angle 180

  --
  **With Regards
  Deoki Nandan Vishwakarma

  *
  *

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

2011-07-27 Thread rajeev bharshetty
The output is 10101101
consider it to be f(173) - f(86) - f(43) - f(21) - f(10) - f(5) - f(2)
- f(1)
  1   0 110
1   01

Hope you get the recursion there .

On Wed, Jul 27, 2011 at 11:19 PM, Vijay Khandar vijaykhand...@gmail.comwrote:

 #includestdio.h
 #includeconio.h
 int f(int n)
 {
 if(n=1)
 {
 printf( %d,n);
 }
 else
 {
 f(n/2);
 printf( %d,n%2);
 }
 }

 void main()
 {
 clrscr();
 f(173);
 getch();
 }

 o/p-1 0 1 0 1 1 0 1
 but i m getting  1 0 1 1 0 1 0 1

 plz explain 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
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




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

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

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



[algogeeks] Re: rotate a matrix NVIDIA question

2011-07-27 Thread amit karmakar
If you meant rotate a 2D matrix by angle 180 of order n x n
Then you cannot have a O(n) algo, Each of the n^2 elements must be
accessed so you cannot have anything less than n^2

On Jul 27, 10:59 pm, Puneet Gautam puneet.nsi...@gmail.com wrote:
 Can anyone give an O(n) solution pls...??
 I think the above code is an O(n^2) solution..
 if i am not wrong...!!!

 On 7/27/11, amit amit.codenam...@gmail.com wrote:



  #include cstdio
  #include algorithm
  using namespace std;

  const int MX = 1000;
  int n, m;
  int a[MX][MX];

  int main() {
      scanf(%d%d, n, m);
      for(int i = 0; i  n; i++)
          for(int j = 0; j  m; j++)
              scanf(%d, a[i][j]);

      for(int i = 0; i  n/2; i++)
          for(int j = 0; j  m; j++)
              swap(a[i][j], a[n-i-1][m-j-1]);
      if(n1)
          for(int j = 0; j  m/2; j++)
              swap(a[n/2][j], a[n/2][m-j-1]);

      for(int i = 0; i  n; i++) {
          for(int j = 0; j  m; j++)
              printf(%d , a[i][j]);
          printf(\n);
      }
  }

  On Jul 27, 7:54 pm, Anika Jain anika.jai...@gmail.com wrote:
  is it lyk for {1,2,3
                     4,5,6,
                     7,8,9}
  to be {3,2,1,
           6,5,4,
           9,8,7}    ??

  On Wed, Jul 27, 2011 at 9:37 AM, Deoki Nandan deok...@gmail.com wrote:
   rotate a 2D matrix by angle 180

   --
   **With Regards
   Deoki Nandan Vishwakarma

   *
   *

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

2011-07-27 Thread Puneet Gautam
@nikhil:So what u mean is that if i have:

struct{
int a;
char b[5];
};

the size of this struct's node will be 12 not 9.., to make it a multiple of 4??



On 7/26/11, Nikhil Gupta nikhilgupta2...@gmail.com wrote:
 Padding is not a topic of self referential structure.

 Padding means that extra spaces of memory are used by the compiler to
 allocate memory. This is done to have the memory address as a multiple of
 the size of the variable. This speeds up the processing of these variables
 by the compiler.

 On Tue, Jul 26, 2011 at 8:09 PM, Puneet Gautam
 puneet.nsi...@gmail.comwrote:

 what is meant by padding in self_referenced structure?
 Is it always necessary?

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




 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, 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] interview ques

2011-07-27 Thread himanshu kansal
if u hv say 20 million records and u have to create a b+ tree then you
might be storing 20 million pointers at the leaf levelhow can u
optimize this(using b+ tree only)???

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

2011-07-27 Thread Reynald
Which of the following data structure do better job (has lesser time
complexity) at searching elements that has a worst-case time
complexity of O(n)? Do not account for the cost of building the Data
structure in searching cost.
a) Linked list with element sorted by value
b) Binary tree with no ordering
c) Ordered array
d) Hast table with bucket, made up of linked list, where linked list
have no ordering.

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



  1   2   >