Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| courses:cs211:winter2012:journals:jeanpaul:chaptter2section4 [2012/01/24 13:07] – [Linear Time O(n)] admin | courses:cs211:winter2012:journals:jeanpaul:chaptter2section4 [2012/01/24 23:11] (current) – mugabej | ||
|---|---|---|---|
| Line 11: | Line 11: | ||
| * Computing the Maximum | * Computing the Maximum | ||
| - | algorithm: | + | algorithm: |
| + | | ||
| for i = 2 to n: \\ | for i = 2 to n: \\ | ||
| - | if a< | + | |
| - | set max = a< | + | set max = a< |
| - | | + | Endif \\ |
| Endfor \\ | Endfor \\ | ||
| - | | ||
| - | **Professor Sprenkle' | ||
| - | < | + | Merging Two Sorted lists |
| - | algorithm: | + | |
| - | for i = 2 to n: | + | |
| - | if a< | + | |
| - | set max = a< | + | |
| - | | + | |
| - | Endfor | + | |
| - | </ | + | |
| - | + | ||
| - | * Merging Two Sorted lists | + | |
| - | algorithm: | + | algorithm: |
| To merge sorted lists A = a< | To merge sorted lists A = a< | ||
| Line 75: | Line 65: | ||
| algorithm: | algorithm: | ||
| - | for each set S< | + | for each set S< |
| for each other set S< | for each other set S< | ||
| for each element //p// of S< | for each element //p// of S< | ||
| Line 84: | Line 74: | ||
| | | ||
| | | ||
| - | Endfor | + | |
| =====O(n^k) Time===== | =====O(n^k) Time===== | ||
| Line 93: | Line 83: | ||
| Algorithm: \\ | Algorithm: \\ | ||
| - | for each subset S of k nodes \\ | + | |
| - | check whether S constitutes an Independent set \\ | + | check whether S constitutes an Independent set \\ |
| - | if S is an Independent set then \\ | + | if S is an Independent set then \\ |
| - | | + | |
| - | Endif \\ | + | Endif \\ |
| - | Endfor \\ | + | Endfor \\ |
| - | if no k-node independent set was found then \\ | + | if no k-node independent set was found then \\ |
| - | | + | |
| - | Endif \\ | + | Endif \\ |
| Line 109: | Line 99: | ||
| Algorithm: \\ | Algorithm: \\ | ||
| - | for each subset S of nodes \\ | + | |
| - | check whether S constitutes and independent set \\ | + | |
| - | If S is a larger independent set than the largest seen so far, then \\ | + | |
| | | ||
| - | | + | Endif \\ |
| - | Endfor \\ | + | Endfor \\ |
| The running time of this brute-force algorithm is O(n²2< | The running time of this brute-force algorithm is O(n²2< | ||
