Click here to Skip to main content
15,910,886 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Gloabl variabl, reference & pointer. Pin
Masaaki Onishi5-Aug-01 6:27
Masaaki Onishi5-Aug-01 6:27 
GeneralRe: What's the difference? Pin
Joe Woodbury5-Aug-01 9:03
professionalJoe Woodbury5-Aug-01 9:03 
Generallinked list with fast sorting Pin
4-Aug-01 4:17
suss4-Aug-01 4:17 
GeneralRe: linked list with fast sorting Pin
Christian Graus4-Aug-01 11:41
protectorChristian Graus4-Aug-01 11:41 
GeneralRe: linked list with fast sorting Pin
6-Aug-01 0:12
suss6-Aug-01 0:12 
GeneralRe: linked list with fast sorting Pin
Malcolm McMahon6-Aug-01 2:40
Malcolm McMahon6-Aug-01 2:40 
GeneralRe: linked list with fast sorting Pin
6-Aug-01 4:08
suss6-Aug-01 4:08 
GeneralRe: linked list with fast sorting Pin
Malcolm McMahon6-Aug-01 5:09
Malcolm McMahon6-Aug-01 5:09 
The code was a generic example which assumed the key was a text string. If you use another kind of key you need to replace the strcmp with a suitable equivalent comparator (if your records are searchable you obviously do have keys).

If you want several alternate keys you can use the same actual set of nodes to create several trees, each tree has it's own children and root pointers in each node. You only need one set of nodes, but you have several arrangements going at the same time. (Assuming that you search separately for the different keys. If you want to search on a combined key, just combine the comparator).

The trouble with a simple linked list is that you can only walk through it sequentially. You can't, for example, go straight to the middle element for a binary chop.

The binary tree is a binary search, with the same order of search time as a binary chop into a sorted table (order of log(n)).
The only thing is that the tree works efficiently only if it's approximately balanced. That's why it screws up if you put the keys in in sorted order. You wind up adding everything on one branch and it degenerates to a simple list (it still works, but you lose the speed advantage). If the data are random then, on average, the tree will be reasonably balanced. There are algorithms for rebalancing a tree but, believe me, you don't want to know.
GeneralRe: linked list with fast sorting Pin
7-Aug-01 1:09
suss7-Aug-01 1:09 
GeneralThread Client\Serveur Pin
4-Aug-01 4:16
suss4-Aug-01 4:16 
GeneralRe: Thread Client\Serveur Pin
4-Aug-01 4:19
suss4-Aug-01 4:19 
GeneralRe: Thread Client\Serveur Pin
Baafie4-Aug-01 14:29
Baafie4-Aug-01 14:29 
GeneralAutomating Project Creation Pin
Steve Thresher4-Aug-01 1:52
Steve Thresher4-Aug-01 1:52 
GeneralRe: Automating Project Creation Pin
Steve Thresher4-Aug-01 2:45
Steve Thresher4-Aug-01 2:45 
GeneralRe: Automating Project Creation Pin
Steve Thresher4-Aug-01 2:48
Steve Thresher4-Aug-01 2:48 
GeneralScrolling a Bitmap in a CScrollView Pin
baywa4-Aug-01 1:13
baywa4-Aug-01 1:13 
GeneralCRichEditView::Stream() Pin
Frank Deo4-Aug-01 0:20
Frank Deo4-Aug-01 0:20 
GeneralRe: CRichEditView::Stream() Pin
Baafie4-Aug-01 2:59
Baafie4-Aug-01 2:59 
GeneralRe: CRichEditView::Stream() Pin
Frank Deo4-Aug-01 9:55
Frank Deo4-Aug-01 9:55 
GeneralRe: CRichEditView::Stream() Pin
4-Aug-01 12:46
suss4-Aug-01 12:46 
GeneralRe: CRichEditView::Stream() Pin
Frank Deo5-Aug-01 4:20
Frank Deo5-Aug-01 4:20 
Questionhow to Delete a class in visual c++? Pin
nemati3-Aug-01 21:28
nemati3-Aug-01 21:28 
AnswerRe: how to Delete a class in visual c++? Pin
Christian Graus4-Aug-01 2:40
protectorChristian Graus4-Aug-01 2:40 
GeneralRe: how to Delete a class in visual c++? Pin
Reno Tiko4-Aug-01 15:50
Reno Tiko4-Aug-01 15:50 
GeneralRe: how to Delete a class in visual c++? Pin
Christian Graus4-Aug-01 17:33
protectorChristian Graus4-Aug-01 17:33 

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.