数据结构背后的T9类字典 [英] Data structure behind T9 type of dictionary

查看:131
本文介绍了数据结构背后的T9类字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

T9字典如何工作?它后面的数据结构是什么如果我们输入'4663',当我们按下按钮时,我们会得到'好',然后'home'等等。

How does a T9 dictionary work? What is the data structure behind it. If we type '4663' we get 'good' when we press down button we get 'gone' then 'home' etc...

编辑:如果用户键入在46,那么它应该显示'go',当按下箭头应该显示'走了'等...

If the user types in 46 then it should show 'go' and when pressed down arrow should show 'gone' etc...

推荐答案

它可以以几种方式实施,其中之一是 Trie 。路由由数字表示,节点指向单词的收集。

It can be implemented in several ways, one of them is Trie. The route is represented by the digits and the nodes point to collection of words.

它也可以使用嵌套哈希表来实现,哈希表是一个字母,每个数字都算出所有可能的路由(O(3 ^ n)路由)。

It can be implemented using nested hash tables as well, the key of the hash table is a letter and on every digit the algorithm calculates all possible routes (O(3^n) routes).

这篇关于数据结构背后的T9类字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