Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Google Applied CS - Day 3
Search
Harsh Vakharia
March 30, 2016
Education
58
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Google Applied CS - Day 3
Day 3:
Ghost game using ArrayList and Trie
Harsh Vakharia
March 30, 2016
More Decks by Harsh Vakharia
See All by Harsh Vakharia
Google Applied CS - Day 4
harshjv
0
48
Google Applied CS - Introduction
harshjv
0
46
Google Applied CS - Day 1
harshjv
0
140
Other Decks in Education
See All in Education
響け!ユーフォニアムと考える「決め方」/Thinking About Decision-Making with Sound! Euphonium
3l4l5
1
200
AIがコードを書く時代に、何を教えるのか / What Should We Teach in the Age of AI-Generated Code?
ichiroc
1
610
マークシート試験のTeX言語を用いた自動採点について
doratex
0
6.1k
人間関係に取り組む、その時に / step away to make space
spring_aki
0
140
2026年度秋学期 統計学 第1回 イントロダクション ー 統計的なものの見方・考え方について (2026. 9. 29)
akiraasano
PRO
0
260
Adobe Express
matleenalaakso
2
8.4k
Design Guidelines and Models - Lecture 5 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
1.7k
Digijulkaisut
matleenalaakso
1
10k
学習者データを「見る」:外国語教師のためのデータの入力、分析、解釈方法
uranoken
0
440
INTRODUCTION TO THE CELL
pawan_pharm
0
330
子どものためのプログラミング道場『CoderDojo』〜法人提携例〜 / Partnership with CoderDojo Japan
coderdojojapan
PRO
4
19k
私たちはなんでテストするんだっけ? Ver.東北IT物産展2026 in 会津若松
camel_404
3
220
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
820
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
59k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
850
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
780
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Agile that works and the tools we love
rasmusluckow
331
22k
Mobile First: as difficult as doing things right
swwweet
225
10k
Transcript
Google Applied CS with Android
High Time
Ghost
How-to 1. Build dictionary 2. Set button click listeners 3.
Decide the turn
Decide the turn if (user's turn) { listen to onKeyUp
-> (k) { if k is a valid letter { append it to TextView } else ignore } } else { if word is of length 4 or more && it is a valid word { Computer wins } else { put next character } }
Put next character It should form a valid word because
this is a computer!
Ta-da ! while (low < high) { mid = (low
+ high) / 2; t = words.get(mid); if(t.startsWith(prefix)) { return t; } else if(prefix.compareTo(t) > 0) { // LHS is bigger low = mid + 1; } else { // RHS is bigger high = mid - 1; } }
Best case: O(1) Average/Worst case: O(log n)
None
None
Tri ! re(tri)eval
Basics 1. HashMap<Character, TrieNode> children 2. root.add(word) 3. root.isWord(word) 4.
root.getAnyWordStartingWith(word)
Add a word to Trie void add(String s, int position)
{ if (position >= s.length()) return; char c = s.charAt(position); TrieNode n = children.get(c); if (n == null) { n = new TrieNode(); children.put(c, n); } if (position == s.length() - 1) { n.isWord = true; } n.add(s, position + 1); }
And a bit of method overloading
void add(String s) { add(s, 0) } void add(String s,
int position) { ... }
Same logic, different application 1. root.isWord(word) 2. root.getAnyWordStartingWith(word)
Fast Dictionary ! An efficient lookup structure
This is it for today
Any doubts?