Procedure greedy var G GRAPH var newclr SET
- Slides: 24
שפה - כתיבת הפתרון בפסאודו Procedure greedy (var G: GRAPH; var newclr: SET) {greedy assigns to newclr a set of vertices that may be given the same color} begin (1) newclr : = (2) for each uncolored vertex v of G do (3) if v is not adjacent to any vertex in newclr then begin (4) mark v colored (5) add v to newclr end; {greedy} 2 Data Structures, CS, TAU - 2. 2
עידון האלגוריתם להשגת תוכנית . (3 מציאה אם צומת שכן )שורה : דוגמא (if v is not adjacent to any vertex in newclr then begin) (3. 1) found : = false; (3. 2) for each vertex W in newclr do (3. 3) (3. 4) if there is an edge between V and W in G then found : = true; (3. 5) if found = false then begin (4). (5) 3 Data Structures, CS, TAU - 2. 1
דוגמא Procedure bubble var i, j, temp : integer begin (1) for i : = 1 to n-1 do (2) for j : = n downto i+1 do (3) if A[j-1] > A[j] then begin {swap A[j-1] and A[j]} (4) temp : = A[j-1]; (5) A[j-1] : = A[j]; (6) A[j] : = temp; end; {bubble} 10 Data Structures, CS, TAU - 2. 9
( חישוב עצרת )רקורסיבי : דוגמא Function fact (n: integer) begin (1) if n<=1 then (2) fact : = 1 else (3) fact : = n*fact(n-1) end; {fact} d T(n) = c + T(n-1) T(n) = 2 c+T(n-2) T(n) = 3 c+T(n-3) T(n) . . . =. c(n-1)+T(1)=c(n-1)+d=O(n) 11 Data Structures, CS, TAU - 2. 10
ציור מדדי סיבוכיות cg(n) f(n) cg(n) n 0 c 2 g(n) c 1 g(n) c 2 g(n) f(n) c 1 g(n) n 0 14 Data Structures, CS, TAU - 2. 13
1 דוגמא a b f(n) 22 Data Structures, CS, TAU - 2. 21
2 דוגמא a b f(n) 2 מקרה 23 Data Structures, CS, TAU - 2. 22
a 3 דוגמא b f(n) : 3 מקרה : גדול n עבור 24 Data Structures, CS, TAU - 2. 23
- Total set awareness set consideration set
- Training set validation set test set
- Söz var kəsdirər başı söz var kəsər savaşı
- Instruments are set up on the dental procedure tray
- Bounded set vs centered set
- Crisp set vs fuzzy set
- Crisp set vs fuzzy set
- Crisp set vs fuzzy set
- What is the overlap of data set 1 and data set 2?
- The function from set a to set b is
- What is an independent set in a graph
- Define graph coloring
- Graph set up
- Handshaking theorem
- Resource allocation graph and wait for graph
- The greedy snake
- Greedy marker
- Greedy best first search
- Metoda greedy probleme rezolvate
- Contoh soal metode greedy
- Contoh soal metode greedy
- Kassim and the greedy dragon
- Greedy algorithm
- Greedy algorithm
- Greedy algoritmus