Re: [algogeeks] Pointers Usage

2013-01-03 Thread Debabrata Das
array would be allocated in stack and stack is very limited compared
to heap.If you want temporary data storage go for stack which will be
freed from stack once array goes out of scope else heap is preferred.

On Thu, Jan 3, 2013 at 1:01 AM, Rahul raikra...@gmail.com wrote:
 Take a look at the linux kernel .
 Or VLC player 's source code.
 You will not ask this question again.

-- 




Re: [algogeeks] Pointers Usage

2013-01-03 Thread Debabrata Das
@ arun... 8 byte may be for 64 bit application or far pointer ...

On Thu, Jan 3, 2013 at 6:29 PM, Arun Vishwanathan
aaron.nar...@gmail.com wrote:
 @atul/shady: why is it that pointer takes 8 bytes ? So the takes a memory
 location whose value is the address of the element it points to. Why does
 the pointer value have to take 8 bytes? I am sorry if I am missing something
 silly here.

-- 




[algogeeks] Doubt on Regular Expression

2012-04-03 Thread Debabrata Das
Hi All,

I was looking for an regular expression such that given a string X,it
should exclude a  token in single quote preceded by a particular
string.

e.g in java say.

String X= 'abc  '   like'abc  ' ='abc'
N.replaceall(reg expression ??) would transform it to : ?? like
'abc  ' =?? ( remove extra space as well but not spaces in single
quote)

Please let me know if you have any doubt.

Thanks,
Debabrata

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

2011-11-13 Thread Debabrata Das
process heap is organized as chunk of free memory need not be
contiguous and during  freeing what free() does is update it's book
keeping records and it's bins array so that next time if asked for new
space may return the same space however it doesn't wipe the freed data
but few run time directive are present in few rtdl libary to overwrite
the freed space with some poison value ( configurable )

On Sun, Nov 13, 2011 at 11:52 PM, sumit mahamuni
sumit143smail...@gmail.com wrote:


 On Nov 11, 9:16 pm, saurabh singh saurab...@gmail.com wrote:
 well that would be tough for the compiler to predict things that will
 happen during run time.Its the job of garbage collector to do that.
 well compiler cant predict what will happen at runtime.









 On Fri, Nov 11, 2011 at 8:36 PM, shady sinv...@gmail.com wrote:
  ok, thanks.

  why do we need to free the memory ?
 if you do not free the memory, you will run out of the memory.

  Suppose i have a linked list of 1000 nodes and i make the head of it =
  NULL, thus losing the whole list. Then compiler can look at other variables
  and if this list has not been referenced anywhere else then it is useless,
  thus will free the memory.
  Is the argument wrong ?


  On Fri, Nov 11, 2011 at 8:20 PM, vikas vikas.rastogi2...@gmail.comwrote:

  nopes , they are not connected, it is just a chance you are getting
  the same values and nothing is overwritten there: basically these are
  DANGLING POINTERS . Now you should keep practising something like this

  #define FREE(N) { free(N); N=NULL;}

  to avoid such mistakes

  On Nov 11, 3:41 pm, shady sinv...@gmail.com wrote:
   typedef struct n{
           int num;
           struct n *next;

   }node;

   node is the structure to create the linked list.

   node *list1;

   I have created a linked list ( list1 )like this 1 - 2 - 3 - 4

   so i free it like this 

   free(list1 - next - next -next);
   free(list1 - next - next);
   free(list1 - next);
   free(list1);

   when i am printing the list after each free, it is always printing a
   list of length 4, isn't the values free'd when we do free() ?

   actual printing gives
   1 2 3 0
   1 2 garbage 0
   1 garbage garbage 0
   garbage garbage garbage 0

   why is the linked list still connected ?

   actual print function -
   void print(node *l)
   {
        while(l != NULL)
       {
           printf(%d\t,l-num);
           l = l-next;
       }
       printf(\n);

   }

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

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

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



Re: [algogeeks] Re: an os question

2011-11-13 Thread Debabrata Das
take online  process dump and analyze, would be good if you retain the
symbol table in the binary..

