CS 130a DISCUSSION SESSION 2 - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

CS 130a DISCUSSION SESSION 2

Description:

abba 8. input text. coded text. code table. LZW Decompression ... 8 abba. LZW Compression Example 2. a a a b b b a a a a b b a a a. 0 2 1 4 2 3 1 6. aa 2 ... – PowerPoint PPT presentation

Number of Views:65
Avg rating:3.0/5.0
Slides: 18
Provided by: lxu3
Category:

less

Transcript and Presenter's Notes

Title: CS 130a DISCUSSION SESSION 2


1
CS 130a - DISCUSSION SESSION 2
Shravan Samindla
2
LZW Its the Code
  • Compression
  • Given a text, at each step
  • generate code (consult table)?
  • update code table
  • are
  • Decompression
  • Given a code, at each step
  • reconstruct the code
  • reconstruct the text
  • are

3
LZW Compression, Decompression
  • a b b a a b b a a b b a b b a

4
LZW Compression Example 1
  • a b b a a b b a a b b a b b a

input text
0 1 1 0 2 4 6 8
coded text
ab 2
bb 3
ba 4
code table
aa 5
abb 6
baa 7
abba 8

5
LZW Decompression Example 1
  • 0 1 1 0 2 4 6 8

coded text
a b b a ab ba abb abba
coded text
2 ab
3 bb
4 ba
code table
5 aa
6 abb
7 baa
8 abba

6
LZW Compression Example 2
  • a a a b b b a a a a b b a a a

input text
0 2 1 4 2 3 1 6
coded text
aa 2
aab 3
bb 4
bba 5
code table
aaa 6
aabb 7
ba 8

7
LZW Decompression Example 2
  • 0 2 1 4 2 3 1 6

coded text
a aa b bb aa aab b aaa
coded text
2 aa
3 aab
4 bb
code table
5 bba
6 aaa
7 aabb
8 ba

8
Try this...
  • code using LZW
  • a b b a b a a b b a b b a b a b b a

9
Whats wrong?
  • 0 2 3 3 2 2
  • 0 2 4 2 1 3

10
Priority Queues - Heaps
  • Priority queue
  • insert
  • deleteMin
  • Heaps
  • One way of achieving priority queues
  • Why not use linked lists?

11
Heaps (contd...)?
  • Heaps
  • binary heaps
  • complete binary tree (so the height is...)?
  • heap order property (what do we gain?)?
  • In minheap,
  • val(parent)
  • val (parent)
  • So, always make sure that heap order property
    holds

12
Why is buildheap linear?
13
insert
  • O(log N)?

14
delete
  • O(logN)?

the thing to remember while deleting from an
arbitrary location, we can move one of two ways
up or down
15
Heaps - Operations
  • decreasekey (p,?)?
  • sift-up
  • increasekey (p,?)?
  • sift-down
  • remove (p)?
  • ??

16
Is the heap representation unique?
  • because...
  • is complete ordering enforced?

17
THANK YOU
Write a Comment
User Comments (0)
About PowerShow.com