Coursera - Algorithm (Princeton) - 习题与解答 - Week 10

本篇博客涵盖了Coursera算法课程第十周的内容,包括前缀码的判断算法,利用前缀树解决Boggle游戏,介绍后缀树的难点,探讨字符串环形旋转的线性解决方案,以及寻找串联重复子串的策略。此外,还介绍了线性时间复杂度内寻找最长回文子串的KR算法和Manacher算法。
摘要由CSDN通过智能技术生成

Week 10

Prefix free codes

题目

In data compression, a set of binary strings is if no string is a prefix of another. For example, {01,10,0010,1111} is prefix free, but {01,10,0010,10100} is not because 10 is a prefix of 10100. Design an efficient algorithm to determine if a set of binary strings is prefix-free. The running time of your algorithm should be proportional the number of bits in all of the binary stings.

分析

实际上时间复杂度就是要不超过 c N W cNW cNW,因此可以用这周学的前缀树

对前缀树,因为只有两位,相当于一个2路前缀树,只要向树中不断插入值,只要在插入过程中遇到既有键,就说明拥有公共前缀。

Boggle

题目

Boggle is a word game played on an 4 4 4-by- 4 4 4 grid of tiles, where each tile contains one letter in the alphabet. The goal is to find all words in the dictionary that can be made by following a path of adjacent tiles (with no tile repeated), where two tiles are adjacent if they are horizontal, vertical, or diagonal neighbors.

分析

使用一个前缀树来维护词典中的单词,对方格进行深度遍历

Suffix trees

问题

Learn about and implement , the ultimate string searching data structure.

分析

官方承认这个是非常难的,因此放弃

Cyclic rotation of a string

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值