On Sun, Nov 13, 2011 at 7:55 PM, vikas vikas.rastogi2...@gmail.com wrote:
 that is normal in embedded systems, what you should do is , put the
 logs in the particular module, which can be enabled by choice. Another
 option is to store the stack traces. using such techniques , you will
 be able to find the problem, at least you will be able to reach near
 to it.

 On Nov 13, 2:58 pm, Anika Jain anika.jai...@gmail.com wrote:
 You have written some code/program and delivered it to d customer. Now u
 dont have the source code with u. The program is not working fine at the
 customer's place. How will u catch the bug?(remember u dont have the source
 code wid u).

 This is an OS question. I dont know the answer. It was asked in an
 interview.

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



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



Re: [algogeeks] Re: error in c++ program

2011-09-23 Thread Debabrata Das
prefix class as class time a,b,c,d;  worked for me.

On Fri, Sep 23, 2011 at 12:09 AM, Rajesh Kumar testalgori...@gmail.com wrote:
 thanx Rahul

 On Thu, Sep 22, 2011 at 11:54 PM, abhinav gupta abhinav@gmail.com
 wrote:

 @rahul
 +1

 On Thu, Sep 22, 2011 at 11:20 PM, rahul vatsa vatsa.ra...@gmail.com
 wrote:

 time is a keyword in c/cpp, change time to any other string in ur code nd
 it will work.


 On Thu, Sep 22, 2011 at 12:27 PM, Rajesh Kumar testalgori...@gmail.com
 wrote:

 not working by changes provide by you

 On Thu, Sep 22, 2011 at 9:42 PM, payal gupta gpt.pa...@gmail.com
 wrote:

 #includeiostream.h
 class time
 {
 int m;
 int h;
 public:
 void set(int,int);
 void sum(time,time,time);
 void display();
 };
 void time::set(int x,int y)
 {
 m=x;
 h=y;
 }
 void time::sum(time t1,time t2,time t3)
 {
 m=t1.m+t2.m+t3.m;
 h=t1.h+t2.h+t3.h;
 }
 void time::display(void)
 {
 coutminute==mendl;
 couthours==hendl;
 }
 int main()
 {
 time a,b,c,d;
 a.set(1,2);
 b.set(2,4);
 c.set(4,8);
 d.sum(a,b,c);
 //display
 a.display();
 b.display();
 c.display();
 d.display();
 return 0;
 }



 dis does works...chk it  out!!!

 Regards,
 PAYAL GUPTA,
 CSE-3rd yr,
 NIT_B
 On Thu, Sep 22, 2011 at 9:28 PM, Don dondod...@gmail.com wrote:

 Give us some help. What is the error? Syntax error? Logic error?
 Runtime error?

 On Sep 22, 10:47 am, Rajesh Kumar testalgori...@gmail.com wrote:
  how we can remove error ?
  #includeiostream
  using namespace std;
  class time
  {
  int m;
  int h;
  public:
  void set(int,int);
  void sum(time,time,time);
  void display();};
 
  void time::set(int x,int y)
  {
  m=x;
  h=y;}
 
  void time::sum(time t1,time t2,time t3)
  {
  m=t1.m+t2.m+t3.m;
  h=t1.h+t2.h+t3.h;}
 
  void time::display(void)
  {
  coutminute==mendl;
  couthours==hendl;}
 
  int main()
  {
  time a,b,c,d;
  a.set(1,2);
  b.set(2,4);
  c.set(4,8);
  d.sum(a,b,c);
  //display
  a.display();
  b.display();
  c.display();
  d.display();
 
  }
 
  Regards
  Rajesh Kumar

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


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



 --
 Regards
 Rajesh Kumar

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

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

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

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


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



Re: [algogeeks] Padding....

2011-09-04 Thread Debabrata Das
@Dheeraj, Thanks for the link
@Anshul
Considering double to be alligned as a 4 byte boundary..
structc_tag

c 1 byte
padding 1 byte
padding 1 byte
padding 1 byte
double 8 byte
int4 byte

whole structure is multiple of 4 so no padding required.

structd_tag

8 byte for double
4 byte for int
1 byte for char
 padding 3 byte

last 3 byte padding for structure size to be multiple of 4

Correct me if am wrong

