Sorting In Pascal ProgrammingIn this article I discuss sorting in Pascal programming language. Sorting is a very useful technique that is used vastly in various programs. This is a programming technique that is used to sort a list of prestored data list in a descending or ascending order according to a preset criterion. There exist various sorting methods in Pascal programming that are used according to a given situation. All of these sorting methods are compared to one another using a time unit measure known as the bigO notation. This technique is for measuring the efficiency of an algorithm that performs a particular function over a collection of items of size p. Take an example, the bigO complexity of both the Bubble sort and Insertion Sort is O (p2). Although both do have the same time complexity, Insertion Sort is slower. There are many useful sorting methods. Here we will discuss just a few sorting methods in Pascal Programming. The Bubble Sort algorithm is very simple though also inefficient sorting algorithm. It is not usually the best option to use. This is because its performance at sorting a list of items is extremely slow. In Pascal programming, it is best at sorting a small list of items, but not for large items. For the Bubble sort, the sorting time complexity is O (p2). Another sorting method in Pascal programming is the Insertion Sort algorithm. This one is a bit more efficient algorithm than the Bubble Sort algorithm. As it name implies, the insertion sort algorithm does insert an unsorted item in an item list that is already sorted. This makes one think of the use of two separated arrays  one sorted and the other unsorted. However, to save space one may use the same array and use a pointer to separate the unsorted and sorted elements of the list. In this algorithm, the sorting time complexity is O (p2). Although this is the same as that of the Bubble Sort's, the Insertion Sort algorithm is twice more efficient, and inefficient for large lists. Another algorithm in Pascal programming is the Quick Sort algorithm. This algorithm does seem pretty fast in performance, though it's not easy to implement regardless of the fact that getting the gist of how the Quick sort algorithm works is not that hard. This algorithm does use recursion extensively, so one should ensure he is quite familiar with recursion, and he has used it a lot before he tries to understand this algorithm. The quick sort does work by using a "pivot". This is an index pointer just like the ones that are used in previous sorting algorithms. Its purpose is to divide the list in two halves, one having elements greater than the pivot while the other having elements smaller than the pivot. The pivot is mostly chosen to be the leftmost element of the list. However, it is not necessary and one may decide to choose any random element from the list to be his pivot. by Dewayne Weiss
Related Articles and Readings
The information provided in this article and/or the comments is the sole responsibility of their respective authors and does not necessarily reflect the opinion of ezinepost.com. ezinepost.com does not endorse any article and/or comments published by our web users unless otherwise noted. 
Member Panel
login to submit articles and more
Article Directory
EZINEPOST.COM

