Re: [algogeeks] problem of fork()

2012-05-24 Thread sumit mahamuni
its not about compilers ... its that new kernels kills all the child
processes, if parent gets killed before.. so that is the reason you
are gettin diff reasons

On 5/24/12, himanshu kansal himanshukansal...@gmail.com wrote:
 i know that the program sholud have printed hello word 8 timesbt whn
 i run it, i get diffrnt reslts everytime and on diffrnt compilers...
 please tell the reason

 On Thu, May 24, 2012 at 11:11 AM, rajesh singarapu
 rajesh0...@gmail.comwrote:

 main process have completed till the time all processes processes
 prints Hello World,

 to prevent it, use wait/wait4 family of fucntions.

 ~r

 On Thu, May 24, 2012 at 8:26 AM, Rajesh Kumar testalgori...@gmail.com
 wrote:
  #includestdio.h
  main()
  {
  fork();
  fork();
  fork();
  printf(Hello Word\n);
  }
 
  output ---
  rajeshkumar@rajeshkumar-laptop:~$ ./a.out
  Hello Word
  Hello Word
  Hello Word
  rajeshkumar@rajeshkumarr-laptop:~$ Hello Word
  Hello Word
  Hello Word
  Hello Word
  Hello Word
 
 
  Why it is not printed continously?
 
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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
  Himanshu Kansal
Msc Comp. sc.
 (University of Delhi)

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




-- 
Thanks and Regards,
Sumit Mahamuni.

-- So once you do know what the question actually is, you'll know what the
answer means.
-- Perhaps the most important principal for good algorithm designer is to
refuse to be content. - Aho, Hopcroft and Ullman.
-- I love deadlines. I like the whooshing sound they make as they fly by. -
D. Adams

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

2012-02-06 Thread sumit mahamuni
Hello,

Here you are right about variable p in add function that it retains it's
value even though function loses its scope. And for main function error you
are seeing has nothing to do with how that variable is stored?
It is about the scope of that variable C compiler sees the scope of static
variable p  limited to add function only, so other function can't use it.
And remember error is at compile time not run time so it is related to
compiler not memory. I hope it explains everything.

On Tue, Feb 7, 2012 at 9:43 AM, atul anand atul.87fri...@gmail.com wrote:

 http://www.geeksforgeeks.org/archives/14268


 On Tue, Feb 7, 2012 at 1:06 AM, gmagog...@gmail.com 
 gmagog...@gmail.comwrote:

 I think you are right about p being in BSS segment and it does last even
 the function finishes, however, you may need a pointer to get the data out
 of p. Then you can read the data.

 Correct me if i am wrong


 On Mon, Feb 6, 2012 at 1:04 PM, Ravi Ranjan ravi.cool2...@gmail.comwrote:

 i have a confusion in it

 #include stdio.h
 #include stdlib.h


 void add(int,int);

 int main(int argc, char *argv[])
 {

 add(6,3);
 printf(%d,p);

   system(PAUSE);
   return 0;
 }


 void add(int a, int b)
 {
   static int p;
 p = a+ b;
 }


 here the memory layout says variable p is in BSS segment ... so its an
 independent region from stack frame. when the function looses its scope
 from function defination(add) then still it should be alive... and can be
 recognized/used by other function(main) but it gves an error of unknown
 variable p.  need the correct logic... if i m wrong...

 thanx
 ravi

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


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


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




-- 
Thanks and Regards,
Sumit Mahamuni.

-- Slow code that scales better can be faster than fast code that doesn't
scale!
-- Tough times never lasts, but tough people do.
-- I love deadlines. I like the whooshing sound they make as they fly by. -
D. Adams

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



Re: [algogeeks] Re: Find even length palindrome.

2011-12-28 Thread sumit mahamuni
  // then break out from the entire loop..
  // Also, if u want to find the exact characters u can do so
   by storing
  // pStrt in a variable.. Using the currMax and pStrt you
   can get the
  // exact palindrome..
   }
}
else
   X[pStrt] = 0;
 }
 pRev -- ;
 
   }
 
   On Dec 28, 10:57 am, sumit mahamuni sumit143smail...@gmail.com
   wrote:
 
