Help with recursion and pointers building doubly linked list from a binary tree. 
Author Message
 Help with recursion and pointers building doubly linked list from a binary tree.

I am trying to build a doubly linked list from a binary tree to
eventually solve a numerical expression.  I don't understand why the
addresses don't pass from recursive call to recursive call.  The ouput
for my code looks like this:

        Please enter a numerical expression to be evaluated :
        To enter expression use spaces between (,),+.-,/,*  :
        5 + 7
        call build with ptr lft , ptr oper is +
        adress of stack ptr before function call 2ff7fc2c
        putting value into node, value is, 5.000000
        address of stackptr 2ff7fbbc
        address of new ptr, next, 2ff7fb6c
        call with right, ptr oper is +
        adress of stack ptr before function call 2ff7fc2c
        putting value into node, value is, 7.000000
        address of stackptr 2ff7fbbc
        address of new ptr, next, 2ff7fb6c
        putting oper into node, ptr value is +

The function I am using to create this output is as follows.

struct stackset *buildlinkstack(struct node *ptr, struct stackset
*stackptr)
{

   struct stackset *tempstackptr, *newstackptr;

   if ((ptr -> left) != NULL)
      {
         printf("call build with ptr lft , ptr oper is %c\n", ptr ->
operator);
         printf("adress of stack ptr before function call %p\n",
&stackptr);
         buildlinkstack(ptr -> left, stackptr);
         printf("call with right, ptr oper is %c\n",ptr -> operator);
         printf("adress of stack ptr before function call %p\n",
&stackptr);
         buildlinkstack(ptr -> right, stackptr);
         printf("putting oper into node, ptr value is %c\n", ptr ->
operator);
         tempstackptr = stackptr;
         stackptr -> value = ptr -> value;
         stackptr -> operator = ptr -> operator;
         stackptr -> next = (struct stackset *)malloc(sizeof(struct
stackset));
         newstackptr = stackptr -> next;
         newstackptr -> previous = tempstackptr;
         newstackptr -> next = NULL;
         return newstackptr;
      }
         else
      {
         printf("putting value into node, value is, %f \n", ptr ->
value);
         tempstackptr = stackptr;
         stackptr -> value = ptr -> value;
         stackptr -> operator = ptr -> operator;
         stackptr  -> next = (struct stackset *)malloc(sizeof(struct
stackset));
         printf("address of stackptr %p\n", &stackptr);
         newstackptr = stackptr -> next;
         newstackptr -> previous = tempstackptr;
         newstackptr -> next  = NULL;
         printf("address of new ptr, next, %p\n", &newstackptr);
         return newstackptr;
      }

Quote:
}

The call I am making to the function is as follows.

  begstackptr = (struct stackset *)malloc(sizeof(struct stackset));
         begstackptr -> next = NULL;
         begstackptr -> previous = NULL;
         begstackptr -> value = 0;
         begstackptr -> operator = 'n';
         stackptr = buildlinkstack(ptr, begstackptr);

Please respond if you have a suggestion to why the addresses are not
being passed to the various calls. My email address is

understand the way variable are passed function to function.  I thought
that if an address was passed changes would be reflected in the
location that they were coming from.



Sat, 18 Jan 1997 10:04:34 GMT  
 Help with recursion and pointers building doubly linked list from a binary tree.
I am trying to build a doubly linked list from a binary tree to
eventually solve a numerical expression.  I don't understand why the
addresses don't pass from recursive call to recursive call.  The ouput
for my code looks like this:

        Please enter a numerical expression to be evaluated :
        To enter expression use spaces between (,),+.-,/,*  :
        5 + 7
        call build with ptr lft , ptr oper is +
        adress of stack ptr before function call 2ff7fc2c
        putting value into node, value is, 5.000000
        address of stackptr 2ff7fbbc
        address of new ptr, next, 2ff7fb6c
        call with right, ptr oper is +
        adress of stack ptr before function call 2ff7fc2c
        putting value into node, value is, 7.000000
        address of stackptr 2ff7fbbc
        address of new ptr, next, 2ff7fb6c
        putting oper into node, ptr value is +

