Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GSTVALUE and RBTVALUE clarification
#1
How to initialize the GST tree on the main file,if i want to pass a compare function that reference the GSTVALUE?.
Reply
#2
From my newGST:

...
g->tree = newBST(compareGSTV);
setBSTdisplay(displayGSTV);
setBSTfree(freeGSTV);
...

simplified displayGSTV:

void displayGSTV(void *a,FILE *fp)
  {
  GSTV *x = a;
  x->display(x->value,fp);
  fprintf(fp,"<%d>",x->freq;
  }
Reply
#3
I am assuming that we use one structure to wrap the generic value for GST and RBT with add on color field for
RBT and it reside on gst.c.since GST is the underline data structure for RBT. if this is the case how can we reference that structure in
rbt .c for insertRBT as an example.
Reply
#4
(11-09-2018, 05:36 PM)oamohamed Wrote: I am assuming that we use one structure to wrap the generic value for GST and RBT with add on color field for
RBT and it reside on gst.c.since GST is the underline data structure for RBT. if this is the case how can we reference that structure in
rbt .c for insertRBT as an example.

It would probably be easier to make two structures, one for each class. RBTvalue would hold the generic value. GSTvalue would hold the RBTvalue.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)