Re: [algogeeks] C ouput

2011-07-25 Thread sameer.mut...@gmail.com
On 7/25/11, private.joker abhi123khat...@gmail.com wrote:
 I guess I got that.
 (a + 1) increments the pointer to the array(a here) according to the size
 of array where as p, being a pointer to an int gets incremented by the size
 of int(4 byte in 32 bit compiler) with the statement p = p+1

 Correct me if i am wrong.

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




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

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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-25 Thread sameer.mut...@gmail.com
f(20,1)-f(10,2)-1- f(5,4)-2 -f(2,8) +4 -
f(1,16)-8 - f(0,32) +16-return 0
   10-1=9   12-2=10 - 8+4=12 16-8=8
  0+16 - -




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




On Mon, Jul 25, 2011 at 8:48 AM, Vijay Khandar vijaykhand...@gmail.comwrote:

 #includestdio.h
 #includeconio.h
 int f(int n,int k)
 {
 if (n==0)
 return 0;
 else
  if(n%2)
  return f(n/2,2*k)+k;
  else return f(n/2,2*k)-k;
 }
 int main()
 {
 clrscr();
 printf(\n %d,f(20,1));
 getch();
 }


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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-25 Thread sameer.mut...@gmail.com
yeah output
 0
1 1
*is dis because of side effect? *
* *
*
*
*Muthuraj R.
4TH Year BE.**
Information Science Dept*
*PESIT, Bengaluru .
*




On Mon, Jul 25, 2011 at 10:49 PM, Deoki Nandan deok...@gmail.com wrote:

 run on gcc compiler it would be
 0
 1 1


 On Mon, Jul 25, 2011 at 10:35 PM, geek forgeek geekhori...@gmail.comwrote:

 1.
 #includestdio.h
 main()
 {
 int i=1;
  printf(\n%d,i^=1%2);
  printf(\n%d %d,i^=1%2,i=1%2);
 return 0;
 }

 output 3 3
 hey shudnt the output be 3 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.




 --
 **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] OUTPUT

2011-07-25 Thread sameer.mut...@gmail.com
its because of side effect where value of i is getting changed twice in a
single line.
correct me if i am wrong :)
*Muthuraj R.
4TH Year BE.**
Information Science Dept*
*PESIT, Bengaluru .
*




On Mon, Jul 25, 2011 at 11:01 PM, geek forgeek geekhori...@gmail.comwrote:

 y not the output is 3 2  coz on right to left evaluation  of printf i shud
 be left shifted by 1 bit wgich shud make it 2 ??


 On Mon, Jul 25, 2011 at 10:28 AM, sameer.mut...@gmail.com 
 sameer.mut...@gmail.com wrote:

 yeah output
  0
 1 1
 *is dis because of side effect? *
 * *
 *
 *
 *Muthuraj R.
 4TH Year BE.**
 Information Science Dept*
 *PESIT, Bengaluru .
 *





 On Mon, Jul 25, 2011 at 10:49 PM, Deoki Nandan deok...@gmail.com wrote:

 run on gcc compiler it would be
 0
 1 1


 On Mon, Jul 25, 2011 at 10:35 PM, geek forgeek geekhori...@gmail.comwrote:

 1.
 #includestdio.h
 main()
 {
 int i=1;
  printf(\n%d,i^=1%2);
  printf(\n%d %d,i^=1%2,i=1%2);
 return 0;
 }

 output 3 3
 hey shudnt the output be 3 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.




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


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

2011-07-24 Thread sameer.mut...@gmail.com
Declare the character strings
char five[7];
char four[7];
int three;
char two[7];
char one[7];

int his order and we get the correct output. But i dont know y?Its something
to do with Memory location where the strings are defined.










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




