|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Hi,
The fuction should work in C. I need to create a struct for tree with pointer to parent only, without pointers to left & right childs. The function got two pointers for two childs and printer the shared parent of them. The function will print the info of the shared parent. I attached a doc file that show what I want, there is two blue childs that the red parent is the one that the function need to print. I alse need to know the struct elements. Sorry for my english. Thanks alot |
| Sponsored Links |
|
|
|
|||||
|
Instead of thinking of this as a Binary Tree, flip the image upside down and think of it as a linked list with multiple roots that eventually merge.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
|
|||
|
Since both children have the same parent (eventually), just compare the parents recursively, like so:
C Code:
Last edited by dargueta; 06-24-2008 at 09:27 PM. Reason: Fixed formatting |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Windows form question (select a value from childform and populate in parent form) | yasinirshad | Visual Basic Programming | 1 | 11-19-2007 12:42 PM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |