@Utkarsh
In this code I am writing on the source code file at time of execution
Every time the file executes it changes its own source code...However I too
would like to know if we can do that in c ...
On Fri, Nov 11, 2011 at 12:38 PM, UTKARSH SRIVASTAV usrivastav...@gmail.com
wrote:
correct me if I am wrong
#includestdio.h
struct node
{
int data;
struct node *left;
struct node * right;
}*root;
int sum(int s,struct node *p,int ar[],int l)
{
if(p == NULL )
{
return 0;
}
if(p-left == NULL p-right == NULL)
{
if( s - p-data == 0)
well rahul is absolutely correct and here I will want to say that one
should also see behaviour of _exit and exit .. they will also
give different output
On Fri, Nov 11, 2011 at 1:09 PM, rahul vatsa vatsa.ra...@gmail.com wrote:
wen u write something in printf, its 1st stored in the
As far as I understand, your solution will always contain the path that
essentially start from root. But the actual problem states that the path
may not necessarily start from root.
On Fri, Nov 11, 2011 at 1:21 PM, UTKARSH SRIVASTAV
usrivastav...@gmail.comwrote:
correct me if I am wrong
And also your solution prints the root to leaf path that sums up to X. But
the path may not contain root as well as leaf also. May be some
intermediate 4 nodes (from root to leaf path)sums up to X. Your code doesnt
provide the solution for that scenario.
On Fri, Nov 11, 2011 at 2:53 PM, aniket
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 -
for an executable its not possible.
open will return with ETXTBSY error.
OS:ubuntu.
On Fri, Nov 11, 2011 at 1:50 PM, NAMAN KOHLI naman09...@iiitd.ac.in wrote:
@Utkarsh
In this code I am writing on the source code file at time of execution
Every time the file executes it changes its
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
ok, thanks.
why do we need to free 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.
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.
On Fri, Nov 11, 2011 at 8:36 PM, shady sinv...@gmail.com wrote:
ok, thanks.
why do we need to free the memory ?
Suppose i have a linked list of 1000 nodes
I tried to understand the logic of it but could not :(
On Nov 11, 11:17 am, shady sinv...@gmail.com wrote:
no, for eg.
array1 = { 1, 2, 5, 6, 7, 7, 7, 23};
array2 = { 1, 2, 2, 4, 8, 9, 12 };
then for
k = 2, answer = 1
k = 3, answer = 2
k = 4, answer = 2,
k = 6, answer = 4.
anyway
what you didn't understand, logic or question ?
On Fri, Nov 11, 2011 at 10:05 PM, Ankuj Gupta ankuj2...@gmail.com wrote:
I tried to understand the logic of it but could not :(
On Nov 11, 11:17 am, shady sinv...@gmail.com wrote:
no, for eg.
array1 = { 1, 2, 5, 6, 7, 7, 7, 23};
array2 =
FIND_PTH_SMALLEST(A, Astart, Aend, B, Bstart, Bend, p) // Check for
the special case when A and/or B have size one. if Astart ==
Aend AND Bstart == Bend return p == 1 ? min(A[1], B[1]) : max(A[1],
B[1])if Astart == Aend return max(min(A[1], B[Bend]),
B[Bend – 1])
I guess this approach will work..
--
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/-/zeydVF1OqioJ.
To post to this group, send email to
14 matches
Mail list logo