On Sun, Sep 4, 2011 at 2:40 AM, Anshul AGARWAL
anshul.agarwa...@gmail.com wrote:
 #include stdio.h

 // structure C
 typedef struct structc_tag
 {
    char        c;
    double      d;
    int     s;
 } structc_t;

 // structure D
 typedef struct structd_tag
 {
    double      d;
    int     s;
    char        c;
 } structd_t;

 int main()
 {


    printf(sizeof(structc_t) = %d\n, sizeof(structc_t));
    printf(sizeof(structd_t) = %d\n, sizeof(structd_t));

    return 0;
 }
 plz explain the output ??

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


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

2011-09-03 Thread Debabrata Das
how  output is 12 on typical 32 bit system and why?
#includestdio.h
struct x
{
int y;
char x;
float z;
};
main()
{
printf(%d,sizeof(struct x));
}

what is the rule of padding

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

2011-09-03 Thread Debabrata Das
there is chance of buffer overflow as it doesn't check if the input
size if it's greater then input size

On Sun, Sep 4, 2011 at 12:26 AM, harshit sethi hshoneyma...@gmail.com wrote:
 gets() is normally used to input string consisting of multiple words.
 This is  not possible using  single scanf()

 On 9/4/11, sukran dhawan sukrandha...@gmail.com wrote:
 +1

 On Sun, Sep 4, 2011 at 12:07 AM, Shashank Jain shashan...@gmail.com wrote:


 Shashank Jain
 IIIrd 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.



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



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

2011-08-28 Thread Debabrata Das
Another approach!!

while(x)
{
x=x(x-1);
count++;
}

On Sun, Aug 28, 2011 at 2:26 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote:

 Here is a small piece of program which counts the number of bits set in a
 number. I found it online somewhere.
 InputOutput00(000)52(101)73(111)

   *int* CountBits (*unsigned* *int* x )

   {
   *static* *unsigned* *int* mask[] *=* { 0x,

   0x,
   0x0F0F0F0F,
   0x00FF00FF,

   0x  } ;
   *int* i ;
   *int* shift ; /* Number of positions to shift to right*/  
 *for* ( i *=*0, shift *=*1; i ** 5; i *++*, shift **=* 2)

   x *=* (x ** mask[i ])*+* ( ( x ** shift) ** mask[i]);

   *return* x;
   }

 Can anyone explain how this is working?

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



Re: [algogeeks] Re: large nos

2011-08-24 Thread Debabrata Das
well if you store value in link list as a polynomial  the you can do
multiplication as cross product.
eg. 345=3*100 + 4*10 + 5*1

On Wed, Aug 24, 2011 at 11:53 PM, Don dondod...@gmail.com wrote:
 Use NTL.
 Don

 On Aug 24, 12:43 pm, MAC macatad...@gmail.com wrote:
 any thoughts ? if we have link lists to represent very large integer numbers
 how to implement multiply and devide operator
 --
 thanks
 --mac

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



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



Re: [algogeeks] MICROSOFT INTERVIEW QUESTIONS faced by my frenz nd me

2011-08-08 Thread Debabrata Das
@suresh, me too , did you got any calls from MS regd the test result?

On Mon, Aug 8, 2011 at 10:14 AM, siddharam suresh
siddharam@gmail.com wrote:
 y'day i have attended the MS test. Following are the questions.
 1)there are two arrays a={1,2,3} b={4,5,6,7,0,0,0}, b has enough  space
 to accommodate the elements of a[]  that is trailing 0's in b. o/p should be
 sorted array containing both the elements of a[] n b[] in above   example
 b={1,2,3,4,5,6,7}
 2) write the test case for above algo
 3) read a file, tell how many time the words in the file repeated(count) and
 line number
 o/p
 word\tcount of the word in the file\tline number
 4)another questions on design of system. i didn't that question at all.
 Thank you,
 Siddharam


 On Mon, Aug 8, 2011 at 12:38 AM, coder dumca coder.du...@gmail.com wrote:

 oh soory

 On Sun, Aug 7, 2011 at 12:02 PM, Neha Sharan neharick...@gmail.com
 wrote:

 @coder: it is not bst.

 On Mon, Aug 8, 2011 at 12:15 AM, coder dumca coder.du...@gmail.com
 wrote:

 inoeder traversal is given 1 2 3 4 5 6 7 8 9
 in preorder traversal  root come fist , then left and then right.
 see the option
   a.    1 6 3 2 7 8 4 9

 1 is root at left there is 6 , sine  left child must be smaller than
 root

 in this way none of options are satisfying this
    b.    6 7 3 8 1 9 2 7   6  is roor but 7 is greater
    c,    2 4 6 8 1 3 5 7
    d.    1 3 5 7 2 4 6 8

 i think the is some fault in the question it should  post order to find
 On Sun, Aug 7, 2011 at 11:38 AM, ankit sambyal ankitsamb...@gmail.com
 wrote:

 @coder : Cud u plz explain the approach for question 9 ??

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

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

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

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

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


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

