Why SortedSet.GetViewBetween isn’t O(log N)?

about the version field UPDATE1: In my memory, a lot of (maybe all?) collections in BCL have the field version. First, about foreach: according to this msdn link The foreach statement repeats a group of embedded statements for each element in an array or an object collection. The foreach statement is used to iterate through the collection to get … Read more

What is the best way to get the minimum or maximum value from an Array of numbers?

The theoretical answers from everyone else are all neat, but let’s be pragmatic. ActionScript provides the tools you need so that you don’t even have to write a loop in this case! First, note that Math.min() and Math.max() can take any number of arguments. Also, it’s important to understand the apply() method available to Function … Read more

Java: what’s the big-O time of declaring an array of size n?

It’s O(n). Consider this simple program: public class ArrayTest { public static void main(String[] args) { int[] var = new int[5]; } } The bytecode generated is: Compiled from “ArrayTest.java” public class ArrayTest extends java.lang.Object{ public ArrayTest(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/Object.”<init>”:()V 4: return public static void main(java.lang.String[]); Code: 0: iconst_5 1: … Read more