Binary search tree in C

Asked

Viewed 90 times

0

I need to use a binary search tree to organize data. In each node I need to have ID and name, but I don’t know how to put two values in the same node. The tree I’m using is as follows:

struct No {
  int data;
  struct No *left;
  struct No *right;
};
typedef struct No No;

What should I change to store two data on each node?

  • 1

    In your No you already have 3 "values", just add one more: char nome[50] something like that

1 answer

0

Just add as much data as you want into that struct.

For example:

struct No {
    int id;
    char nome[64];
    struct No *left;
    struct No *right;
};

typedef struct No No;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.