Notes for Lecture 5


Sets and Maps;Big-Oh Notation


Sets


引入

  • 非重复读入大文件中的所有单词
  • method:存储于向量中 每次输入遍历向量判重 不重存入
  • 每次输入均需要遍历整个向量 耗时

定义

类型

  • Set
  • HashSet

操作

运算符(集合交 并 差)

遍历


Maps


定义

a collection storing pairs

类型

  • Map
  • HashMap

操作

应用

  • tallying 计数

遍历


Compound/Nested Collections


Lotto tictets
Buddy list


算法分析和Big-Oh符号