topic 9 linear search and hash tables. announcements participation due tomorrow funsort explanation...

Post on 17-Jan-2018

218 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

FunSort FunSort(list, low, high) returns list if (low < high) then FunSort(list, low, high-1) if list[high-1] > list[high] then swap list[high-1] and list[high] FunSort(list, low, high-1) end if end FunSort

TRANSCRIPT

Topic 9

Linear Search and

Hash Tables

Announcements

• Participation due tomorrow

• FunSort explanation posted

FunSortFunSort(list, low, high) returns list

if (low < high) thenFunSort(list, low, high-1)if list[high-1] > list[high] then

swap list[high-1] and list[high]FunSort(list, low, high-1)

end ifend if

end FunSort

FunSort TL;DR

5 4 3 2 1…3 4 5 2 1

More on Homework 4

• Program argumentspublic static void main(String[] args){ for (int i = 0; i < args.length; i++) System.out.println(args[0]);} bash$ java cs345_prog1 hello worldhelloworld

• Images

Searching

Definition:

Searching Unsorted Array

Jump Search

Binary Search

Interpolation/Phonebook Search

0 … 8946 … 9999

N Log(n) Log(log(n))

Hash Tables

Definition:

Division Method

Multiplication Method

MAD (Multiply, Add, and Divide)

Considerations

Collisions

Chaining

Open Addressing

Linear Probing

Quadratic Probing

Double Hashing

Deletion

• Chaining

• Open Addressing

Runtime Analysis

Perfect Hashing

Universal Hash Function

Bloom Filters

top related