On Sat, Jul 23, 2011 at 10:57 PM, shady sinv...@gmail.com wrote:

 anyone ?


 On Sun, Jul 24, 2011 at 2:38 AM, Anika Jain anika.jai...@gmail.comwrote:

 in this in scanf one,two, four five will b thr, no  thr..

 and sumbody plz tell afterwards this change why the o/p is
 this is 10 times charlie
 thisis10charlie

 why in 'four' empty string is going??


 On Sat, Jul 23, 2011 at 9:37 PM, geek forgeek geekhori...@gmail.comwrote:

 #includestdio.h
 main()
 {
 char outline[50];
 char one[7],two[7],four[7],five[7];
 int three;
 sprintf(outline,this is %d times %s \n,10,charlie);
 printf(%s,outline);
 sscanf(outline,%s %s %d %s %s,one,two,three,four,five);
 printf(%s,one);
 printf(%s,two);
 printf(%d,three);
 printf(%s,four);
 printf(%s,five);
 }

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


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


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


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

2011-07-24 Thread sameer.mut...@gmail.com
@Anurag:

May i know which compiler gave you the above output?






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




On Sat, Jul 23, 2011 at 11:11 PM, Anurag atri anu.anurag@gmail.comwrote:

 The output will be
 This is 10 times charlie
 Thisis10timescharlie

 and it makes sense , this will be helpful
 http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/

 Regards
 Anurag Atri

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


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

2011-07-24 Thread sameer.mut...@gmail.com
No. Its not coming like dat.


This is 10 times charlie
Thisis10charlie


This is the output



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




On Sat, Jul 23, 2011 at 11:23 PM, shady sinv...@gmail.com wrote:

 it is not coming like that ?


 On Sun, Jul 24, 2011 at 11:41 AM, Anurag atri anu.anurag@gmail.comwrote:

 The output will be
 This is 10 times charlie
 Thisis10timescharlie

 and it makes sense , this will be helpful
 http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/

 Regards
 Anurag Atri

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


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


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

2011-07-24 Thread sameer.mut...@gmail.com
@Anrag: i am using gcc on Ubuntu.I also checkd it on Ideone online compiler.


But Declare the character strings
char five[7];
char four[7];
int three;
char two[7];
char one[7];

int his order and we get the correct output. But i dont know y?Its something
to do with Memory location where the strings are defined.



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




On Sat, Jul 23, 2011 at 11:34 PM, Anurag atri anu.anurag@gmail.comwrote:

 Dev c++ , which one are you using ?

 On Sun, Jul 24, 2011 at 12:01 PM, sameer.mut...@gmail.com 
 sameer.mut...@gmail.com wrote:

 No. Its not coming like dat.



 This is 10 times charlie
 Thisis10charlie


 This is the output




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




 On Sat, Jul 23, 2011 at 11:23 PM, shady sinv...@gmail.com wrote:

 it is not coming like that ?


 On Sun, Jul 24, 2011 at 11:41 AM, Anurag atri 
 anu.anurag@gmail.comwrote:

 The output will be
 This is 10 times charlie
 Thisis10timescharlie

 and it makes sense , this will be helpful
 http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/

 Regards
 Anurag Atri

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


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


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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
 Anurag Atri
 III year
 Computer Engineering
 Delhi College Of Engineering


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


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

2011-07-23 Thread sameer.mut...@gmail.com
@shady: yes its a good idea to have aptitude puzzles etc in other group

On Sat, Jul 23, 2011 at 8:29 AM, shady sinv...@gmail.com wrote:

 nice idea Saurabh, but i don't think much people will join that group too,
 and the difference should be on the basis of type of questions asked. Any
 suggestions from others ? There we can ask questions related to debugging
 and puzzles, aptitude


 On Sat, Jul 23, 2011 at 8:51 PM, saurabh singh saurab...@gmail.comwrote:

 The break statement here breaks out of the do loop so the o/p hello hmmm
 give a break statement after hello and you will get only hello.

 PS:Seeing the number of C questions wont it be a better idea to start a
 parallel group especially for the same?My request to the group admins for
 the same.


 On Sat, Jul 23, 2011 at 8:47 PM, geek forgeek geekhori...@gmail.comwrote:

 #includestdio.h
 main()
 {
 int i=3;
 switch(i)
 {
 do
 {
 case 3: printf(\nhello);
 case 2:printf(\n h);
 break;
 case 1:printf(wat);
 break;
 case 0: printf(hai);
 }while(i--);
 }
 }

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


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


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