Here I can think of O( n * log n ). can anyone think of better
 solution??
 
On Tue, Dec 27, 2011 at 11:06 PM, atul007 atul.87fri...@gmail.com
 wrote:
 Given a string of length N, find whether there exits an even
 length
 palindrome substring.
 what would be efficient way of solving this problem.?
 
 --
 You received this message because you are subscribed to the
 Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
 
--
Thanks and Regards,
Sumit Mahamuni.
 
-- Slow code that scales better can be faster than fast code that
 doesn't
scale!
-- Tough times never lasts, but tough people do.
-- I love deadlines. I like the whooshing sound they make as they
 fly by. -
D. Adams

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


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




-- 
Thanks and Regards,
Sumit Mahamuni.

-- Slow code that scales better can be faster than fast code that doesn't
scale!
-- Tough times never lasts, but tough people do.
-- I love deadlines. I like the whooshing sound they make as they fly by. -
D. Adams

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



Re: [algogeeks] Re: Find even length palindrome.

2011-12-28 Thread sumit mahamuni
@Lucifier :

Hey the equation you made is not what as mine :).
here it is..

at each point we are doing comparisons from middle the complexity is O(n)
and we are doing the same for left and right half so the complexity is
2T(n/2). So equation becomes

T(n) = 2T(n/2) + O(n)

according to masters theorem the time complexity is O(n * log n).

On Thu, Dec 29, 2011 at 10:08 AM, Lucifer sourabhd2...@gmail.com wrote:

 @atul
 The example that u have taken, is it correct ?
 I see that in the search string 'abcdtrwdcba' acc to u the even length
 palindrome is abcddcba..

 On Dec 29, 9:23 am, atul anand atul.87fri...@gmail.com wrote:
  @Lucifier :
 
  this is wat i was trying to say :-
 
  string = abcdtrwdcba
 
  find even length substring and hash them , moving from left to right.
 
  hash(abcdtrwdcba) // corner case
  hash(ab)
  hash(abcd)
  hash(abcdtr)
  .
  .
  .
  hash(dcba).
 
  after hashing is done.
 
  again hash moving from right to left.
  hash(abcd) --- hash alreday present so ...even length palindrome exists.
  you need to take care of cases like for ab -hash is present , but is
 part
  of bigger substring (abcd) when moving from right to left. so keep track
 of
  the index.
  here how to keep track:-
 
  when you find hash of (ab) index=i;
  when you find second even palindrome hash(abcd).
 
  if length(abcd)  length(ab);
  {
  temp_index=current_index + lenght(ab);
  if(temp_index== index)
  {
  // we know ab is the  part of bigger string
 abcd.update
  the new even palindrome found.
  }
 
 
 
 
 
 
 
  }

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




-- 
Thanks and Regards,
Sumit Mahamuni.

-- Slow code that scales better can be faster than fast code that doesn't
scale!
-- Tough times never lasts, but tough people do.
-- I love deadlines. I like the whooshing sound they make as they fly by. -
D. Adams

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



Re: [algogeeks] Find even length palindrome.

2011-12-27 Thread sumit mahamuni
Here I can think of O( n * log n ). can anyone think of better solution??

On Tue, Dec 27, 2011 at 11:06 PM, atul007 atul.87fri...@gmail.com wrote:

 Given a string of length N, find whether there exits an even length
 palindrome substring.
 what would be efficient way of solving this problem.?

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




-- 
Thanks and Regards,
Sumit Mahamuni.

-- Slow code that scales better can be faster than fast code that doesn't
scale!
-- Tough times never lasts, but tough people do.
-- I love deadlines. I like the whooshing sound they make as they fly by. -
D. Adams

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Cliched 'k' largest elements in billion numbers: Heaps or median-of-medians?

2011-12-11 Thread sumit mahamuni
hey here how will you find the median over the billions of numbers when all
data doesnt fit at the same time in memory??