The function I am using to create this output is as follows.

struct stackset *buildlinkstack(struct node *ptr, struct stackset
*stackptr)
{

   struct stackset *tempstackptr, *newstackptr;

   if ((ptr -> left) != NULL)
      {
         printf("call build with ptr lft , ptr oper is %c\n", ptr ->
operator);
         printf("adress of stack ptr before function call %p\n",
&stackptr);
         buildlinkstack(ptr -> left, stackptr);
         printf("call with right, ptr oper is %c\n",ptr -> operator);
         printf("adress of stack ptr before function call %p\n",
&stackptr);
         buildlinkstack(ptr -> right, stackptr);
         printf("putting oper into node, ptr value is %c\n", ptr ->
operator);
         tempstackptr = stackptr;
         stackptr -> value = ptr -> value;
         stackptr -> operator = ptr -> operator;
         stackptr -> next = (struct stackset *)malloc(sizeof(struct
stackset));
         newstackptr = stackptr -> next;
         newstackptr -> previous = tempstackptr;
         newstackptr -> next = NULL;
         return newstackptr;
      }
         else
      {
         printf("putting value into node, value is, %f \n", ptr ->
value);
         tempstackptr = stackptr;
         stackptr -> value = ptr -> value;
         stackptr -> operator = ptr -> operator;
         stackptr  -> next = (struct stackset *)malloc(sizeof(struct
stackset));
         printf("address of stackptr %p\n", &stackptr);
         newstackptr = stackptr -> next;
         newstackptr -> previous = tempstackptr;
         newstackptr -> next  = NULL;
         printf("address of new ptr, next, %p\n", &newstackptr);
         return newstackptr;
      }

Quote:
}

The call I am making to the function is as follows.

  begstackptr = (struct stackset *)malloc(sizeof(struct stackset));
         begstackptr -> next = NULL;
         begstackptr -> previous = NULL;
         begstackptr -> value = 0;
         begstackptr -> operator = 'n';
         stackptr = buildlinkstack(ptr, begstackptr);

Please respond if you have a suggestion to why the addresses are not
being passed to the various calls. My email address is

understand the way variable are passed function to function.  I thought
that if an address was passed changes would be reflected in the
location that they were coming from.



Sat, 18 Jan 1997 07:49:46 GMT  
 Help with recursion and pointers building doubly linked list from a binary tree.
I am trying to build a doubly linked list from a binary tree to
eventually solve a numerical expression.  I don't understand why the
addresses don't pass from recursive call to recursive call.  The ouput
for my code looks like this:

        Please enter a numerical expression to be evaluated :
        To enter expression use spaces between (,),+.-,/,*  :
        5 + 7
        call build with ptr lft , ptr oper is +
        adress of stack ptr before function call 2ff7fc2c
        putting value into node, value is, 5.000000
        address of stackptr 2ff7fbbc
        address of new ptr, next, 2ff7fb6c
        call with right, ptr oper is +
        adress of stack ptr before function call 2ff7fc2c
        putting value into node, value is, 7.000000
        address of stackptr 2ff7fbbc
        address of new ptr, next, 2ff7fb6c
        putting oper into node, ptr value is +

The function I am using to create this output is as follows.

