Princeton Algorithms: Part 2 [week 5: Substring Search]
来源:互联网 发布:硬笔入门字帖 知乎 编辑:程序博客网 时间:2024/05/30 23:02
Exercise
Question Explanation
The correct answer is: 1 2 2 4 5 2 7 5
Here is the DFA:
0 1 2 3 4 5 6 7
----------------------
A 1 2 2 4 5 2 7 5
B 0 0 3 0 0 6 0 0
C 0 0 0 0 0 0 0 8
Question Explanation
The correct answer is: T Y T T H I N H
Here is a trace:
i j i+j 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
----------------------------------------------------------------------------------------------------
P A N E W A T Y O U R F E E T T H I N K N O W A N D T H E N
0 6 6 O W A N D T H
1 6 7 O W A N D T H
8 6 14 O W A N D T H
9 6 15 O W A N D T H
10 4 14 O W A N D T H
11 6 17 O W A N D T H
18 6 24 O W A N D T H
21 0 21 O W A N D T H
Question Explanation
The correct answer is: 4
hash(3237816904) = 3237816904 (mod 53)
= 52
hash(1000000000) = 1000000000 (mod 53)
= 28
2378169046 = (3237816904 - 3*1000000000) * 10 + 6
hash(2378169046) = (3237816904 - 3*1000000000) * 10 + 6 (mod 53)
hash(2378169046) = (52 - 3*28) * 10 + 6 (mod 53)
= -49 (mod 53)
= -49 + 53 (mod 53)
= 4
Recall that the Java operator % is remainder, and not modulus. When taking
a dividend mod Q, the result is a value between 0 and Q-1; with remainder,
the result can be a negative value if the dividend is negative.
Interview Questions
0 0
- Princeton Algorithms: Part 2 [week 5: Substring Search]
- Princeton Algorithms: Part 2 [week 5: Tries]
- Princeton Algorithms: Part 1 [week 5: Balanced Search Trees]
- Princeton Algorithms: Part 2 [week 7: Reductions]
- Princeton Algorithms: Part 2 [week 7: Intractability]
- Princeton Algorithms: Part 1 [week 4: Binary Search Trees]
- Princeton Algorithms: Part 2 [week 7: Final Exam Part II]
- Princeton Algorithms: Part 2 [week 2: Minimum Spanning Trees]
- Princeton Algorithms: Part 2 [week 2: Shortest Paths]
- Princeton Algorithms: Part 1 [week 2:Stacks and Queues]
- Princeton Algorithms: Part 1 [week 2:Elementary Sorts]
- Princeton Algorithms: Part 2 [week 1: Undirected Graphs]
- Princeton Algorithms: Part 2 [week 1: Directed Graphs]
- Princeton Algorithms: Part 2 [week 3: Maxflow and Mincut]
- Princeton Algorithms: Part 2 [week 3: Radix Sorts]
- Princeton Algorithms: Part 2 [week 6: Regular Expressions]
- Princeton Algorithms: Part 2 [week 6: Data Compression]
- Princeton Algorithms: Part 2 [week 7: Linear Programming]
- C++中this指针的用法.
- Cloudera Impala官方文档中文翻译-2(Using Impala to Query HBase Tables)
- Hadoop架构和设计要点
- 【LeetCode】3Sum Closest
- Java集合框架2——迭代器
- Princeton Algorithms: Part 2 [week 5: Substring Search]
- C++的try_catch异常
- 华尔街纪事丨中国人在美国买房的那些事儿
- XMemcached使用
- 陌陌流行,因为异乡人的渴望?
- Mongodb分页优化
- C++虚函数访问权限的改变
- 如何传递二维数组
- secureCRT 不识别 键盘输入