On Mon, Dec 12, 2011 at 6:41 AM, bharath sriram bharath.sri...@gmail.comwrote:

 Hey group,

 This is kind of a cliched question but given a file with billion numbers
 and the task is to compute 'k' largest numbers from this file, what
 approach is preferred?
 1) Using heaps
 2) Using Median-of-median algorithm.

 Have read few links which prefer heaps but clearly median of median
 algorithm has a linear time complexity and don't see how its any less if
 not better than using heaps?
 Any thought?

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




-- 
Thanks and Regards,
Sumit Mahamuni.

-- Slow code that scales better can be faster than fast code that doesn't
scale!
-- Tough times never lasts, but tough people do.
-- I love deadlines. I like the whooshing sound they make as they fly by. -
D. Adams

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

2011-11-24 Thread sumit mahamuni
 at
 http://groups.google.com/group/algogeeks?hl=en.
 
  --
  Anup Ghatage
 
   --
  You received this message because you are subscribed to the
 Google
Groups
  Algorithm Geeks group.
  To post to this group, send email to
 algogeeks@googlegroups.com.
  To unsubscribe from 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*
  *The Coder*
 
  *Life is a Game. The more u play, the more u win, the more u
 win , the
  more successfully u play*
 
   --
  You received this message because you are subscribed to the
 Google
Groups
  Algorithm Geeks group.
  To post to this group, send email to
 algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 --
 Aamir Khan | 3rd Year  | Computer Science  Engineering | IIT
 Roorkee
 
--
You received this message because you are subscribed to the Google
 Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.

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


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




 --
 Nitin Garg

 Personality can open doors, but only Character can keep them open

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




-- 
Thanks and Regards,
Sumit Mahamuni.

-- Slow code that scales better can be faster than fast code that doesn't
scale!
-- Tough times never lasts, but tough people do.
-- I love deadlines. I like the whooshing sound they make as they fly by. -
D. Adams

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



[algogeeks] Re: Re-entrant and thread safe

2011-11-17 Thread sumit mahamuni


On Oct 29, 10:44 pm, AMAN AGARWAL mnnit.a...@gmail.com wrote:
 Hi All,

 Please explain the difference between thread safe functions and re-entrant
 functions with example.

Thread safe function is the function if it ensures that it is the only
thread which modifies the shared data structure in thread safe manner
and which ensures the safe execution by multiple threads at the same
time.
And if we talk about the re-entrant code is a piece of code which can
be executed partially by a thread and can be re-executed by the same
thread or simultaneously executed by another thread and still
correctly complete the original execution.

I guess this would help you?



 Regards,
 Aman.

 --
 AMAN AGARWAL
 Success is not final, Failure is not fatal: It is the courage to continue
 that counts!

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

2011-11-17 Thread sumit mahamuni
On Thu, Nov 17, 2011 at 4:05 PM, shady sinv...@gmail.com wrote:

 you can't do binary search with linked lists.

Yes you can do the binary search on the linked list.
But the only difference it makes from the array is that array elements can
be accessed in O(1) time and finding the mid in array is O(1) where it is
not possible with (1) on linked list. Yes you can find mid but that will be
expensive than array.



 On Nov 17, 1:14 pm, Vijay Khandar vijaykhand...@gmail.com wrote:
  Linked lists are not suitable data structures of which one of the
  following problems?
  a) Insertion sort
  b) Binary search
  c) Radix sort
  d) Polynomial manipulation
 
  Plz explain anyone in detail
  Vijay...

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




-- 
Thanks and Regards,
Sumit Mahamuni.

-- Slow code that scales better can be faster than fast code that doesn't
scale!
-- Tough times never lasts, but tough people do.
-- I love deadlines. I like the whooshing sound they make as they fly by. -
D. Adams

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



[algogeeks] Re: heap memory

2011-11-14 Thread sumit mahamuni


On Nov 5, 10:28 pm, himanshu kansal himanshukansal...@gmail.com
wrote:
 can we know the size of heap memory allocated to our program

Hi,
 from my knowledge of OS, when program is loaded in the memory the
heap is not allocated to the process.
as the requests made by the process, the memory will be allocated from
the virtual memory area (VMA) of the process by the kernel. As the
Data and code sections are fixed in the address space of the process
the remaining address space is utilized for the heap and the stack.
the heap of the process is managed by the virtual memory manager.

