Αbominable Δημοσ. 15 Μαρτίου 2005 Δημοσ. 15 Μαρτίου 2005 Προσφατα εφτιαξα ενα προγραμμα που Υλοποιει ενα (2,4) Δεντρο το οποιο ειναι φυλλοπροσανατολισμενο..Γενικα μου δουλευε καλα (οχι ακριβως οπως επρεπε). Μετα την ενθεση 1000 στοιχειων και την διαγραφη 500, μου παρουσιαζε προβλημα αφου σε συγκεκριμενο κομβο, τα κλειδια δεν ειχαν αντικατασταθει οπως επρεπε..Με αποτελεσμα να κολλαει το προγραμμα.. Υπαρχει κατι σαν εξεταστης προγραμματων για τα λογικα σφαλματα που προκαλουνται απο ενα προγραμμα;; Να καθησω να κανω βηματικη εκτελεση σε ενα δεντρο για την εισαγωγη-διαγραφη 1500 στοιχειων, δεν ειναι και οτι πιο ευκολο..
Skeftomilos Δημοσ. 15 Μαρτίου 2005 Δημοσ. 15 Μαρτίου 2005 Χμ, τέτοια bugs είναι που κάνουν τους προγραμματιστές να τραβάνε τα μαλλιά τους και να μένουν φαλακροί. Μερικοί πηδάνε κι απ'το παράθυρο στο τέλος. Μία ιδέα που μπορώ να σκεφτώ είναι να υλοποιήσεις μία απλή δομή με την ίδια λειτουργικότητα του δέντρου, για παράδειγμα μία λίστα. Η ταχύτητα δε μας ενδιαφέρει εδώ, μόνο η αξιοπιστία. Μετά θα κάνεις παράλληλη χρήση του δέντρου και της λίστας. Μία εισαγωγή στο ένα, μία εισαγωγή στην άλλη. Το ίδιο και με τις διαγραφές. Μετά από κάθε εισαγωγή ή διαγραφή θα κάνεις έλεγχο αντιστοιχίας των δύο δομών. Μόλις συμβεί η πρώτη ασυμφωνία σταματάς την εκτέλεση και εξετάζεις τα περιεχόμενά τους. Αν είσαι τυχερός θα μπορέσεις να εντοπίσεις το bug. Αν όχι, αύξησε την ποσότητα καφεΐνης στον καφέ σου. :grin:
Giannis__ Δημοσ. 15 Μαρτίου 2005 Δημοσ. 15 Μαρτίου 2005 Fylloprosanatolismeno? Opws leme fyllometrhths? Pragmatika den mporw na katalavw autes tis metafraseis. Apo ti stigmh pou oti grafeis se code, einai se agglika, giati na les to insert enthesh, kai to node kombo klp klp. Kai to bhmatikh ektelesh einai to debugging? Eleos Mh to pareis proswpika, apla mou fainontai poly periergoi autoi oi oroi sta ellhnika. Na ypirxe programming language, pou na grafes Ean kai Alliws, tha to katalavaina na ta legame sta ellhnika. Gia auto den mporw na plhsiasw kai ellhniko biblio programmatismou pote. Anyway gousta einai auta, back to the topic... Ontws to debugging me breakpoints se mia tetoia periptwsh den boithaei poly. Den kserw ti programming language xrhsimopoieis, alla an einai kati se .net i java, checkare ta Unit testing suites (NUnit kai JUnit). Tha se boithisoun na testareis ta diafora functions pou exeis. An den ta exeis ksanakousei, kane ena search, tha breis polles plhrofories kai tutorials. Epishs mia pou den mas dineis katholou code, den kserw an exeis ena thread i perissotera, ta opoia mporei na dimiourgoun diafora deadlocks, update problems klp.
krot Δημοσ. 15 Μαρτίου 2005 Δημοσ. 15 Μαρτίου 2005 (οχι ακριβως οπως επρεπε) Τί εννοείς; Για ψάξε το αυτό το όχι ακριβώς όπως έπρεπε. Συνήθως άμα δουλεύει καλά για 10 δουλεύει καλά και για 1000 και για 10000. Μήπως δημιουργείται κάποιο πρόβλημα με την δέσμευση μνήμης; και όταν έχει πάρα πολλά φύλλα τα παίζει; Πάντως και ο κώδικας δεν πρέπει να είναι πολύ μεγάλος. Δεν τον βάζεις να ρίξουμε μια ματιά;
tzoykas Δημοσ. 15 Μαρτίου 2005 Δημοσ. 15 Μαρτίου 2005 Πρόγραμμα που να ψάχνει για λογικά λάθη ΔΕΝ υπάρχει και όταν υπάρξει θα έχουμε ήδη αντικατασταθεί από τις μηχανές που θα γράφουν κώδικα μόνες τους Κανε ένα copy paste όπως είπε και ο krot να δούμε τι παίζει ....
daidalus Δημοσ. 15 Μαρτίου 2005 Δημοσ. 15 Μαρτίου 2005 Θα συμφωνήσω και εγώ με το φίλο παραπάνω που σε προτρέπει να χρησιμοποιήσεις αγγλική ορολογία.Καλώς ή κακώς οι ελληνικές μεταφράσεις δεν είναι τόσο επιτυχημένες.Δυστύχως ως έχει προσωπικά αδυνατώ να καταλάβω τι μπορεί να πηγαίνει στραβα. :|
drm Δημοσ. 15 Μαρτίου 2005 Δημοσ. 15 Μαρτίου 2005 Κάνα περίεργο memory leak (πιθανόν πέρα από το τέλος κάποιου πίνακα ???) το οποίο εμφανίζετε περιστασιακά ???
Αbominable Δημοσ. 15 Μαρτίου 2005 Μέλος Δημοσ. 15 Μαρτίου 2005 > #include <stdio.h> #include <stdlib.h> #include <math.h> #define min(a, ((a) < ( ? (a): () struct tree_node *access(int x); struct tree_node *create_node(void); void split(struct tree_node *last_changed); void fuse(struct tree_node *father, struct tree_node *uncle); void share(struct tree_node *father, struct tree_node *uncle); void delete_node(struct tree_node *u); void delete_item(int x); void insert_item(int x); void primitive_tree(); void change_node(struct tree_node *father, struct tree_node *grandpa); int content_min, content_max, counter,counter_d, sp ,f, sh , account; FILE *fout; struct tree_node { struct tree_node *parent; struct tree_node *children[5]; int keys[6]; int content; int children_no; int depth; int index; int node_pos;//node-position ston pinaka.. }; struct tree { struct tree_node *root; // root struct tree_node nodes[60000];//Pinakas ston opoio apo8hkeyontai oi komboi.. int node_no; // # kombwn kai fyllwn.. int height; } my_tree; struct tree_node *access(int x) { struct tree_node *u; int index; u=my_tree.root; account++; //fprintf(fout,"Access..\n"); while (u->children_no!=0) {/*Efoson o kombos den einai fyllo*/ u->keys[0]=content_min; u->keys[u->children_no]=content_max; for (index=0; index<=u->children_no;index++) {/*E3etazei ta kleidia tou*/ // fprintf(fout,"%d", index); if (u->keys[index]<x && x<=u->keys[index+1]) {/*Se periptwsh pou to stoixeio brisketai anamesa se 2 kleidia, akolou8ei ton katallhlo kombo..*/ u=u->children[index]; account++; break; } } } //fprintf(fout,"\n"); return u; } void split(struct tree_node *last_changed) { struct tree_node new_node, *grandpa, new_root; int i; //fprintf(fout,"Split..\n"); sp++; for(i=0; i<5; i++) new_node.children[i]=NULL; for(i=0; i<6; i++) new_node.keys[i]=NULL; if (last_changed==my_tree.root) {/*Ean o kombos pou kaleitai na diaspastei einai h riza tou dentrou tote orizoume ena neo kombo gia nea riza, ton arxikopoioume katallhla..*/ new_root.index=0; new_root.depth=0; new_root.children_no=1; for(i=0; i<5; i++) new_root.children[i]=NULL; for(i=0; i<6; i++) new_root.keys[i]=NULL; //Ton 8etoume patera ths palias rizas pou twra 8a diaspastei se 2 nees.. new_root.children[0]=last_changed; new_root.keys[0]=content_min; new_root.keys[2]=content_max; //Kai se ka8e kombo pou yparxei sto dentro ay3anoume to ba8os tou kata 1.. for(i=0; i<my_tree.node_no; i++) { my_tree.nodes[i].depth++; } my_tree.height++; //Apo8hkeysh ths neas rizas ston pinaka kombwn tou dentrou.. new_root.node_pos=my_tree.node_no++; my_tree.nodes[new_root.node_pos]=new_root; my_tree.root=&my_tree.nodes[new_root.node_pos]; last_changed->parent=my_tree.root;//my_tree.nodes[my_tree.node_no-1]; } grandpa=last_changed->parent;//O pateras tou kombou pou 8a diaspastei.. /*Dhmioyrgei ena kainoyrio kombo ston opoio 8a apo8hkeytoun ta [(b+1)/2] paidia..*/ new_node.children_no=0; new_node.content=0; /*Arxikopoihsh patera,index kai ba8ous*/ new_node.parent=grandpa; new_node.index=last_changed->index+1; new_node.depth=last_changed->depth; /* Metafora twn kombwn mia 8esh pera gia thn pros8hkh tou neou kombou..*/ for(i=grandpa->children_no; i>last_changed->index+1; i--) { grandpa->children[i]=grandpa->children[i-1]; grandpa->children[i]->index=i; } /*Metafora twn paidiwn, ston neo kombo..*/ for(i=0; i<3; i++) { new_node.children[i]=last_changed->children[2+i]; new_node.children[i]->index=i; last_changed->children[2+i]=NULL; new_node.children_no++; last_changed->children_no--; } /*Eisagwgh kleidiwn ston neo kombo..*/ for (i=1; i < new_node.children_no; i++) { new_node.keys[i]=last_changed->keys[2+i]; last_changed->keys[2+i]=NULL; } last_changed->keys[5]=NULL; new_node.keys[0]=content_min; new_node.keys[3]=content_max; /*Apo8hkeysh toy neou kombou, kai aparaithtes ry8miseis..*/ my_tree.nodes[my_tree.node_no++]=new_node; grandpa->children[last_changed->index+1]=&my_tree.nodes[my_tree.node_no-1]; /*Ta paidia toy orizontai na deixnoyn ayton ws patera..*/ for(i=0; i<new_node.children_no; i++) new_node.children[i]->parent=&my_tree.nodes[my_tree.node_no-1]; /*Ay3anontai ta paidia tou progonou kai eisagontai ta katallhla kleidia..*/ grandpa->children_no++; for(i=grandpa->children_no; i>last_changed->index+1; i--) { grandpa->keys[i]=grandpa->keys[i-1]; } grandpa->keys[last_changed->index+1]=last_changed->keys[2]; grandpa->keys[grandpa->children_no]=content_max; last_changed->keys[2]=content_max; if (grandpa->children_no > 4) split(grandpa); } void insert_item(int x) { struct tree_node new_leaf; struct tree_node u; int i; int index; u=*access(x); //fprintf(fout,"Insert..\n"); if (x==u.content) { // fprintf(fout,"To stoixeio yparxei hdh...\n"); counter--; } else { new_leaf.children_no=0; new_leaf.content=x; new_leaf.parent=u.parent; new_leaf.depth=u.depth; new_leaf.node_pos=my_tree.node_no++; if(x<u.content) index=u.index; else index=u.index+1; /*Eisagwgh neou fylou kai ry8miseis paidiwn,kleidiwn klp stoixeiwn ston patera..*/ for(i=u.parent->children_no; i>index; i--) { u.parent->children[i]=u.parent->children[i-1]; u.parent->children[i]->index=i; } new_leaf.index=index; /*Apo8hkeysh toy komboy ston pinaka..*/ my_tree.nodes[new_leaf.node_pos]=new_leaf; u.parent->children[index]=&my_tree.nodes[new_leaf.node_pos]; u.parent->children_no++; /*Ry8miseis kleidiwn ston patera*/ for(i=u.parent->children_no; i>index; i--) u.parent->keys[i]=u.parent->keys[i-1]; u.parent->keys[u.index+1]=min(u.content,new_leaf.content); if (u.parent->children_no > 4) split(u.parent); } } void delete_item(int x) { struct tree_node *to_delete, *father, *grandpa; int i; to_delete=access(x); father=to_delete->parent; grandpa=father->parent; if (to_delete->content==x) { counter_d++; // fprintf(fout,"Delete item..\n"); /*Diagrafh tou kleidiou pou odhgei ston kombo apo ton patera..*/ for(i=to_delete->index+1; i<=father->children_no; i++) { father->keys[i]=father->keys[i+1]; } father->keys[0]=content_min; father->keys[father->children_no-1]=content_max; /*Diagrafh tou kombou apo ton pinaka paidiwn tou patera..*/ for (i=to_delete->index; i<=father->children_no-1; i++) { father->children[i]=father->children[i+1]; if(father->children[i]!=NULL) father->children[i]->index=i; } father->children_no--; /*Ean o progonos kombos epeita apo thn diagrafh tou stoixeiou meinei me ena paidi, tote kaleitai mia apo tis diadikasies sympty3hs 'h diamoirasmou..*/ if (father->children_no==1) change_node(father, grandpa); } else { // fprintf(fout,"To stoixeio pou epi8ymeite na diagrapsetai den yparxei..\n"); } } void change_node(struct tree_node *father, struct tree_node *grandpa) { struct tree_node *r_uncle, *l_uncle; int i; if (father==my_tree.root) { my_tree.root=father->children[0]; my_tree.root->parent=NULL; grandpa=NULL; for(i=0; i<my_tree.node_no; i++) my_tree.nodes[i].depth-=1; my_tree.height-=1; } else { switch(father->index) { case 0: r_uncle=grandpa->children[1]; if (r_uncle->children_no>2) { share(father,r_uncle); } else { fuse(father, r_uncle); } break; case 1: /*Periptwsh poy o pateras exei aderfia de3ia -aristera*/ if (grandpa->children_no>2) { l_uncle=grandpa->children[0]; r_uncle=grandpa->children[2]; if(l_uncle->children_no > r_uncle->children_no) { if (l_uncle->children_no>2) { share(father,l_uncle); } else { fuse(father, l_uncle); } } else { if (r_uncle->children_no>2) { share(father,r_uncle); } else { fuse(father, r_uncle); } } } /*Periptwsh pou o pateras exei aderfo mono sta aristera tou..*/ else { l_uncle=grandpa->children[0]; if (l_uncle->children_no>2) { share(father,l_uncle); } else { fuse(father, l_uncle); } } break; case 2: /*Periptwsh poy o pateras exei aderfia de3ia -aristera*/ if (grandpa->children_no>3) { l_uncle=grandpa->children[1]; r_uncle=grandpa->children[3]; if(l_uncle->children_no > r_uncle->children_no) { if (l_uncle->children_no>2) { share(father,l_uncle); } else { fuse(father, l_uncle); } } else { if (r_uncle->children_no>2) { share(father,r_uncle); } else { fuse(father, r_uncle); } } } /*Periptwsh pou o pateras exei aderfo mono sta aristera tou..*/ else { l_uncle=grandpa->children[1]; if (l_uncle->children_no>2) { share(father,l_uncle); } else { fuse(father, l_uncle); } } break; case 3: l_uncle=grandpa->children[2]; if (l_uncle->children_no>2) { share(father,l_uncle); } else { fuse(father, l_uncle); } break; } if (grandpa->children_no==1) { if (grandpa==my_tree.root) { my_tree.root=grandpa->children[0]; my_tree.root->parent=NULL; grandpa=NULL; for(i=0; i<my_tree.node_no; i++) my_tree.nodes[i].depth-=1; my_tree.height-=1; } else { change_node(grandpa, grandpa->parent); } } } } void fuse(struct tree_node *father, struct tree_node *uncle) { struct tree_node *grandpa; //O pateras twn 2 aderfwn int i; f++; grandpa=father->parent; // fprintf(fout,"Fuse..\n"); /*O pateras tou diegramenou fylou 8a symptyx8ei me ton aristero aderfo tou..*/ if (father->index > uncle->index) { /*Metaferetai to fyllo tou patera ston aderfo tou..*/ uncle->children[uncle->children_no]=father->children[0]; /*Kai ry8mizontai ta index kai deikths ston patera..*/ uncle->children[uncle->children_no-1]->index=uncle->children_no-1; uncle->children[uncle->children_no++]->parent=uncle; /*Metaferetai to teleytaio kleidi tou kombou mia 8esh pera gia thn eisagwgh tou neou kleidiou..*/ uncle->keys[uncle->children_no]=uncle->keys[uncle->children_no-1]; /*Metaferetai to katallhlo kleidi apo ton patera tvn 2 aderfwn ston koino kombo..*/ uncle->keys[uncle->children_no-1]=grandpa->keys[uncle->index+1]; /*Diagrafetai to kleidi apo ton patera tvn 2 aderfwn..*/ for(i=uncle->index+1; i < grandpa->children_no; i++) grandpa->keys[i]=grandpa->keys[i+1]; grandpa->keys[grandpa->children_no]=NULL; } /*Alliws 8a symptyx8ei me ton de3h aderfo tou..*/ else { /*Metaferontai ta paidia tou aderfou mia 8esh pio pera gia thn eisagwgh tou neou fyllou..*/ for (i=uncle->children_no; i>0; i--) { uncle->children[i]=uncle->children[i-1]; uncle->children[i]->index=i; } /*Metaferetai to fyllo tou patera ston aderfo tou kai ay3anetai to # paidiwn tou..*/ uncle->children[0]=father->children[0]; uncle->children[0]->parent=uncle; uncle->children_no++; /*Metaferontai ta kleidia tou aderfou mia 8esh pio pera*/ for(i=uncle->children_no; i>1; i--) { uncle->keys[i]=uncle->keys[i-1]; } /*Metaferetai to katallhlo kleidi apo ton patera twn 2 aderfwn ston koino kombo..*/ uncle->keys[1]=grandpa->keys[uncle->index]; /*Diagrafetai to kleidi apo ton patera twn 2 aderfwn..*/ for(i=uncle->index; i < grandpa->children_no; i++) { grandpa->keys[i]=grandpa->keys[i+1]; } grandpa->keys[grandpa->children_no]=NULL; } /*Allazoun oi 8eseis twn kombwn ston pinaka paidiwn tou pappou gia na exoyn to swsto index..*/ for(i=father->index; i<grandpa->children_no-1; i++) { grandpa->children[i]=grandpa->children[i+1]; grandpa->children[i]->index=i; } grandpa->children[grandpa->children_no-1]=NULL; /*Meiwnetai to #paidiwn tou pappou..*/ grandpa->children_no--; if (grandpa ->children_no==1) { if (grandpa==my_tree.root) { my_tree.root=grandpa->children[0]; my_tree.root->parent=NULL; grandpa=NULL; for(i=0; i<my_tree.node_no; i++) my_tree.nodes[i].depth-=1; my_tree.height-=1; } else { change_node(grandpa, grandpa->parent); } } } void share(struct tree_node *father, struct tree_node *uncle) { struct tree_node * grandpa; int i; sh++; // fprintf(fout,"Share..\n"); grandpa= father->parent; if (father->index > uncle->index) { /*PAIDIA*/ /*O pateras tou diegramenou fylou 8a daneistei paidi apo ton aristero aderfo tou..*/ /*Metaferetai to monadiko paidi mia 8esh dipla ston pinaka paidiwn*/ father->children[1]=father->children[0]; father->children[1]->index=1; /*Metaferetai to teleytaio paidi toy aderfou,ay3anetai to #paidiwn tou patera kai meiwnetai to #paidiwn tou adrefou kombou..*/ father->children[0]=uncle->children[--uncle->children_no]; father->children[0]->parent=father; father->children[0]->index=0; ++father->children_no; uncle->children[uncle->children_no]=NULL; /*KLEIDIA*/ /*Metaferetai to kleidi apo ton patera twn 2 aderfwn ston patera pou yio8ethse to fyllo..*/ father->keys[1]=grandpa->keys[father->index]; father->keys[2]=content_max; /*Metaferetai to kleidi apo ton aderfo ston patera twn 2 aderfwn..*/ grandpa->keys[father->index]=uncle->keys[uncle->children_no-1]; } else { /*PAIDIA*/ /*Alliws o pateras tou diegramenou fylou 8a daneistei paidi apo ton de3h aderfo tou..*/ /*Metaferetai to 1o paidi tou aderfou,ay3anetai to #paidiwn tou patera kai meiwnetai to #paidiwn tou adrefou kombou..*/ father->children[1]=uncle->children[0]; father->children[1]->parent=father; ++father->children_no; for(i=0; i<uncle->children_no-1; i++) { uncle->children[i]=uncle->children[i+1]; uncle->children[i]->index=i; } uncle->children[--uncle->children_no]=NULL; /*KLEIDIA*/ /*Metaferetai to katallhlo kleidi apo ton patera twn 2 aderfwn ston patera pou yio8ethse to fyllo..*/ father->keys[1]=grandpa->keys[uncle->index]; father->keys[2]=content_max; /*Metaferetai to 1o kleidi apo ton aderfo ston patera twn 2 aderfwn..*/ grandpa->keys[uncle->index]=uncle->keys[1]; for(i=1; i<uncle->children_no; i++) uncle->keys[i]=uncle->keys[i+1]; uncle->keys[uncle->children_no]=content_max; } } void main(void) { int i, x; struct tree_node *u; content_min=0; content_max=20001; primitive_tree(); i=0; fout=fopen("Test.txt","w"); counter=2; /*Erwthma a for(i=0; i<20000; i++) { x=rand()%19999+1; //fprintf(fout,"To %2d stoixeio poy apo8hkeyetai einai to %d\n",i,x); counter++; insert_item(x); //fprintf(fout,"\n"); }*/ i=0; /*Erwthma b*/ /*EISAGWGH 1000 STOIXEIWN GIA TO ARXIKO DENTRO*/ fprintf(fout,"Eisagoume 1000 stoixeia"); for(i=0; i<1000; i++) { x=rand()%999+1; //fprintf(fout,"To %2d stoixeio poy apo8hkeyetai einai to %d\n",i,x); counter++; insert_item(x); } fprintf(fout,"Bre8hkan %d stoixeia me Ypsos= %d\n",counter ,my_tree.height); fprintf(fout,"Epomenws parathroyme oti 2^h <= %d <= 4^h afoy 2^%d= %3.0f kai 4^%d= %6.0f\n", counter,my_tree.height, pow(2,my_tree.height),my_tree.height, pow(4,my_tree.height)); fprintf(fout,"\n"); fprintf(fout,"\n"); /*DIAGRAFH & EISAGWGH 500 STOIXEIWN KAI METRHSH EPANAZYGISTIKWN PRA3EWN..*/ counter=0; sp=sh=f=0; fprintf(fout,"Diagrafoume 250 stoixeia"); fprintf(fout,"# Stoixeiwn poy exoyn diagrafei , # pra3ewn diamoiramou , # pra3ewn sumpth3hs\n"); for(i=0; i<500; i++) { if(i%2==1) { x=rand()%999+1; //fprintf(fout,"To %2d stoixeio poy 8elete na diagrapsetai einai to %d\n",i,x); delete_item(x); fprintf(fout," %4d\t %4d \t %4d \t",counter_d,sh,f); } else { x=rand()%999+1; //fprintf(fout,"To %2d stoixeio poy 8elete na diagrapsetai einai to %d\n",i,x); insert_item(x); counter++; //fprintf(fout," %4d \t %4d \t",counter,sp); fprintf(fout,"\n"); } } /*PROSPELASH 200 STOIXEIWN KAI METRHSH BHMATWN*/ for(i=0; i<200; i++) { account=0; x=rand()%999+1; u=access(x); fprintf(fout,"%3d \t Psa3imo, gia to stoixeio \t %3d, \t katalh3ame sto \t %3d \t meta apo \t %d\t bhmata..\n",i,x, u->content, account); } fclose(fout); while(getchar()!=EOF) ; } void primitive_tree() { struct tree_node leaf1, leaf2, root; int i; leaf1.content=1; leaf1.index=0; leaf1.depth=1; leaf1.node_pos=0; leaf1.children_no=0; leaf2.content=2; leaf2.index=1; leaf2.depth=1; leaf2.node_pos=1; leaf2.children_no=0; for(i=0; i<5; i++) { leaf1.children[i]=NULL; leaf2.children[i]=NULL; root.children[i]=NULL; } root.index=0; root.depth=0; root.node_pos=2; root.keys[0]=content_min; root.keys[1]=min(leaf1.content,leaf2.content); root.keys[2]=content_max; my_tree.nodes[root.node_pos]=root; my_tree.root=&my_tree.nodes[root.node_pos]; leaf1.parent=my_tree.root; leaf2.parent=my_tree.root; my_tree.nodes[leaf1.node_pos]=leaf1; my_tree.nodes[leaf2.node_pos]=leaf2; my_tree.root->children[0]=&my_tree.nodes[leaf1.node_pos]; my_tree.root->children[1]=&my_tree.nodes[leaf2.node_pos]; my_tree.root->children_no=2; my_tree.node_no=3; my_tree.height=1; } Ειναι ψιλο-μεγαλος.. Μην δωσετε πολυ σημασια.. Για λιγα στοιχεια μου τρεχει ακριβως.. Το προβλημα πρεπει να προκυπτει μαλλον κατα την διαγραφη (delete) των στοιχειων.. (Εξηγησεις: ) Φυλλοπροσανατολισμενο ειναι το δεντρο που περιεχει τα δεδομενα στα φυλλα (leaf) του, ενω στους κομβους (nodes) περιεχει πληροφοριες-κλειδια για τον ποιο κομβο πρεπει να ακολουθησει για να καταληξει στο αντιστοιχο φυλλο-δεδομενο. Το προβλημα προκυπτει κατα την διαγραφη, οταν καποια στιγμη τα κλειδια συγκεκριμενου κομβου δεν ειναι οπως θα επρεπε με αποτελεσμα να πεφτει σε (loop) ατερμονο βρογχο. Τεσπα εμαθα αυτο που ηθελα. Ευχαριστω πολυ. Υ.Γ. Σχετικα με τους ορισμους, με οποιον δασκαλο καθισεις τετοια γραμματα θα μαθεις.. Επειτα γουστα ειναι αυτα, προσωπικα προτιμω τα Ελληνικα..
kickeras Δημοσ. 16 Μαρτίου 2005 Δημοσ. 16 Μαρτίου 2005 sizitisi 1i: ontws kai egw tetoio provlima exw. exw mathei mathimatika kai fisiki sta ellinika kai kamia fora apla pramata me diskolevoun sta agglika alla programming ematha sta agglika kai ektos tou oti den kserw kan ti simenoun oi ellinikes metafraseis merikes fores akoma kai san aples lekseis. Vivlio elliniko an anoiksw tha katalavw ligotera apo ena mathiti sxoleiou. sizitisi 2i: Wxwxwx an einai memory leak.....den exw xrono na koitaksw ton kwdika sou alla....constructor exeis i mou fenetai pws oxi? tin exw kai egw patisei me ena programma twra kai mallon exw memory leak giati kapoies fores mou kanei kati koula kai varaw to kefali mou ston toixo. Prepei na eisai poli prosektikos eidika me tous pointers(EIDIKA ME AFTOUS), ta initializations kai to pws kaleis ta panta kathws iparxei periptwsi kati na mi doulevei opws fenetai. I p.x. opou kati den prepei na allazei anagkastika const wste an meta to allakseis kapou tha to piasei o compiler. Eidika an to provlima sou einai kata to delete tote koitakse prosektika min allazeis kati pou de prepei. Dokimase otan sou kanei to provlima na xrisimopoiiseis breakpoints alla ekeini ti stigmi kai sigkrine values pou panw katw ksereis ti exoun. Checkare kai ta memory locations. I entoli assert einai poli xrisimi tha sou simvouleva na tin koitakseis. Kali tixi
Προτεινόμενες αναρτήσεις
Αρχειοθετημένο
Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.