2011-08-08 Thread Debabrata Das
ok deletion is possible for the current pointer in a singly linked list.
just keep on copying the next node to the current node untill you
reach last node and delete the last  node
No idea abt insertion,let me check

On Mon, Aug 8, 2011 at 9:40 PM, pankaj kumar pancsen...@gmail.com wrote:
 if doubly link list then it is possible to insert a new node before the
 current 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.


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



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread Debabrata Das
i think 3

On Mon, Aug 8, 2011 at 10:32 PM, rajul jain rajuljain...@gmail.com wrote:
 got it thanks

 On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee akash...@gmail.com wrote:

 i think its 1 though ...

 On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com wrote:

 What will the following code snippet do, when is it passed the root of
 a binary tree ?
 func( Node *node){

  if(node-right != NULL)

       func( node-right);

  if(node-left != NULL)

        func( node-left);

  if( node-left == NULL  node-right == NULL )

     delete(node);

 }

 Pick choice
 Delete the tree from bottom to top

 Delete the tree from top to bottom

 Delete the leaf nodes from right to left

 Delete the leaf nodes from left to right

 I think it is 3

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


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

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


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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-08-08 Thread Debabrata Das
this is a case of heap corruption

On Mon, Aug 8, 2011 at 10:40 PM, Mohit Goel mohitgoel291...@gmail.com wrote:
 #includestdio.h
 #includeconio.h
 struct abc
 {
    char p[1];
 };
 int main()
 {
     struct abc *c =NULL;
  char name[]=abcde;
  c = (struct abc *) malloc (sizeof(struct abc));

  strcpy(c-p,name);
  printf(%s,c-p);
  getch();
  return 0;
 }
 why it is printing the whole string abcde..there is not enough memory
 in array 'p'...

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


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



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread Debabrata Das
check this condition
if( node-left == NULL  node-right == NULL )
it is true only for leaves node

