Example #1
0
        static void Main(string[] args)
        {
            NumberOfIslands number = new NumberOfIslands();

            Console.WriteLine(number.IslandCount());

            SpiralPrint sp = new SpiralPrint();

            sp.Print();

            PascalTriangle pt = new PascalTriangle();

            pt.Generate(6); pt.Print();

            MedianOfSortedArrays ms = new MedianOfSortedArrays();

            Console.WriteLine(ms.MedianOf2SortedArrays(ms.array1, ms.array2));

            FindtheMissingNumber fn = new FindtheMissingNumber();

            Console.WriteLine(fn.FindtheMissingNumberMethod1());

            ContainsDuplicate cd = new ContainsDuplicate();

            Console.WriteLine(cd.isDuplicateMethod2());

            ReversedLinkedList rl = new ReversedLinkedList();

            rl.reversedList();

            ReverseNumber rn = new ReverseNumber();

            rn.ReverseANumber(12345);

            LinearSearch ls = new LinearSearch();
            BinarySearch bs = new BinarySearch();

            ZigZag zz = new ZigZag();

            Console.WriteLine(zz.Convert("PAYPALISHIRING", 3));

            BinaryTree bt = new BinaryTree();

            bt.InorderTraverse(bt.root);
            Console.WriteLine();
            bt.PreorderTraverse(bt.root);
            Console.WriteLine();
            bt.PostorderTraverse(bt.root);

            RotateArray ra = new RotateArray(3);
            //SearchRotatedArray sr = new SearchRotatedArray(3);
            //Console.WriteLine(sr.Find());

            FindSumSarray  fS    = new FindSumSarray();
            MaxSumSubArray mxSum = new MaxSumSubArray();
        }
Example #2
0
        private static void LinearSearch()
        {
            int[] arr   = { 2, 3, 4, 7, 9, 10, 15, 18, 40 };
            int   index = 7;

            var linearSearch = new LinearSearch();

            int result = linearSearch.Search(arr, index);

            if (result == -1)
            {
                Console.WriteLine("Element is not present in array");
            }
            else
            {
                Console.WriteLine("Element is present at index " + result);
            }
        }