-2

i have found following code on online for suffix tree

#include <stdio.h>
#define E 0

struct suffix_tree_node;


struct suffix_tree_link {
    // 0 is e - global index of during string's end
    unsigned long start;
    unsigned long end;
    suffix_tree_link(suffix_tree_node* source, suffix_tree_node* target, 
                     unsigned long start, unsigned long end) {
        this->source = source;
        this->target = target;
        this->start = start;
        this->end = end;
    }
    suffix_tree_node* source;
    suffix_tree_node* target;
    suffix_tree_link* next_link;
};

struct suffix_tree_node {
    suffix_tree_link* first_link;
    suffix_tree_node* parent_node;
    suffix_tree_node* suffix_link_node;

    // other constructors?
    suffix_tree_node() {
        parent_node = suffix_link_node = NULL;
        first_link = NULL;
    }

    void add_target(unsigned long start, unsigned long end, suffix_tree_node* target) {
        suffix_tree_link* link;
        for(link = first_link; link != NULL; link = link->next_link);
        link = new suffix_tree_link(this, target, start, end);
    }

};



class suffix_tree {

    suffix_tree_node* root;
    const char* string;

    void ukkonen() {
        root->add_target(1, E, new suffix_tree_node);
        unsigned long e = 1, j_i = 1, i = 1; 
        for( int i = 0; string[i] != '\0'; i++) {
            e++;
            for() {

                j_star = j;
            }

            j_i = j_star;
        }
    }

public:

    suffix_tree(const char* string) {
        root = new suffix_tree_node();
        this->string = string;
        ukkonen();
    }

};

int main() {
    suffix_tree("foof");
    return 0;
}

everything is clear almost in this code,because i have read about suffix tree many times before,but i did not understand this fragment:

void ukkonen() {
            root->add_target(1, E, new suffix_tree_node);
            unsigned long e = 1, j_i = 1, i = 1; 
            for( int i = 0; string[i] != '\0'; i++) {
                e++;
                for() {

                    j_star = j;
                }

                j_i = j_star;
            }
        }

what does this code do?

also what is for()? or j_start?

here is a link for this code.

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
  • 5
    Are you sure that actually compiles? – Kerrek SB Mar 14 '12 at 20:13
  • No C pro but if it did I would imagine it would either never enter that section or enter an infinite loop...curious to find out though. Looks like half finished homework to me. – Rig Mar 14 '12 at 20:17
  • `for(;;)` is an infinite loop, but I've never seen `for()` before. – Mooing Duck Mar 14 '12 at 20:19
  • i could not guessed instead of this bug lines,what could be in ukkonen method –  Mar 14 '12 at 20:20
  • May be something was lost because `<` or `>` symbols were not quoted properly for html? – 6502 Mar 14 '12 at 20:27
  • @6502 - Nope, if you click on the 'raw' link on github, you get the same thing. – Robᵩ Mar 14 '12 at 20:33
  • i dont know,could you help me to recovery this code such that it could work? –  Mar 14 '12 at 20:36
  • Look [here](https://github.com/qumon/da_labs/blob/master/lab5.3.cpp). – Robᵩ Mar 14 '12 at 20:37
  • so i have read about suffix tree many times,but could not read about code itself now,so it is complete implementation of suffix tree? –  Mar 14 '12 at 20:43
  • I don't know if that implementation is complete, nor even if it is a suffix tree. You might try asking its author. – Robᵩ Mar 14 '12 at 21:28

1 Answers1

5

You are looking at a work-in-progress. The code you posted hasn't been completely written yet, and does not compile.

A later version of that file can be found here.

Robᵩ
  • 163,533
  • 20
  • 239
  • 308