KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Someone asked me a brainteaser, and I don't know; my knowledge slows down after amortized analysis, and in this case, this is O(n). public int findMax(array) { int count = 0; int max = array[0]; for (int i=0; i<array.length; i++) { if (array[i] > max) { count++; max = array[i]; } } return count; } What's the expected value of count for an array of size n? Numbers are randomly picked from a uniform distribution.
Tags (comma-separated)
Save Edits
Cancel