后缀树:最长重复子串执行

编程入门 行业动态 更新时间:2024-10-25 18:27:47
本文介绍了后缀树:最长重复子串执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我实现了一个后缀树,这是不COM pressed。我想知道如何解决发现的最长的重preating子在一个字符串的问题。我知道,我们必须找到两个孩子最深的内部节点,但如何能C此$ C $。此外,我们怎么知道最长的重复子是什么。我感兴趣的是code在JAVA。请给Java实现。作为参考,我的TrieNode看起来像

类TrieNode { 焦CH; 链表< TrieNode>儿童; }

解决方案

这只是最深的节点有两个孩子,如果你存储字节字符串的结束。

要找到你需要做一个深度优先搜索最长的子串,保持一个参考最深的节点有2个或更多的孩子,它的深度。这是最简单的做一个递归函数。

I have implemented a suffix tree, which is not compressed. I wanted to know how to solve the problem of finding the longest repreating substring in a string. I know that we have to find the deepest internal node with two children, but how can be code this. Also, how do we know what the longest repeating substring is. I am interested in the code in JAVA. Pls give java implementation. For reference, my TrieNode looks like

class TrieNode{ char ch; LinkedList<TrieNode> child; }

解决方案

It's only the deepest node with 2 children if you store an end of string byte.

To find the longest substring you'll need to do a depth first search, keeping a reference to the deepest node with 2 or more children and it's depth. This is easiest to do with a recursive function.

更多推荐

后缀树:最长重复子串执行

本文发布于:2023-11-30 01:09:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648216.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:后缀   最长

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!