Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 82288

An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem. Use this tag when your issue is related to design and analysis of algorithms.

1 vote

Finding all vertices on negative cycles

Update I just realized that my answer below may be incorrect. The intended idea was to perform |V|-1 waves of "relaxation", as in Bellman-Ford (see CLRS). At the end, instead of returning FALSE to den …
xdavidliu's user avatar
  • 858
2 votes
1 answer
903 views

monotonically increasing codeword length in optimal (maybe Huffman) code for alphabet with m...

I'm working on exercise 16.3-5 of CLRS: Prove that if we order the characters in an alphabet so that their frequencies are monotonically decreasing, then there exists an optimal code whose codewor …
xdavidliu's user avatar
  • 858
2 votes

monotonically increasing codeword length in optimal (maybe Huffman) code for alphabet with m...

I misunderstood the phrase "monotonically increasing". It actually means the same thing as "non-decreasing", as explained on p 53 of the book. The phrase is different from "strictly increasing", also …
xdavidliu's user avatar
  • 858
1 vote
0 answers
208 views

why does message authentication using 2-universal family of hash functions require a prime n...

I am self-studying the book Intro to Algorithms 3ed by CLRS. …
xdavidliu's user avatar
  • 858
3 votes

how to bound the probability that quicksort takes greater than n lg n time?

Here's a possible answer to the original CLRS question itself, based on the outline provided in the accepted answer above. Let $X_n$ be the random variable indicating the height of a randomly-built b …
xdavidliu's user avatar
  • 858
2 votes
2 answers
2k views

how to bound the probability that quicksort takes greater than n lg n time?

I am working on exercise 12.4-5 of CLRS (Cormen et al, Intro to Algorithms 3rd ed) Consider RANDOMIZED-QUICKSORT operating on a sequence of n distinct input numbers. … Algorithms 21 (1996), 476-507. I hunted down the Karp paper, and it indeed proves the result from the Knuth problem. …
xdavidliu's user avatar
  • 858
7 votes

Algorithm to find diameter of a tree using BFS/DFS. Why does it work?

Update 3 and corrected answer There's an error in the linked solution set (see update 2 below), but it can be easily corrected with @Yuval Filmus's suggestion in the question's comment, which further …
xdavidliu's user avatar
  • 858