Click here to Skip to main content
15,925,444 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: help! Pin
Hamid_RT19-Mar-06 2:46
Hamid_RT19-Mar-06 2:46 
AnswerRe: help! Pin
Robert Palma Jr.19-Mar-06 7:56
Robert Palma Jr.19-Mar-06 7:56 
QuestionWin32 Radio Button problem Pin
amanoullah18-Mar-06 20:54
amanoullah18-Mar-06 20:54 
AnswerRe: Win32 Radio Button problem Pin
Monty218-Mar-06 21:18
Monty218-Mar-06 21:18 
AnswerRe: Win32 Radio Button problem Pin
Jörgen Sigvardsson18-Mar-06 22:23
Jörgen Sigvardsson18-Mar-06 22:23 
AnswerRe: Win32 Radio Button problem Pin
Hamid_RT19-Mar-06 2:28
Hamid_RT19-Mar-06 2:28 
QuestionConvet Binary tree to Circular linked list Pin
Ilamparithi18-Mar-06 20:26
Ilamparithi18-Mar-06 20:26 
AnswerRe: Convet Binary tree to Circular linked list Pin
El Corazon19-Mar-06 8:22
El Corazon19-Mar-06 8:22 
Ilamparithi wrote:
How to convert a Binary tree to Circular linked list?


Why would you want to? homework assignment? or change of design?

Because of that possibility, I won't give you code. Any tree is read very easily. You have a descending key branch and an ascending key branch. A balanced tree has equal descending key branches as ascending key branches, each node is compared high or low to a key search and you follow either branch as appropriate, when you find equal, you stop. A binary tree, like a binary search is a minimal path to solution design, very efficient in search, but very poor design for sequential access. Lists are very poor random search but exceedingly fast in sequential search operations.

To follow a tree in sequential order is easy, you always follow a branch until your reach a bottom leaf and then back track and follow the next.

// psuedo-code this will NOT compile!!
process (node)
{
if (node->left not empty ) process (node->left)
display (node)
if (node->right not empty ) process (node->right)
}

pretty simple, but the stack flow from recursion has severe overhead, especially for large trees. You can change the display node portion to add to a sequential list, and add the necessary passed parameters to do so. But on large trees the overhead of process will be very high. If you notice most of the time is spent calling functions, so the cpu is spending 66% of its time doing nothing but calling code, only 33% processing a node. ouch.

If you have a design that must change from random access priority speed to sequential access priority speed, this is a great one-time tool to rebuild your list. If the list does not need to be ordered, then it doesn't matter what order you process left right and display operations. Circular linked lists are often random order, so I guess it doesn't matter, I highly dislike random order data because of the unpredictability factor. In my business "knowing" that a process will always take n milliseconds is more important than making it fast (though I try to do both in balanced form).

read this: http://en.wikipedia.org/wiki/Tree_search[^]

_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
QuestionGLUI user interface Pin
shanana18-Mar-06 16:44
shanana18-Mar-06 16:44 
Questionsingle line rich text problem Pin
Jim Crafton18-Mar-06 12:35
Jim Crafton18-Mar-06 12:35 
AnswerRe: single line rich text problem Pin
Jörgen Sigvardsson18-Mar-06 13:27
Jörgen Sigvardsson18-Mar-06 13:27 
GeneralRe: single line rich text problem Pin
Jim Crafton18-Mar-06 14:50
Jim Crafton18-Mar-06 14:50 
GeneralRe: single line rich text problem Pin
Jörgen Sigvardsson18-Mar-06 22:22
Jörgen Sigvardsson18-Mar-06 22:22 
GeneralRe: single line rich text problem Pin
Jim Crafton19-Mar-06 4:10
Jim Crafton19-Mar-06 4:10 
QuestionHow to retrieve local IP address Pin
Allad18-Mar-06 11:20
Allad18-Mar-06 11:20 
AnswerRe: How to retrieve local IP address Pin
Jim Crafton18-Mar-06 12:39
Jim Crafton18-Mar-06 12:39 
GeneralRe: How to retrieve local IP address Pin
Allad18-Mar-06 13:15
Allad18-Mar-06 13:15 
GeneralRe: How to retrieve local IP address Pin
Jim Crafton18-Mar-06 14:03
Jim Crafton18-Mar-06 14:03 
AnswerRe: How to retrieve local IP address Pin
Gavin Taylor18-Mar-06 14:47
professionalGavin Taylor18-Mar-06 14:47 
GeneralRe: How to retrieve local IP address Pin
Allad19-Mar-06 9:14
Allad19-Mar-06 9:14 
GeneralRe: How to retrieve local IP address Pin
ThatsAlok19-Mar-06 17:25
ThatsAlok19-Mar-06 17:25 
Questionrichedit.h Pin
Waldermort18-Mar-06 9:32
Waldermort18-Mar-06 9:32 
AnswerRe: richedit.h Pin
karle18-Mar-06 9:59
karle18-Mar-06 9:59 
AnswerRe: richedit.h Pin
Trollslayer18-Mar-06 12:17
mentorTrollslayer18-Mar-06 12:17 
Questionrichedit controls Pin
Waldermort18-Mar-06 6:11
Waldermort18-Mar-06 6:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.