#include "fcbo_no_ny_breadth1.h"
void find_all_intents(void);
void insert_node(unsigned long * intent, unsigned long * extent, int start_int, int start_bit);
void generate_from_node(unsigned long *intent, unsigned long *extent, int start_int, int start_bit);
struct queue_node_t
;struct queue_node_concept
concept_queue = ;
int main(int argc, char **argv)
/*層次遍歷? 「類」層次遍歷吧 因為儘管是層次遍歷,但是對構成的格來說不是走的層次
空空:01 2 3 4
01:012 0134 014
2:3:34
4:012:01234 0124
0134:
014:
34:01234:
0124:
概念個數:11, 時間0.008000秒
*/void find_all_intents(void)
}// 去掉新條件ny(即implied),只有cbo原始條件;廣度;單結點、單概念分配記憶體,用完釋放
void generate_from_node(unsigned long *intent, unsigned long *extent, int start_int, int start_bit)
start_bit = archbit;
}skipout:
return;
}//自己的insert_node方法,僅僅更新概念指標concept_queue
void insert_node(unsigned long * intent, unsigned long * extent, int start_int, int start_bit)
fcbo_no_ny_breadth1.h:
#pragma once
#define _crt_secure_no_warnings
#include #include #include #define bit ((unsigned long) 1)
#define null_long ((unsigned long) 0)
#define int_size (sizeof (int))
#define long_size (sizeof (unsigned long))
#define archbit ((long_size * 8) - 1)
#define byte_count_a (long_size * int_count_a)
#define byte_count_o (long_size * int_count_o)
#define buffer_block 1024
struct stats_t
stats = ;
int *buff = null;
int buff_index = 0;
size_t buff_size = buffer_block;
int attributes = 0;
int objects = 0;
int int_count_a = 0;
int int_count_o = 0;
int table_entries = 0;
int min_support = 0;
unsigned long *context;
unsigned long **cols;
int *supps;
int *attrib_numbers;
unsigned long upto_bit[archbit + 1];
int attr_offset = 0;
file *in_file;
file *out_file;
int verbosity_level = 1;
int get_next_integer(file *file, int *value)
if (ch == eof)
return 0;
*value = 0;
while ((ch >= '0') && (ch <= '9'))
ungetc(ch, file);
*value -= attr_offset;
return 1;
}void allocate_buffer(int **buffer, int size)
}#define push_new_integer(__value) \
\buff [buff_index] = (__value); \
buff_index ++; \
}void read_file(file *file)
else
last_value = value;
} if (last_value >= 0)
objects = last_object + 1;
attributes = last_attribute + 1;
}void create_context(void)
memset(context, 0, long_size * int_count_a * objects);
supps = (int *)malloc(sizeof(int) * attributes);
memset(supps, 0, sizeof(int) * attributes);
for (i = 0; i < buff_index; i++)
context[row * int_count_a + (buff[i] / (archbit + 1))] |= (bit << (archbit - (buff[i] % (archbit + 1))));
supps[buff[i]]++;
table_entries++;
} if (verbosity_level >= 2)
fprintf(stderr, "objects: %6i\nattributes: %4i\nentries: %8i\n", objects, attributes, table_entries);
}void initialize_output(void)
void print_attributes(unsigned long *set, size_t supp)
c++;
if (c >= attributes)
goto out;
} }out:
fprintf(out_file, "\n");
}int cols_compar(void *a, void *b)
else }
int rows_compar(void *a, void *b)
void sort_context(void)
} free(context);
context = new_context;
qsort(context, objects, byte_count_a, rows_compar);
}void initialize_algorithm(void)
cols_buff = (unsigned long *)malloc(long_size * int_count_o * attributes);
memset(cols_buff, 0, long_size * int_count_o * attributes);
cols = (unsigned long **)malloc(sizeof(unsigned long *) * attributes);
ptr = cols_buff;
for (k = j = 0; j < int_count_a; j++)
for (i = archbit; i >= 0; i--, k++) }
void compute_closure(unsigned long *intent, unsigned long * extent, unsigned long * prev_extent, unsigned long * attr_extent, int * supp)
}else
break;
}} }
else }
}
按層次遍歷
思路 設兩個列表,乙個列表存放當前層節點,此節點的左右子樹入子層列表。給出乙個原層,乙個子層,每次用子層覆蓋原層。遍歷完當前層,存入結果列表中。def print self,proot write code here outlist if not proot return outlist quene...
樹的層次遍歷
include includeusing namespace std 結點權值作為結點編號 int postorder 31 後序遍歷結點 int inorder 31 中序遍歷結點 int leftnodes 31 儲存某結點的左子樹編號 int rightnodes 31 儲存某結點的右子樹編號...
樹的層次遍歷和確定層次問題
還是很簡單的 public void levelorder node root if node.getright null 層次遍歷有些演算法題會考,需要確定層次問題 public void levelorder node root if node.getright null size 大while...