Data Structures and Algorithms

0.0(0)
studied byStudied by 2 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/52

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

53 Terms

1
New cards

True, AVL Tree are more balanced than Red-Black Tree

2
New cards

BFS用?實作

Queue

3
New cards

DFS用?實作

Stack

4
New cards

List can be constructed to a BST with worst case O(n)

False, skewed tree will have worst case O(n2)

“The height of tree is n and there are n elements“

5
New cards
Quick Sort: Best/Avg/Worst(when?)

O(nlogn)/O(nlogn)/O(n^2). When the data are sorted

6
New cards

Merge Sort: Best/Avg/Worst

O(nlogn)/O(nlogn)/O(nlogn)

7
New cards
Insertion Sort:Best(when?)/Avg/Worst

O(n)/O(n^2)/O(n^2)/  when the data are sorted

8
New cards

Selection Sort:Best/Avg/Worst

O(n^2)/O(n^2)/O(n^2)

9
New cards
Which is not stable sorting algorithm: Bubble,Insertion,Selection,Merge,Quick,Heap,Counting,Radix,Bucket
Selection,Quick,Heap
10
New cards

If a weighted graph with weight w_i\geq0  , then if a new graph with w_i+M,M\geq0 , the shortest path will remain the same.

False, 如果該shortest path有比較多edge,則他有可能不復為最短路徑
11
New cards
Have Euler Circuit
Every nodes have even degree
12
New cards
Have Euler Path
Only 2 nodes have odd degree
13
New cards
Preorder
中左右
14
New cards
Inorder
左中右
15
New cards
Postorder
左右中
16
New cards
Time complexity of 0-1 knapsack
O(nW) w is the size of the backpack
17
New cards

Time complexity for k-coloring problem when
1. k <= 2 
2. k >=3 

1.O(V+E) ( 判斷是否為二分圖)
2. NP-C

18
New cards
二分圖一定沒有 WHAT?
奇環
19
New cards

B tree with Degree = T

degree=\lceil\frac{order}{2}\rceil

Max Child = 2t; Min child = t
Max Key = 2t-1; Min Key = t-1

20
New cards

It’s possible to run radix sort in linear time with respect to the length of the list

"True, but only when the length of elements are all fixed, otherwise it will be O(kn) k for digit,n for # of elements"

21
New cards

AD

22
New cards

Time Complexity of Floyd Warshall

O(V^3)

23
New cards

Time Complexity of Dijsktra

O(VlgV+E) using Fibonacci Heap

O(VlgV+ElgV) using Binary Heap

24
New cards

Time Complexity of Bellman Ford

O(VE)

25
New cards

Conversion between Red-Black Tree and 2-3-4 Tree

紅節點與父節點合併,black depth為height

26
New cards

False, Trie不是BST

27
New cards

m-nary tree has how many Internal and External node

L=(m-1)I+1
|E|=n-1=I+L-1

N=mI+1

28
New cards

Every tree is a bipartite graph

True

29
New cards

An AVL tree with height = h has node’s n >= ?

n\geq F_{h+2}-1

30
New cards

Time Complexity of Strassen’s Matrix Multiplication

O(n^{log_{2}{7}})

31
New cards

The number of degree 0 nodes in a tree

#deg(2)+1

32
New cards

B+ Tree

A B tree that store data only in leaf, 利於執行連續搜尋3

33
New cards

The number of spanning in complete graph K_n

n^{n-2}

34
New cards

DP/Divide and Conquer

DP問題有重複

35
New cards

Rabin-Karp

利用Hash

36
New cards

Boyer-Moore

利用Bad/Good Character

37
New cards

n^k k>1

比任何nlog^t(n)還要成長的快

38
New cards

Topological Sort

Kahn’s Algorithm,每次取出只出不進的點

39
New cards

Deletion for BST/AVL

補上Inorder Successor

40
New cards

Number of Node in a full BST with L leaf nodes

N=2L-1

41
New cards

For a bipartite graph to have Hamilton Path

|M-N| = 1

42
New cards

# of invalid stack sequence

Catalan Number

43
New cards

B tree with Order = M

Max Child = M; Min Child = ceil(M/2)

Max Key = M-1; Min Key = ceil(M/2)-1

44
New cards

Extended Master Therom

Let\ T(n)=aT(\frac{n}{b})+n^Elog^kn
1.n^{log_b^a}=n^E
2.k<(-1)=>O(n^E)
3.k=(-1)=>O(n^Elog(logn))

4.k>(-1)=>O(n^Elog^{k+1}n)

45
New cards

Q_{n+1}\ has\ V_{n+1}=?\ E_{n+1}=?

Q_n+1為兩個Qn再補上缺的邊=>V_{n+1}=2V_{n},E_{n+1}=2E_{n}+V_{n}

46
New cards

Find a longest simple path between two nodes (positive edge weights)

NP-H

47
New cards

Find a shortest simple path... with negative weight cycles

NP-H

48
New cards

Find a positive weight directed cycle

P

49
New cards

Find a largest cycle in a graph (edge-weight 1)

NP-H

50
New cards

Find a smallest cycle in a graph (edge-weight 1)

P

51
New cards

Find a maximum cut in a flow network

NP-H

52
New cards

The 2-CNF-Satisfiability problem

P

53
New cards

3-SAT

NP-C