how would i go about sorting multiple items in a binary search tree..
for example if i have a list of first last and middle names and i want to sort it in a tree by last name, how would i store all three of them in each node..
should i create a struct with them in it and a separate struct for my tree?
whats the easiest way to do this?
nadleeh 0 Newbie Poster
Recommended Answers
Jump to PostYou don't sort a binary search tree because it's inherently sorted. Just use the last name as your key for insertion.
Jump to PostDude, wtf. Just build your freaking tree. It's already sorted! You don't need a linked list, you don't need a separate sorting step:
#include <stdio.h> #include <string.h> struct person { char first_name[20]; char last_name[20]; }; struct node { struct person data; struct node *link[2]; }; struct node …
Jump to PostIf understood them completely why would I be here asking questions to get a grasp of it...
Forums are insufficient when what you really need is a book or tutorial dedicated to the topic. It's difficult to ask a question that makes sense without at least some foundation in the …
All 9 Replies
abhimanipal 91 Master Poster
nadleeh 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
nadleeh 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
nadleeh 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
nadleeh 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.