View Single Post
  #4  
Old 08-07-2018, 11:25 AM
maskedmelon maskedmelon is offline
Planar Protector

maskedmelon's Avatar

Join Date: Nov 2011
Location: not far from here
Posts: 5,793
Default

forgot to mention, the constant time assumes there is no exception thrown. if there is an exception thrown then the cost would be linear time as a function of th number of instructions in the block, no? Basically if an exception is thrown near the end of a try catch block, then you wasted a bunch of time that could have been saved by one or more conditionals (unless it can't be results over that way). I'd think it'd be more common for an exception to be thrown at the beginning of a try block though since it isn't really used unless you expect a potential exception throw in the next line of code. And, if you expect exceptions later on, you'd have to introduce conditionals to resolve those if you didn't use a try-catch block, no?
__________________
<Millenial Snowfkake Utopia>