1. Trang chủ
  2. » Công Nghệ Thông Tin

Lecture Java methods: Object-oriented programming and data structures (2nd AP edition): Chapter 25 - Maria Litvin, Gary Litvin

23 37 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Slide 1

  • Objectives:

  • Lookup Tables

  • Lookup Tables (cont’d)

  • Lookup Tables: Example 1

  • Lookup Tables: Example 2

  • Lookup Tables: Example 3

  • Applications of Lookup Tables

  • Hash Tables

  • Hash Tables (cont’d)

  • Chaining

  • Probing

  • java.util.HashSet<E> and java.util.HashMap<K,V> Classes

  • HashSet and HashMap (cont’d)

  • Slide 15

  • Slide 16

  • hashCode Examples

  • Consistency

  • HashSet<E> Constructors

  • HashMap<K,V> Constructors

  • Review:

  • Review (cont’d):

  • Slide 23

Nội dung

Chapter 25 - Lookup tables and hashing. After you have mastered the material in this chapter, you will be able to: Learn about lookup tables, learn about hashing, review java.util.HashSet and java.util.HashMap.

Java Methods Object-Oriented Programming and Data Structures 2nd AP edition with GridWorld Maria Litvin ● Gary Litvin   Chapter Hash Function Danger  Keep Out  25 Lookup Tables and Hashing Copyright © 2011 by Maria Litvin, Gary Litvin, and Skylight Publishing All rights reserved Objectives: • Learn about lookup tables • Learn about hashing • Review java.util.HashSet and java.util.HashMap 25­2 Lookup Tables • A lookup table is an array that helps to find data very quickly • The array stores references to data records (or some values) • A data record is identified by some key • The value of a key is directly translated into an array index using a simple formula 25­3 Lookup Tables (cont’d) • Only one key can be mapped onto a particular index (no collisions) • The index that corresponds to a key must fall into the valid range (from to array.length-1) • Access to data is “instantaneous” (O(1)) 25­4 Lookup Tables: Example   Zip codes 600 601 1004 1005 1006 1007 1008 1009 99950 99951 99998 99999 Corresponding locales Adjuntas, PR Amherst, MA Barre, MA Belchertown, MA Blanford, MA Bondsville, MA Some table entries remain unused Ketchikan, AK 25­5 Lookup Tables: Example private static final int [ ] n_thPowerOf3 = { 1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683 }; // precondition:

Ngày đăng: 04/11/2020, 23:19

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN