Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Posted 20 March 2014 - 12:22 AM

Anyone can recommend an awesome useful and clear discrete math/ discrete structures textbook?


I'm using Discrete Mathematics And Its Applications 7th Edition by Kenneth Rose. I don't like a lot of the examples mainly because the author assume you know what he is thinking to achieve his steps in his examples.


Anyone can recommend an awesome textbook they have used for this subject? I am struggling with this textbook.


Posted 19 March 2014 - 09:12 PM

Suppose an algorithm goes through a list of n integers and for every iteration of the loop it is needs to check if the current evaluated element of the list is even. If it is even, return the index of the integer that is evaluated as even.


How come the algorithm would have 2n + 1 comparison instead of n + 1 comparison?


I thought linear search would have n comparision because it is going through n elements. + 1 comparison for the if statement. So that would make the algorithm O(n+1) comparision, no?. Where did the extra n come from?



procedure last_even_loc(a1,a2,...,an:integers);
location = 0;
for i = 1 to n if(a_i = 0) (mod 2) then location = i
return location;