struct stackset *buildlinkstack(struct node *ptr, struct stackset
*stackptr)
{

   struct stackset *tempstackptr, *newstackptr;

   if ((ptr -> left) != NULL)
      {
         printf("call build with ptr lft , ptr oper is %c\n", ptr ->
operator);
         printf("adress of stack ptr before function call %p\n",
&stackptr);
         buildlinkstack(ptr -> left, stackptr);
         printf("call with right, ptr oper is %c\n",ptr -> operator);
         printf("adress of stack ptr before function call %p\n",
&stackptr);
         buildlinkstack(ptr -> right, stackptr);
         printf("putting oper into node, ptr value is %c\n", ptr ->
operator);
         tempstackptr = stackptr;
         stackptr -> value = ptr -> value;
         stackptr -> operator = ptr -> operator;
         stackptr -> next = (struct stackset *)malloc(sizeof(struct
stackset));
         newstackptr = stackptr -> next;
         newstackptr -> previous = tempstackptr;
         newstackptr -> next = NULL;
         return newstackptr;
      }
         else
      {
         printf("putting value into node, value is, %f \n", ptr ->
value);
         tempstackptr = stackptr;
         stackptr -> value = ptr -> value;
         stackptr -> operator = ptr -> operator;
         stackptr  -> next = (struct stackset *)malloc(sizeof(struct
stackset));
         printf("address of stackptr %p\n", &stackptr);
         newstackptr = stackptr -> next;
         newstackptr -> previous = tempstackptr;
         newstackptr -> next  = NULL;
         printf("address of new ptr, next, %p\n", &newstackptr);
         return newstackptr;
      }

Quote:
}

The call I am making to the function is as follows.

  begstackptr = (struct stackset *)malloc(sizeof(struct stackset));
         begstackptr -> next = NULL;
         begstackptr -> previous = NULL;
         begstackptr -> value = 0;
         begstackptr -> operator = 'n';
         stackptr = buildlinkstack(ptr, begstackptr);

Please respond if you have a suggestion to why the addresses are not
being passed to the various calls. My email address is

understand the way variable are passed function to function.  I thought
that if an address was passed changes would be reflected in the
location that they were coming from.



Sat, 18 Jan 1997 11:46:54 GMT  
 Help with recursion and pointers building doubly linked list from a binary tree.
I am trying to build a doubly linked list from a binary tree to
eventually solve a numerical expression.  I don't understand why the
addresses don't pass from recursive call to recursive call.  The ouput
for my code looks like this:

        Please enter a numerical expression to be evaluated :
        To enter expression use spaces between (,),+.-,/,*  :
        5 + 7
        call build with ptr lft , ptr oper is +
        adress of stack ptr before function call 2ff7fc2c
        putting value into node, value is, 5.000000
        address of stackptr 2ff7fbbc
        address of new ptr, next, 2ff7fb6c
        call with right, ptr oper is +
        adress of stack ptr before function call 2ff7fc2c
        putting value into node, value is, 7.000000
        address of stackptr 2ff7fbbc
        address of new ptr, next, 2ff7fb6c
        putting oper into node, ptr value is +

The function I am using to create this output is as follows.

struct stackset *buildlinkstack(struct node *ptr, struct stackset
*stackptr)
{

   struct stackset *tempstackptr, *newstackptr;

   if ((ptr -> left) != NULL)
      {
         printf("call build with ptr lft , ptr oper is %c\n", ptr ->
operator);
         printf("adress of stack ptr before function call %p\n",
&stackptr);
         buildlinkstack(ptr -> left, stackptr);
         printf("call with right, ptr oper is %c\n",ptr -> operator);
         printf("adress of stack ptr before function call %p\n",
&stackptr);
         buildlinkstack(ptr -> right, stackptr);
         printf("putting oper into node, ptr value is %c\n", ptr ->
operator);
         tempstackptr = stackptr;
         stackptr -> value = ptr -> value;
         stackptr -> operator = ptr -> operator;
         stackptr -> next = (struct stackset *)malloc(sizeof(struct
stackset));
         newstackptr = stackptr -> next;
         newstackptr -> previous = tempstackptr;
         newstackptr -> next = NULL;
         return newstackptr;
      }
         else
      {
         printf("putting value into node, value is, %f \n", ptr ->
value);
         tempstackptr = stackptr;
         stackptr -> value = ptr -> value;
         stackptr -> operator = ptr -> operator;
         stackptr  -> next = (struct stackset *)malloc(sizeof(struct
stackset));
         printf("address of stackptr %p\n", &stackptr);
         newstackptr = stackptr -> next;
         newstackptr -> previous = tempstackptr;
         newstackptr -> next  = NULL;
         printf("address of new ptr, next, %p\n", &newstackptr);
         return newstackptr;
      }

Quote:
}