On Mon, Aug 8, 2011 at 10:46 PM, rajul jain rajuljain...@gmail.com wrote:
 I have also made same answer on first look but read 3rd  option correctly it
 say deletion of leaves from right to left not internal nodes.

 On Mon, Aug 8, 2011 at 10:36 PM, Debabrata Das
 debabrata.barunhal...@gmail.com wrote:

 i think 3

 On Mon, Aug 8, 2011 at 10:32 PM, rajul jain rajuljain...@gmail.com
 wrote:
  got it thanks
 
  On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee akash...@gmail.com
  wrote:
 
  i think its 1 though ...
 
  On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com wrote:
 
  What will the following code snippet do, when is it passed the root of
  a binary tree ?
  func( Node *node){
 
   if(node-right != NULL)
 
        func( node-right);
 
   if(node-left != NULL)
 
         func( node-left);
 
   if( node-left == NULL  node-right == NULL )
 
      delete(node);
 
  }
 
  Pick choice
  Delete the tree from bottom to top
 
  Delete the tree from top to bottom
 
  Delete the leaf nodes from right to left
 
  Delete the leaf nodes from left to right
 
  I think it is 3
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 

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


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


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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-08-08 Thread Debabrata Das
when you do maloc or new , space is allocated from heap segment of
your process address space.
Though you have alllocated (sizeof(struct abc) space but strcpy copies
abcde beyond your allocated space and overwrite the contents, we
should avoid this scenario and use strncpy so that it cannot go beyond
alloacted space.. you never know if some one using the buffer beyond
p.



On Mon, Aug 8, 2011 at 10:48 PM, Mohit Goel mohitgoel291...@gmail.com wrote:

 @debabratas:   can u plz explain  this term ..heap corruption ..

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


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



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread Debabrata Das
@aditi , yes you r right... i missed out delete(node) would make parent as leaf

On Mon, Aug 8, 2011 at 11:03 PM, rajul jain rajuljain...@gmail.com wrote:
 This is what i am trying to say to debabrata

 On Mon, Aug 8, 2011 at 10:56 PM, aditi garg aditi.garg.6...@gmail.com
 wrote:

 @debrata : bt remember its a recursive function...once the leaf node gets
 deleted thn it will move bak to the node and thn to the left of it
 fr eg
           a
        /    \
       b     c
     /  \    /  \
    d   e  f   g
 frst g will be deleted...then f thn it wil delete c and so on...i think
 the ans shud be 1...correct me if i am wrong...
 On Mon, Aug 8, 2011 at 10:49 PM, Debabrata Das
 debabrata.barunhal...@gmail.com wrote:

 check this condition
 if( node-left == NULL  node-right == NULL )
 it is true only for leaves node

 On Mon, Aug 8, 2011 at 10:46 PM, rajul jain rajuljain...@gmail.com
 wrote:
  I have also made same answer on first look but read 3rd  option
  correctly it
  say deletion of leaves from right to left not internal nodes.
 
  On Mon, Aug 8, 2011 at 10:36 PM, Debabrata Das
  debabrata.barunhal...@gmail.com wrote:
 
  i think 3
 
  On Mon, Aug 8, 2011 at 10:32 PM, rajul jain rajuljain...@gmail.com
  wrote:
   got it thanks
  
   On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee
   akash...@gmail.com
   wrote:
  
   i think its 1 though ...
  
   On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com
   wrote:
  
   What will the following code snippet do, when is it passed the
   root of
   a binary tree ?
   func( Node *node){
  
    if(node-right != NULL)
  
         func( node-right);
  
    if(node-left != NULL)
  
          func( node-left);
  
    if( node-left == NULL  node-right == NULL )
  
       delete(node);
  
   }
  
   Pick choice
   Delete the tree from bottom to top
  
   Delete the tree from top to bottom
  
   Delete the leaf nodes from right to left
  
   Delete the leaf nodes from left to right
  
   I think it is 3
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 

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




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

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

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

Re: [algogeeks] max product!

2011-08-07 Thread Debabrata Das
why do you need three smallest number, two would suffice ?

On Sun, Aug 7, 2011 at 7:47 PM, Amol Sharma amolsharm...@gmail.com wrote:

 yes...it should work !!
 --


 Amol Sharma
 Third Year Student
 Computer Science and Engineering
 MNNIT Allahabad




 On Sun, Aug 7, 2011 at 7:13 PM, Prakash D cegprak...@gmail.com wrote:

 1


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


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



Re: [algogeeks] xplanation plz

2011-08-06 Thread Debabrata Das
try this:
const int a=54;
int *p=(int *)a;
*p=100;
printf(%d\n,*p);
printf(%x %x,p,a);



On Sun, Aug 7, 2011 at 12:28 AM, UTKARSH SRIVASTAV
usrivastav...@gmail.com wrote:
 yes saurabh the value of a has not changed

 On Sat, Aug 6, 2011 at 11:20 AM, aditi garg aditi.garg.6...@gmail.com
 wrote:

 @saurabh
 http://ideone.com/J0gNi
 its jst pointing to same address bt it has not modified the value...chk
 the abv link...
 On Sat, Aug 6, 2011 at 8:13 PM, saurabh singh saurab...@gmail.com wrote:

 http://ideone.com/Wszkg
 On Sat, Aug 6, 2011 at 8:03 PM, jagrati verma
 jagrativermamn...@gmail.com wrote:

 how can modify constant variable with the help of pointers.

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



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

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



 --
 UTKARSH SRIVASTAV
 CSE-3
 B-Tech 3rd Year
 @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.