Class Util

java.lang.Object
topics.sorting.utils.Util

public class Util extends Object
Helper class to trace and use common operations among sorting algorithms
Author:
vicegd
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    findPosMax(int[] elements, int firstElement)
    Finds the position of the biggest element in the array
    static int
    findPosMin(int[] elements, int firstElement)
    Finds the position of the smallest element in the array
    static void
    interchange(int[] elements, int i, int j)
    Interchanges element i and element j
    static void
    trace(int iteration, int[] elements)
    Logs messages for the sorting algorithm
    static void
    traceMessage(String message, int[] elements)
    Logs string messages for some sorting algorithms
    static void
    traceShellSort(int k, int pos, int[] elements)
    Logs messages for the Shell sorting algorithm

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Util

      public Util()
  • Method Details

    • trace

      public static void trace(int iteration, int[] elements)
      Logs messages for the sorting algorithm
      Parameters:
      iteration - Number of iteration in the algorithm (from 0)
      elements - Array with numbers
    • traceShellSort

      public static void traceShellSort(int k, int pos, int[] elements)
      Logs messages for the Shell sorting algorithm
      Parameters:
      k - Value of the k parameter in the Shell algorithm
      pos - Value for the pos parameter in the Shell algorithm
      elements - Array with numbers
    • traceMessage

      public static void traceMessage(String message, int[] elements)
      Logs string messages for some sorting algorithms
      Parameters:
      message - Message to be logged
      elements - Array with numbers
    • interchange

      public static void interchange(int[] elements, int i, int j)
      Interchanges element i and element j
      Parameters:
      elements - Array with numbers
      i - Position of one element to be interchanged
      j - Position of the other element
    • findPosMin

      public static int findPosMin(int[] elements, int firstElement)
      Finds the position of the smallest element in the array
      Parameters:
      elements - Array with numbers
      firstElement - First element from which it is going to search
      Returns:
      Position of the smallest element
    • findPosMax

      public static int findPosMax(int[] elements, int firstElement)
      Finds the position of the biggest element in the array
      Parameters:
      elements - Array with numbers
      firstElement - First element from which it is going to search
      Returns:
      Position of the biggest element