From 65f6fcf9cf7c893ea14c5d18c87e5d9083554237 Mon Sep 17 00:00:00 2001 From: Ciel Date: Sat, 29 Nov 2025 09:32:18 +0000 Subject: [PATCH] Fix trie merging bug --- dedup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dedup.c b/dedup.c index 00305681..d70e92bc 100644 --- a/dedup.c +++ b/dedup.c @@ -9,12 +9,12 @@ struct Trie { } *root=NULL; char merge(struct Trie *p) { + // missing child + if(!p) return 0; // this node is marked if(p->flag) return 1; - // missing either child - if(!p->child[0]||!p->child[1]) return 0; // true when both true; - return (p->flag = merge(p->child[0]) && merge(p->child[1])); + return (p->flag = merge(p->child[0]) & merge(p->child[1])); } void print(struct Trie *p, unsigned depth) {