Example #1
0
        public static int Sum(LinkedList A)
        {
            int sum = 0;

            for (LinkedList.Node pA = A.Head; pA != null; pA = pA.next)
            {
                sum += pA.data;
            }
            return(sum);
        }
Example #2
0
        public static int ListSum(this LinkedList list)
        {
            int sum = 0;

            for (LinkedList.Node p = list.Head; p != null; p = p.next)
            {
                sum += p.data;
            }

            return(sum);
        }
Example #3
0
        public static int CountDiffMinMax(LinkedList A)
        {
            int max = A.Head.data;
            int min = A.Head.data;

            for (LinkedList.Node pA = A.Head; pA != null; pA = pA.next)
            {
                if (pA.data > max)
                {
                    max = pA.data;
                }
                if (pA.data < min)
                {
                    min = pA.data;
                }
            }
            return(max - min);
        }