And the frames for the process (Physical memory) will also be
allocated by the kernel at the run time for the same. Kernel it self
does the virtual to physical and physical to virtual translations
while allocating virtual memory.  Kernel maintains the pools of the
memory, where each pool represents blocks of memory of a certain power
of two in size. If a smaller size is requested than is available, the
smallest available size is selected and it is then broken in two. One
of the resulting halves is selected, and the process repeats (checking
the size again and splitting if needed) until the block is just large
enough. All new blocks that are formed during these splits are added
to their respective memory pools for later use.

 i think sbrk(0) will return the address of end of heap.
 but how to find the start of heap so that we can calculate the size of
 total heap memory allocated to our program

 is there any way possible

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

2011-11-14 Thread sumit mahamuni
Yeah, right. the same algo of binary tree can be used for bst also but
using that is expensive.

On Mon, Nov 14, 2011 at 9:56 PM, AMAN AGARWAL mnnit.a...@gmail.com wrote:

 Hi,

 I think it matters whether its a bst or normal tree. In BST left node is
 smaller and the right node is greater than the root node, but no such
 constraint is applicable for a binary tree.

 Regards,
 Aman.


 On Mon, Nov 14, 2011 at 10:12 AM, sumit mahamuni 
 sumit143smail...@gmail.com wrote:

 Hi,


 On Mon, Nov 14, 2011 at 1:52 AM, AMAN AGARWAL mnnit.a...@gmail.comwrote:


 Hi,

 Please tell me the solution of this question.

 write a program which find LCA of a binary tree. It is not a BST

 Does it matter its a BST or binary tree? the algo will be same for the
 BST or binary tree.



 Regards,
 Aman,

 --
 AMAN AGARWAL
 Success is not final, Failure is not fatal: It is the courage to
 continue that counts!

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




 --
 Thanks and Regards,
 Sumit Mahamuni.

 -- Slow code that scales better can be faster than fast code that
 doesn't scale!
 -- Tough times never lasts, but tough people do.
 -- I love deadlines. I like the whooshing sound they make as they fly
 by. - D. Adams

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




 --
 AMAN AGARWAL
 Success is not final, Failure is not fatal: It is the courage to continue
 that counts!

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




-- 
Thanks and Regards,
Sumit Mahamuni.

-- Slow code that scales better can be faster than fast code that doesn't
scale!
-- Tough times never lasts, but tough people do.
-- I love deadlines. I like the whooshing sound they make as they fly by. -
D. Adams

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



[algogeeks] Re: free() function

2011-11-13 Thread sumit mahamuni


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.



Re: [algogeeks] difference btw int *a[] and int (*a)[]

2011-11-13 Thread sumit mahamuni
hi,
   one is the array of integer pointers and the other is pointer to integer
array.

On Mon, Nov 14, 2011 at 12:11 AM, rj7 r4ra...@gmail.com wrote:

 Could someone pls tell me the difference between  int *a[] and int (*a)
 []

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




-- 
Thanks and Regards,
Sumit Mahamuni.

-- Slow code that scales better can be faster than fast code that doesn't
scale!
-- Tough times never lasts, but tough people do.
-- I love deadlines. I like the whooshing sound they make as they fly by. -
D. Adams

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

2011-11-13 Thread sumit mahamuni
@anup: Dude u missed the second its int (*a)[]
not pointer to function its the pointer to integer array

On Mon, Nov 14, 2011 at 7:00 AM, Anup Ghatage ghat...@gmail.com wrote:

 First is an array of pointers to integers.
 Second is a pointer to a function that returns an integer.

 On Mon, Nov 14, 2011 at 12:11 AM, rj7 r4ra...@gmail.com wrote:

 Could someone pls tell me the difference between  int *a[] and int (*a)
 []

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




 --
 Anup Ghatage

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




-- 
Thanks and Regards,
Sumit Mahamuni.

-- Slow code that scales better can be faster than fast code that doesn't
scale!
-- Tough times never lasts, but tough people do.
-- I love deadlines. I like the whooshing sound they make as they fly by. -
D. Adams

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