コード例 #1
0
ファイル: Program.cs プロジェクト: onegronm/algorithms-python
        /*
         * a single doubling append is an O(n) time operation since we have to
         * copy all n items from our array.
         *
         * while the time cost of each special O(n) doubling append doubles
         * each time, the number of O(1)O(1) appends you get until the next
         * doubling append also doubles.
         *
         * This kind of "cancels out," and we can say each append has an average
         * cost or amortized cost of O(1).
         *
         * If we were worried about that O(n)O(n)-time worst-case cost of appends,
         * we might try to use a normal, non-dynamic array.
         *
         * The advantage of dynamic arrays over arrays is that you don't have to
         * specify the size ahead of time, but the disadvantage is that some appends
         * can be expensive. That's the tradeoff.
         *
         * - Can we solve the problem in one pass?
         * - Is the input random? Does it require sorting?
         *
         *
         */


        static void Main(string[] args)
        {
            ArraysAndStrings arraysAndStrings = new ArraysAndStrings();

            arraysAndStrings.Run();

            MergingMeetingTimes.Merge_ranges(new List <Meeting> {
                new Meeting(0, 1), new Meeting(3, 5), new Meeting(4, 8), new Meeting(9, 10)
            });

            MergingMeetingTimes.Merge_ranges_extra_space(new List <Meeting> {
                new Meeting(0, 1), new Meeting(3, 5), new Meeting(4, 8), new Meeting(9, 10)
            });

            Console.Read();
        }
コード例 #2
0
 public void Prepare()
 {
     tested = new ArraysAndStrings();
 }