data Flashcards

1
Q

important of Huffman coding

A

1) it is an algorithm to compress data
2) it applies compression algorithm to take a large file and store it as a smaller set of data
3) it applies decompression algorithm to take smaller compressed data and get the original back

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

methods for data compression

A

1) Use ASCII Code - each character takes 8-bits
2) Use 3-bit to encode each character
3) Use Huffman Code
- use variable length code
- use fewer bits for more frequently occuring characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Calculate memory of Huffman Code

A

1) File Size: Frequency * number of bits
2) Table Size: (Frequency * 8) + (number of total bits)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

List 4 types of Shortest Path Problem

A

1) Single Source: Find a shortest path from a given source to each vertex
2) Single Destination: Find a shortest path to a give destination from each vertex
3) Single Pair: Find a shortest path from a to t, for given vertices a and t in a graph
4) All Pairs: Find a shortest path for every pair of vertice in graph

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Compare Dijkstra and Floyd Algorithm

A

similarity = can support both direct and non directed graoh

dijkstra = non negative weight

floyd = can support negative weight
= assume non-negative cycles

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

the time complexity for Dijkstra Algorithm using Adjacency Matrix, Min Heap,

time complexity for Floyd Algorithm

A

1) Adjacecny Matrix = O(V2)
2) Min Heap Adjacency List = O(E(log V)

3) Floyd = O(V3)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Types of Minimum Spanning Tree & their Time Complexity

A

1) Prim’s O(1)
2) Kruskal’s O(n2)
min heap > O(nlogn)

3) Topological Sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Important of knowing whether it is a spare/dense graph

A

1) it affects the choice of data structure to represent graph
2) it affects the choice of algorithm to process graph

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Advantages of Adjacency Matrix Representation

A

1) Simple and Clear
2) O(1) to check whether any 2 vertices have edges connecting to them
3) O(V) to find all adjacent vertices of V

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Disadvantages of Matrix Representation

A

1) Waste of time and space on Sparse Graph

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Advatages of Adjacency List

A

1) O(V) time to find all the adjacent vertices of V
2) Space efficient of Sparse Graph

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Disadvantages of Adjacency List

A

1) O(V) time to check whetehr any 2 vertices have edges connecting them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Definition of Sparse & Dense Graph

A

Sparse
- number of edges is closer to the number of vertices

Dense
- number of edges is closer to the sequared of number of vertices

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Definition of Strongly connect Graph, Weakly Connected Graph and Complete Connected Graph

A

Strongly Connected Graph
- There is a path for every vertices to every other vertices in directed graph

Weakly Connected Graph
- There is a path for every vertices to every other vertice ignoring the direction of edge

Complete Connected Graph
- For every pair of vertices, u not equal to v, there exist an edge from u to v

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly