Header Image
Creative Commons image courtesy of Flickr user StormPetrel1-
Recent Posts
Recent Comments
- In the Spotlight: MAT2540 – Discrete Structures and Algorithms II – The Open Road on Links
- OpenLab Workshop for Opening Gateways Fellows | 2018-2019 Opening Gateways Faculty Seminar on Final Exam Review
- Eric on Eric’s Final Review
- Kate Poirier on Hints/reminders from today’s class
- Kate Poirier on Final Exam Review
Archives
Categories
Meta
Review
This entry was posted in Test #1 Review. Bookmark the permalink.
if ai is even then ai>=m??
I don’t understand that line. Why did you put condition with another condition, after the then statement, there should be a assignment statement (“=”).
it should be
if ai is even
if p = 0
m = ai
p = i
else if ai>m
m = ai
p = i
sorry for some reason the blog doesn’t show the tab space
sorry for some reason the blog doesn’t show the tab space
sorry for some reason the blog doesn’t show the tab space
Sorry, I don’t know how to delete the repeat comment and for some reason it post 3 times.
I think Benjamin is onto something here; the “if/then” statement is confused here. Probably you wanted something more like, “if is even and , then…” It looks like you’ve also used “P” and “m” to stand for the same thing, so it’s hard to tell what this algorithm would actually return.