2011-07-21 Thread sameer.mut...@gmail.com
i tried in gcc of Ubuntu and its working fineits not goin infinite ...

On Thu, Jul 21, 2011 at 6:44 AM, Aman Goyal aman.goya...@gmail.com wrote:

 I think it is kind of illegal to use it, cos i tried this code on gcc
 compiler oof ubuntu(code b) and the result is infinite loop, which doesnt go
 with our logic at all.


 On Thu, Jul 21, 2011 at 5:45 PM, karthiga m karthichandr...@gmail.comwrote:

 no it is legal only... its working 

 On 7/21/11, Reynald Suz reynaldsus...@gmail.com wrote:
  I tried in Dev C++,code-B executes infinitely. Why?
 
  On Thu, Jul 21, 2011 at 4:13 PM, Gaurav Popli abeygau...@gmail.com
 wrote:
 
  dont you think it is illegal using x=x-- or x=--x;??
 
  On Thu, Jul 21, 2011 at 2:56 PM, karthiga m karthichandr...@gmail.com
 
  wrote:
   in code  A using pr e- decrement  therefore i gets decremented when
   checking while condition so
   it will print as 9 8 7  6 5 4 3 2 1 .
   in code B using post-decrement  it will prints like 9 8 7 6 5 4 3 2 1
 0
   here why zero printing means while checking while condition x-- have
   previous value..therefore at tht time x-- is 1 so while condition
   executing and prints x value as zero.
  
   On 7/21/11, Reynald reynaldsus...@gmail.com wrote:
   Code: A
   int main()
   {
   int x = 10;
   while ( x = --x)
   printf(  %d , x);
   getchar();
   }
  
   Code: B
   int main()
   {
   int x = 10;
   while ( x = x--)
   printf(  %d , x);
   getchar();
   }
  
   Does Code-A and Code-B work similar? Justify.
  
   --
   You received this message because you are subscribed to the Google
  Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
  
   --
   You received this message because you are subscribed to the Google
   Groups
  Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
  
  
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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
  Reynald Reni
  Masters in Software Engineering
  CIT - 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.


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


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

