Skip to content

Commit

Permalink
changed notes
Browse files Browse the repository at this point in the history
  • Loading branch information
fergalhennessy committed Jan 9, 2024
1 parent 32a5626 commit 6da10f5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/_notes/Public/(LC1) Merge K Lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public:
};
```

Runtime Analysis: Assuming *k* lists with an average size of *n*, we note that the first merger has *2n* comparisons, the second *3n*, and so on until the final list has *(k+1)n* comparisons for a total O(k^2\*n) runtime
Runtime Analysis: Assuming *k* lists with an average size of *n*, we note that the first merger has *2n* comparisons, the second *3n*, and so on until the final list has *(k+1)n* comparisons for a total $$O(k^2\*n)$$ runtime

It's possible to do better with this pairs strategy by using a queue: we can merge lists of the same size and push the resulting bigger list to the back of a queue. Using this strategy, our runtime is *O(n\*k\*log(k))*.

Expand Down

0 comments on commit 6da10f5

Please sign in to comment.