The call I am making to the function is as follows.

  begstackptr = (struct stackset *)malloc(sizeof(struct stackset));
         begstackptr -> next = NULL;
         begstackptr -> previous = NULL;
         begstackptr -> value = 0;
         begstackptr -> operator = 'n';
         stackptr = buildlinkstack(ptr, begstackptr);

Please respond if you have a suggestion to why the addresses are not
being passed to the various calls. My email address is

understand the way variable are passed function to function.  I thought
that if an address was passed changes would be reflected in the
location that they were coming from.



Sat, 18 Jan 1997 22:39:33 GMT  
 Help with recursion and pointers building doubly linked list from a binary tree.
I am trying to build a doubly linked list from a binary tree to
eventually solve a numerical expression.  I don't understand why the
addresses don't pass from recursive call to recursive call.  The ouput
for my code looks like this:

        Please enter a numerical expression to be evaluated :
        To enter expression use spaces between (,),+.-,/,*  :
        5 + 7
        call build with ptr lft , ptr oper is +
        adress of stack ptr before function call 2ff7fc2c
        putting value into node, value is, 5.000000
        address of stackptr 2ff7fbbc
        address of new ptr, next, 2ff7fb6c
        call with right, ptr oper is +
        adress of stack ptr before function call 2ff7fc2c
        putting value into node, value is, 7.000000
        address of stackptr 2ff7fbbc
        address of new ptr, next, 2ff7fb6c
        putting oper into node, ptr value is +

The function I am using to create this output is as follows.

struct stackset *buildlinkstack(struct node *ptr, struct stackset
*stackptr)
{

   struct stackset *tempstackptr, *newstackptr;

   if ((ptr -> left) != NULL)
      {
         printf("call build with ptr lft , ptr oper is %c\n", ptr ->
operator);
         printf("adress of stack ptr before function call %p\n",
&stackptr);
         buildlinkstack(ptr -> left, stackptr);
         printf("call with right, ptr oper is %c\n",ptr -> operator);
         printf("adress of stack ptr before function call %p\n",
&stackptr);
         buildlinkstack(ptr -> right, stackptr);
         printf("putting oper into node, ptr value is %c\n", ptr ->
operator);
         tempstackptr = stackptr;
         stackptr -> value = ptr -> value;
         stackptr -> operator = ptr -> operator;
         stackptr -> next = (struct stackset *)malloc(sizeof(struct
stackset));
         newstackptr = stackptr -> next;
         newstackptr -> previous = tempstackptr;
         newstackptr -> next = NULL;
         return newstackptr;
      }
         else
      {
         printf("putting value into node, value is, %f \n", ptr ->
value);
         tempstackptr = stackptr;
         stackptr -> value = ptr -> value;
         stackptr -> operator = ptr -> operator;
         stackptr  -> next = (struct stackset *)malloc(sizeof(struct
stackset));
         printf("address of stackptr %p\n", &stackptr);
         newstackptr = stackptr -> next;
         newstackptr -> previous = tempstackptr;
         newstackptr -> next  = NULL;
         printf("address of new ptr, next, %p\n", &newstackptr);
         return newstackptr;
      }

Quote:
}

The call I am making to the function is as follows.

  begstackptr = (struct stackset *)malloc(sizeof(struct stackset));
         begstackptr -> next = NULL;
         begstackptr -> previous = NULL;
         begstackptr -> value = 0;
         begstackptr -> operator = 'n';
         stackptr = buildlinkstack(ptr, begstackptr);

Please respond if you have a suggestion to why the addresses are not
being passed to the various calls. My email address is