2011-07-19 Thread sameer.mut...@gmail.com
#includestdio.h
int * fun(int a1,int b)
{
int a[2];
a[0]=a1;
a[1]=b;
//int c=5;
printf(%x\n,a[0]);
return a;
}
int main()
{
int *r=fun(3,5);
printf(%d\n,r[0]);
printf(%d\n,r[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.



Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree

2011-07-17 Thread sameer.mut...@gmail.com
@sagar: The question says Algo should be in place. So use of an array to
print the right border of tree is not advisable. We can do it recursively
without using an array also .

On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com 
sameer.mut...@gmail.com wrote:

 @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed
 twice. otherwise it is fine.


 On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.comwrote:

 please explain the code a bit more.. unable to understand it..an example
 will be better..


 On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.comwrote:

 Yep!

 On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul 
 swetharahu...@gmail.comwrote:

 @Reynald
 Will 75 not be included in the tree that u
 have given..??


 On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek 
 sagarpar...@gmail.comwrote:

 here is the code
 void border(node*);
 void recur(node*);

 void border(node *ptr)
 {
  node* tmp; int stack[20],top=0;
  if(tmp=ptr-left)
  {
   while(tmp-left)
   {
printf(%d ,tmp-data);
tmp=tmp-left;
   }
  }
  recur(ptr);
  if(tmp=ptr-right)
  {
   while(tmp-right)
   {
stack[top++]=tmp-data;
tmp=tmp-right;
   }
  }
  while(top--) printf(%d ,stack[top]);
  printf(%d\n,ptr-data);
 }

 void recur(node* ptr)
 {
  if(ptr-left) recur(ptr-left);
  if(!ptr-left!ptr-right) printf(%d ,ptr-data);
  if(ptr-right)   recur(ptr-right);

 }

 On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote:

 Algo to find the border of a given binary tree. Optimized for space
 and time.
 Input:
  10
   / \
 50 50
/  \ /   \
  25  75   20020
  / \   /  /\
 15 35   120155   250

 Output:50 25 15 35 120 155 250 20 150 10

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




 --
 Regards
 Reynald Reni
 Masters in Software Engineering
 CIT - 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.




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

2011-07-17 Thread sameer.mut...@gmail.com
@Navneet:

Its not possible to solve this without a single tail pointer. I  have come
across this question saying it requires a single pointer and that pointer is
the tail pointer. So along with head you need a tail pointer or a global
pointer. Otherwise cannot keep track of header for reversed list.

On Sun, Jul 17, 2011 at 6:57 PM, Navneet navneetn...@gmail.com wrote:

 I am looking for a solution with no 'tail' node available/static types
 used etc.

 Also with algorithms given without above two conditions, i don't see
 they doing the right thing for me. Maybe i need to check more.

 Have you guys tried to see if this is working for you?

 On Jul 17, 4:42 pm, bharath kannan bharathgo...@gmail.com wrote:
  node * reverse(node *head)
  {
  if(head-next)
  {
   node * temp=reverse(head-next);
   head-next-next=head;
   head-next=NULL;
   return temp;
 }
 return head;
 
  }
 
  On Sun, Jul 17, 2011 at 4:57 PM, Piyush Sinha ecstasy.piy...@gmail.com
 wrote:
 
 
 
 
 
 
 
   *node *reverse(node *head)
   {
   if(head==NULL)
 return head;
   if(head-next==NULL)
 return head;
   node *temp = reverse(head-next);
   head-next-next = head;
   head-next = NULL;
return (temp);
   }*
 
   On Sun, Jul 17, 2011 at 4:30 PM, Anika Jain anika.jai...@gmail.com
 wrote:
 
   initial call to this will be rev(head);
 
   On Sun, Jul 17, 2011 at 4:28 PM, Anika Jain anika.jai...@gmail.com
 wrote:
 
   node *listing::rev(node *p)
   {
   if(p-next==NULL)
   {
   head=p;
   return p;
   }
   else
   {
   node *t=rev(p-next);
   t-next=p;
   p-next=NULL;
   tail=p;
   return p;
 
   }
   }
 
   On Sun, Jul 17, 2011 at 3:21 PM, Nishant Mittal 
   mittal.nishan...@gmail.com wrote:
 
   void rev_recursion(NODE **head)
   {
   if(*head==NULL)
   return;
   NODE *first, *rest;
   first=*head;
   rest=first-next;
   if(!rest)
   return;
   rev_recursion(rest);
   first-next-next=first;
   first-next=NULL;
   *head=rest;
 
   }
 
   On Sun, Jul 17, 2011 at 2:53 PM, vaibhav shukla 
   vaibhav200...@gmail.com wrote:
 
   struct node *reverse_recurse(struct node *start)
   {
 if(start-next)
 {
 reverse_recurse(start-next);
 start-next-next=start;
 return(start);
 }
 else
 {
 head=start;
 }
   }
 
   in main
 
   if(head)
   {
 temp = reverse_recurse(head);
 temp-next =NULL;
   }
 
   head and temp are global
 
   On Sun, Jul 17, 2011 at 2:42 PM, Navneet Gupta 
 navneetn...@gmail.comwrote:
 
   Hi,
 
   I was trying to accomplish this task with the following call ,
 header
   = ReverseList(header)
 
   I don't want to pass tail pointer or anything and just want that i
 get
   a reversed list with new header properly assigned after this call.
 I
   am getting issues in corner conditions like returning the correct
 node
   to be assigned to header.
 
   Can anyone give an elegant solution with above requirement? Since
 it
   is with recursion, please test for multiple scenarios (empty list,
 one
   node list, twe nodes
 
   list etc) before posting your solution. In case
   of empty list, the procedure should report that.
 
   --
   Regards,
   Navneet
 
   --
   You received this message because you are subscribed to the Google
   Groups Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
   --
 best wishes!!
   Vaibhav Shukla
   DU-MCA
 
--
   You received this message because you are subscribed to the Google
   Groups Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
--
   You received this message because you are subscribed to the Google
   Groups Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
--
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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*
   * 

Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree

2011-07-16 Thread sameer.mut...@gmail.com
@sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed
twice. otherwise it is fine.

On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.comwrote:

 please explain the code a bit more.. unable to understand it..an example
 will be better..


 On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.comwrote:

 Yep!

 On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.comwrote:

 @Reynald
 Will 75 not be included in the tree that u
 have given..??


 On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.comwrote:

 here is the code
 void border(node*);
 void recur(node*);

 void border(node *ptr)
 {
  node* tmp; int stack[20],top=0;
  if(tmp=ptr-left)
  {
   while(tmp-left)
   {
printf(%d ,tmp-data);
tmp=tmp-left;
   }
  }
  recur(ptr);
  if(tmp=ptr-right)
  {
   while(tmp-right)
   {
stack[top++]=tmp-data;
tmp=tmp-right;
   }
  }
  while(top--) printf(%d ,stack[top]);
  printf(%d\n,ptr-data);
 }

 void recur(node* ptr)
 {
  if(ptr-left) recur(ptr-left);
  if(!ptr-left!ptr-right) printf(%d ,ptr-data);
  if(ptr-right)   recur(ptr-right);

 }

 On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote:

 Algo to find the border of a given binary tree. Optimized for space
 and time.
 Input:
  10
   / \
 50 50
/  \ /   \
  25  75   20020
  / \   /  /\
 15 35   120155   250

 Output:50 25 15 35 120 155 250 20 150 10

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




 --
 Regards
 Reynald Reni
 Masters in Software Engineering
 CIT - 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.


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



Re: [algogeeks] C Output

2011-07-14 Thread sameer.mut...@gmail.com
1st problem

format specifier is %d whereas memory is allocated only for short int
memory allocated-2bytes. but being stored in 4bytes.
so a is overwritten by b.
In dis case where u give a=1, b=1, a becomes become 0.
n so it gives:0+1=1
in  d scanf if u use %hd instead u ll get d right output!!


On Thu, Jul 14, 2011 at 8:01 AM, nicks crazy.logic.k...@gmail.com wrote:

 Hey Guys, plz help me in getting these 2 C output problems

 *PROBLEM 1.*
 *
 *
 *#*includestdio.h
 int main()
 {
 short int a,b,c;
 scanf(%d%d,a,b);
  c=a+b;
 printf(%d,c);
 return 0;
 }
  INPUT-
 1 1

 OUTPUT
 1

 i am not getting why  1 is coming in the output.what difference is
 using short making in the code ???


 *PROBLEM 2.*
 *
 *
 *
 *
 #includestdio.h
 main()
 {
 struct
  {
 int a:1;
 int b:2;
 }t;
  t.b=6;
 t.a=2;
 printf(%d %d,t.a,t.b);
 }

 OUTPUT
 0 -2

 What does the statement  a:1 and b:1 mean and what are they doing.i am
 seeing them first time ever...hence not able to get the outputif someone
 has any idea plz 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.


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

2011-07-13 Thread sameer.mut...@gmail.com
Guys i always have this doubt.Please tell me whether stack frames allocated
for each recursive call will be cleared if we return in the middle of a
recursive call?

On Tue, Jul 12, 2011 at 10:22 PM, Don dondod...@gmail.com wrote:

 // Similar to other suggestions, but without tail recursion.

 ptr search(ptr root, int value)
 {
ptr result = 0;
while(root  !result)
{
result = (root-tag == value) ? root : search(root-left,
 value);
root = root-right;
}
return result;
 }

 On Jul 12, 8:28 am, anonymous procrastination opamp1...@gmail.com
 wrote:
  Hello,
 
  Suppose you have to search a particular node in a binary tree.
  The code is quite simple. Pick up any traversal and see if any node
  matches the value.
  Doubt I have is that how to pull out of the recursive function at the
  instant node is found.
  In iterative algos we use a break.
  Here I can use a global flag variable. But any other bettr way of
  doing this?

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



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



Re: [algogeeks] microsoft ques

2011-07-12 Thread sameer.mut...@gmail.com
@kranthi :

d solution u ve given is only for 2 continuous elements..
wr as d question doesnt limit it to 2.. It can be d product of any no. of
continuous elements.
So if the array is 200, 5, -2, -3, -1
den ans shd be 200*5*-2*-3 = 6000

N if m workin ur algo in d right way, den it ll give 1000

On Wed, Jul 13, 2011 at 10:52 AM, kranthi kumar damarlakran...@gmail.comwrote:

 I think this is the solution what u need U can do in O(n) time...


 #includeiostream
 using namespace std;

 main()
 {
 int a[7] = { 0, 0, 0, 19, 380, -1, 2};
 int prod, nprod;
 bool x = false;

 for(int i=0;i6;i++)
 {
 nprod = a[i] * a[i+1];
 coutnprodendl;
 if( x == false)
 {
 x = true;
 prod = nprod;
 }
 else if( x== true  prod  nprod )
 prod = nprod;
 }

 cout\nResult: prod;
 }



 --
 Regards:
 ---
 D Kranthi kumar
 Computer Science  Engg.
 1st Mtech, IIT Madras.

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


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



Re: [algogeeks] c doubt

2011-07-04 Thread sameer.mut...@gmail.com
Continuous memory allocation is used for 2-d array.
So a[2][5] will assign 10 continuous memory spaces.
Hello will be stored on the 1st 5 spaces. Hi will be saved on the next 2
consecutive spaces itself.
There is no null character saved for the 1st string so while printing it
prints until it finds a null character which exists only after hi.

So a[0] prints hellohi
and a[1] prints hi

On Mon, Jul 4, 2011 at 1:48 PM, Sangeeta sangeeta15...@gmail.com wrote:

 #includestdio.h
 #includestring.h
 void main()
 {
 char a[2][5]= {
 hellodear,
  hi};
 printf(%s%s,a[0],a[1]);
 }

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



Re: [algogeeks] Re: help..

2011-07-02 Thread sameer.mut...@gmail.com
nn-1  is the expression to find out if n is a power of 2...If nn-1 returns
0 its a power of 2 else its not.
And what sunny said is also ryt

On Sat, Jul 2, 2011 at 3:47 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 @cegprakash
 Expression resets the least significant set bit


 On Sat, Jul 2, 2011 at 3:20 PM, mohit goel mohitgoel291...@gmail.comwrote:

 May be this can work.give any counter example...
 int count;
 main()
 {
   int l,rope,cuts;
   scanf(%d%d,l,rope);
   count =0;

find_cuts(l,rope);
printf(cuts needed is %d,count);
getch();
return 0;
}

  int find_cuts(int l,int rope)

  {

 if(l==rope)
 return count;
  count++;
  printf(%d,count);
  l=l/2;
  if(l==rope)
  return count;
  if(ropel)
  rope =rope-l;

  find_cuts(l,rope);


  }

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

2011-07-02 Thread sameer.mut...@gmail.com
ASCII value of 'A' is 65 and Asciivalue of 'E' is 69.
69-65=4

On Sat, Jul 2, 2011 at 7:12 PM, abhijith reddy abhijith200...@gmail.comwrote:

 p[3] = 'E'
 p[1] = 'A'
 p[3]-p[1] = 4
 ?


 On Sat, Jul 2, 2011 at 7:10 PM, KK kunalkapadi...@gmail.com wrote:

 10. What does the following fragment of C-program print?

 char c[] = GATE2011;
 char *p =c;
 printf(%s, p + p[3] - p[1]);

  (A) GATE2011 (B) E2011 (C) 2011 (D) 011
 Answer: - (C)

 why is p[3] - p[1] returning 4 

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


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


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



Re: [algogeeks] Re: Test Cases

2011-07-01 Thread sameer.mut...@gmail.com
@hemanth: doing it in seperate for loops or in a single for loop both
results in O(n) time.It does not make a difference.

I think there cannot be a solution better than O(n) as we need to traverse
the array atleast once.

On Fri, Jul 1, 2011 at 12:57 PM, Hemanth Sagar hemanth2...@gmail.comwrote:

 The most efficient code will be surely of O(n). This is because there is no
 way of finding
 the min and max without scanning the entire array atleast once.

 Is this so? or any counter arguments ?


 On Sat, Jul 2, 2011 at 1:06 AM, rajeevrvis rajeev.open.1...@gmail.comwrote:

 Are there any Algorithms for finding efficient max differences ?


 On Jul 1, 11:42 pm, Hemanth 007 hemanth2...@gmail.com wrote:
  Hii,
  One improvement is that finding min and max can be done in a single
  run, rather than calling the  findMin and findMax separately.
  But yet the order is O(n);
  Is there any better soln than O(n);
 
  #includestdio.h
  #includelimits.h
  void findExtreme(int array[],int size,int* min,int* max){
  int i;
  for(i=0;isize;i++){
  if(array[i]  *max)*max = array[i];
  if(array[i]*min)*min=array[i];
  }
 
  }
 
  main(){
  int arr[]={0,609,211,432,31,};
  int max=INT_MIN,min=INT_MAX;
  findExtreme(arr,sizeof(arr)/sizeof(arr[0]),min,max);
  printf(%d %d ,max,min);
  printf(%d,max-min);}
 
  ~
  ~
  ~

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


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


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

2011-07-01 Thread sameer.mut...@gmail.com
how to Delete a node in a BST. Handle All Test cases.

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

2011-06-28 Thread sameer.mut...@gmail.com
its tryin to acess arr[3] which is not defined and nullhence it is
giving null and priniting default value 0.000.arr[2[ is only the last
defined array of structure.

On Tue, Jun 28, 2011 at 12:07 PM, udit sharma sharmaudit...@gmail.comwrote:

 I think this is also a compiler dependent program..
 Bcz if u run d code

 #includestdio.h
 typedef struct
 {
   char *name;
double salary;
 }job;

 main()
 {
 static job a={tcs,15000.0};
 static job a={ibm,25000.0};
 static job a={google,35000.0};
 int x=5;
 job *arr[3]={a,b,c};
  printf(%s %f\t,(3)[*arr]);
 }


 it'll give u : (null) 0.00
 This indicates tat d compiler is evaluating (3)[*arr] in  (3,x1)[*arr]

 And if d compiler gives: google 35000.00 as a result, means it is
 evaluating (3,x1)[*arr] as (2)[*arr]..
 Correct me if m 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.



Re: [algogeeks] Re: output plzz

2011-06-28 Thread sameer.mut...@gmail.com
We are getting same output because in this problem we wre typecastin
unsigned integer to a signed integer...Hence normal operation results.

On 6/28/11, Kamakshii Aggarwal kamakshi...@gmail.com wrote:
 #includestdio.h

 int main()
 {

 int array[] = {23,34,12,17,204,99,16};
 int TOTAL_ELEMENTS =(sizeof(array) / sizeof(array[0]));
 int d;
 for(d=-1;d = (TOTAL_ELEMENTS-2);d++)
 printf(%d\n,array[d+1]);
 return 0;
 }

 but in this case we are getting the same o/p..can u please again explain
 whats wrong with the above question.

 On Sat, Jun 25, 2011 at 9:24 PM, nicks crazy.logic.k...@gmail.com wrote:

 that's grt...i didn't knew it !!


 On Sat, Jun 25, 2011 at 4:43 AM, Anantha Krishnan 
 ananthakrishnan@gmail.com wrote:

 Good.


 On Sat, Jun 25, 2011 at 4:47 PM, RITESH SRIVASTAV 
 riteshkumar...@gmail.com wrote:

 sizeof returns size_t values and size_t is typedef unsigned int
 size_t;
 but when you compare it with -1(int) ,d=-1 is converted to unsigned
 int
 which becomes very large (INT_MAX)
 and d (INT_MAX)  7 so the loop is never executed.

 On Jun 25, 3:23 pm, harshit pahuja hpahuja.mn...@gmail.com wrote:
  #includestdio.h
  #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
  int array[] = {23,34,12,17,204,99,16};
  int main()
  {
  int d;
  for(d=-1;d = (TOTAL_ELEMENTS-2);d++)
  printf(%d\n,array[d+1]);
  return 0;
 
  }
 
  y der is nothing in the output .
 
  -
  Regards -
  HARSHIT PAHUJA

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


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


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



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



Re: [algogeeks] Reverse

2011-06-27 Thread sameer.mut...@gmail.com
guys temporary variable means not to store string in another variable.

On Mon, Jun 27, 2011 at 10:37 PM, hary rathor harry.rat...@gmail.comwrote:

 @vishal : dont you think that , i is also a variable?

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


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

2011-06-26 Thread sameer.mut...@gmail.com
#include iostream

using namespace std;

int main()
{
   int input[10];
int n;
   coutenter nendl;
   cinn;
   int output[10];
   coutenter input arrayendl;
   for(int i=0;in;i++)
   cininput[i];

   int a[n],b[n];
   a[0]=1;
   for(int i=1;in;i++)
   {
   a[i]=a[i-1]*input[i-1];

   }
   b[n-1]=1;
   for(int i=n-2;i=0;i--)
   {
   b[i]=b[i+1]*input[i+1];
   }
   for(int i=0;in;i++)
   {

   output[i]=a[i]*b[i];
   coutoutput[i]endl;
   }
   return 0;
}











On Sun, Jun 26, 2011 at 9:38 PM, ross jagadish1...@gmail.com wrote:

 Given an array A , of N integers ( In no particular order), fill up an
 auxilary array B such that B[i] contains the product of
 all elements in A other than A[i].
 Constraints:
 O(n) Time,
 Can this be done with O(1) space?
 Division is *not* allowed .

 eg: A 1 2 3 4 5
  B 120 60 40 30 24

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



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

2011-06-25 Thread sameer.mut...@gmail.com
May i know the reason please?

On Sat, Jun 25, 2011 at 1:06 PM, hary rathor harry.rat...@gmail.com wrote:

 sol 1 :

 #includeiostream
 using namespace std;
 int main(){
char arr[]=Pilani,*p=arr;
  p[0]='K';// does not work.
  *(p[0])='s'; //does not work;
coutp[0]  (void *)p  \n;
return 0;
 }

 sol 2 :
 #includeiostream
 using namespace std;
 int main(){
char *p=(char *)Pilani;
  p[0]='K';// does not work.
 *(p[0])='s'; //does not work;
coutp[0]  (void *)p  \n;
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.


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

2011-06-25 Thread sameer.mut...@gmail.com
It breaks out correctly when test condition value is 0 i.e when value of t
is 1

On Sat, Jun 25, 2011 at 4:41 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 No, Read about the return type of scanf


 On Sun, Jun 26, 2011 at 4:56 AM, amit the cool amitthecoo...@gmail.comwrote:

 main()
 {
 int i,t;
 for ( t=4;scanf(%d,i)-t;printf(%d\n,i))
printf(%d--,t--);
 }

 inputs and corresponding outputs are:
 0
 4--0
 1
 3--1
 2
 2--2
 3
 but the loop should break when 2 is given as input.

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