Monday, 28 July 2014

COBOL Sort Merge File Description.

Sorting means reorganizing the data in such as way that it is in the order of smallest to largest. Sorting is one of the most important issues in data structures and computing. Data is regularly sorted before being sorted, as it can then very efficiently be retrieved, be it a collection of names, telephone numbers, or items on a simple to-do list. 

In this chapter, we compare different sorting algorithms by considering their asymptotic behavior. Some of the algorithms are relatively easy to develop, but may perform poorly, whereas other algorithms are slightly more complex to implement, but show good performance in sorting the list when we have a long lists. 

After sorting, it becomes much easier to conduct search operations on a collection of items. We'll start with the simplest of all sorting algorithms; that is, the bubble sort algorithm.

An illustration with an example

Sorting means arranging all the items in a list in ascending order of their magnitude. We will be discussing some of the most important sorting algorithms, which each have different performance attributes with respect to runtime complexity. Sorting algorithms are categorized by their memory usage, complexity, recursion, and whether they are comparison-based, among other considerations.

Some of the algorithms use more CPU cycles, and, as such, have bad asymptotic values. Other algorithms chew on more memory and other computing resources as they sort a number of values. Another consideration is how sorting algorithms lend themselves to being expressed recursively, iteratively, or both. There are algorithms that use comparison as the basis for sorting elements. An example of this is the bubble sort algorithm. Examples of a non-comparison sorting algorithm are the bucket sort and pigeonhole sort algorithms.

Sort File : A collection of records to be sorted by a SORT statement. The sort file is created and can be used by the sort function only.
An entry in the file section of the data division that is composed of the level indicator SD, followed by a file-name, and then followed clauses that describe the attributes of the SORT-MERGE file.

To code a file description for a sort work file, you use an SD statement as shown in below example. The syntax of this statement is the same as the FD statement except that you can’t code a Block Contains clause. That’s because the blocking for this file is determined by the sort program.
After the SD statement for the sort work file, you code a record description just as you do for any other file. The only requirement is that the record description must contain the key fields that the sort will be based on. These fields will be named in the Sort statement, as you’ll see in a moment.
Sub Topics
Example :

In this chapter, we explored a number of important and popular sorting algorithms, which are very useful for many real-world applications. We discussed bubble sort, insertion sort, selection sort, quick sort, and heap sort algorithms, along with the explanation of their implementation in Python. Quick sort performs much better than the other sorting algorithms. Of all the algorithms discussed, quick sort preserves the index of the list that it sorts. We'll use this property in the next chapter as we explore the selection algorithms.

Created with Artisteer

No comments:

Post a comment