understand the way variable are passed function to function.  I thought
that if an address was passed changes would be reflected in the
location that they were coming from.



Sat, 18 Jan 1997 22:41:31 GMT  
 Help with recursion and pointers building doubly linked list from a binary tree.
I am trying to build a doubly linked list from a binary tree to
eventually solve a numerical expression.  I don't understand why the
addresses don't pass from recursive call to recursive call.  The ouput
for my code looks like this:

        Please enter a numerical expression to be evaluated :
        To enter expression use spaces between (,),+.-,/,*  :
        5 + 7
        call build with ptr lft , ptr oper is +
        adress of stack ptr before function call 2ff7fc2c
        putting value into node, value is, 5.000000
        address of stackptr 2ff7fbbc
        address of new ptr, next, 2ff7fb6c
        call with right, ptr oper is +
        adress of stack ptr before function call 2ff7fc2c
        putting value into node, value is, 7.000000
        address of stackptr 2ff7fbbc
        address of new ptr, next, 2ff7fb6c
        putting oper into node, ptr value is +

The function I am using to create this output is as follows.

struct stackset *buildlinkstack(struct node *ptr, struct stackset
*stackptr)
{

   struct stackset *tempstackptr, *newstackptr;

   if ((ptr -> left) != NULL)
      {
         printf("call build with ptr lft , ptr oper is %c\n", ptr ->
operator);
         printf("adress of stack ptr before function call %p\n",
&stackptr);
         buildlinkstack(ptr -> left, stackptr);
         printf("call with right, ptr oper is %c\n",ptr -> operator);
         printf("adress of stack ptr before function call %p\n",
&stackptr);
         buildlinkstack(ptr -> right, stackptr);
         printf("putting oper into node, ptr value is %c\n", ptr ->
operator);
         tempstackptr = stackptr;
         stackptr -> value = ptr -> value;
         stackptr -> operator = ptr -> operator;
         stackptr -> next = (struct stackset *)malloc(sizeof(struct
stackset));
         newstackptr = stackptr -> next;
         newstackptr -> previous = tempstackptr;
         newstackptr -> next = NULL;
         return newstackptr;
      }
         else
      {
         printf("putting value into node, value is, %f \n", ptr ->
value);
         tempstackptr = stackptr;
         stackptr -> value = ptr -> value;
         stackptr -> operator = ptr -> operator;
         stackptr  -> next = (struct stackset *)malloc(sizeof(struct
stackset));
         printf("address of stackptr %p\n", &stackptr);
         newstackptr = stackptr -> next;
         newstackptr -> previous = tempstackptr;
         newstackptr -> next  = NULL;
         printf("address of new ptr, next, %p\n", &newstackptr);
         return newstackptr;
      }

Quote:
}

The call I am making to the function is as follows.

  begstackptr = (struct stackset *)malloc(sizeof(struct stackset));
         begstackptr -> next = NULL;
         begstackptr -> previous = NULL;
         begstackptr -> value = 0;
         begstackptr -> operator = 'n';
         stackptr = buildlinkstack(ptr, begstackptr);

Please respond if you have a suggestion to why the addresses are not
being passed to the various calls. My email address is

understand the way variable are passed function to function.  I thought
that if an address was passed changes would be reflected in the
location that they were coming from.



Sun, 19 Jan 1997 00:44:40 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Doubly Linked Circular Binary Tree...???

2. More on xoring pointers in a doubly linked list

3. Need help with doubly linked lists

4. Please I need some help -- traversing trough a doubly linked list--

5. Help on doubly-link lists on an ADT.....

6. help! doubly linked lists

7. Doubly Linked Lists...HELP PLEASE (sorry if this a repost)

8. HELP: problem with doubly linked list

9. Help wanted for doubly linked lists

10. HELP PLEASE: singly/doubly linked lists

11. help with doubly linked list

12. BINARY TREES VS LINKED LISTS>

 

 
Powered by phpBB® Forum Software