Implementation Of Sorting Algorithms

7 Chapters
|
61 Pages
|
8,596 Words
|

Sorting algorithms are fundamental tools in computer science, employed to arrange elements in a specified order. They play a crucial role in various applications, including data processing, database management, and algorithm design. Implementation of sorting algorithms involves translating the algorithmic logic into executable code to efficiently reorder a collection of items, such as numbers or strings. Key sorting algorithms include insertion sort, selection sort, bubble sort, merge sort, quick sort, and heap sort, each with unique characteristics and performance profiles. For instance, merge sort employs a divide-and-conquer strategy to recursively divide the array into smaller sub-arrays, sorting them individually, and then merging them back together in sorted order, ensuring a time complexity of O(n log n). Conversely, bubble sort repeatedly steps through the list, comparing adjacent elements and swapping them if they are in the wrong order, with a time complexity of O(n^2). Optimization techniques such as adaptive sorting, parallel processing, and hybrid algorithms enhance the efficiency and scalability of sorting implementations, catering to diverse requirements ranging from small-scale applications to large-scale data processing tasks in fields like finance, telecommunications, and scientific computing.

ABSTRACT

This research work took theoretical and empirical studies that have been done over the past years on sorting algorithms and its variants. The study includes a comparative sorting algorithms (i.e. Bubble sort, shell sort, straight insertion sort quick sort, simple sort etc.) the same criteria such as coding memory space used meaning efficiency as in the time used by the computer argument on the number of comparison. Data flow diagrams and process to evaluate the performance of these sorting techniques. The programming language used to implement these sorting algorithms is BASIC.

The various chapter in this research work is logically arranged to reflect in each stage in the research process, the adopting chapters ranges from introduction literature review, systems investigation/analysis, system programming/ implementation to the researchers, recommendations and conclusion. The coded program and its output are also attached.

TABLE OF CONTENT

Title Page
Certification
Dedication
Acknowledgement
Abstract
Table of Content

CHAPTER ONE
1.0 Introduction 1
1.1 Background of the Study 1-3
1.2 Statement of Problem 3-4
1.3 Objective/Purpose of the Study 4
1.4 Significance of the Study 4-5
1.5 Scope and Limitation of the Study 5
1.6 Organization of Work 6

CHAPTER TWO
Review of Related Literature to the Topic 7
2.0 A Reflective View on Sorting 7-8
2.1 Classification of Sorting 8
2.2 Internal Sorting Techniques 9
2.2.1 Bubble Sort 9-10
2.2.2 Heap Sort 11-12
2.2.3 Insertion Sort 13-14
2.2.4 Merge Sort 15-16
2.2.5 Quick Sort 16-18
2.2.6 Selection Sort 18-19
2.2.7 Shell Sort 19-20
2.2.8 Simple Sort 20-22
2.3 External Sorting Techniques 22
2.3.1 Method of External Sort 22-23
2.3.2 Disk Sort 24
2.3.3 Strategies for Choosing Sorting Method 24-25

CHAPTER THREE
3.0 System Analysis and Investigation 26
3.1 Analysis of Sorting Algorithms 26-27
3.2 Memory Space Allocation 27-29
3.3 Comparative Study of the Algorithm 30
3.4 Research Methodology 31-32

CHAPTER FOUR
4.0 Program Design and Implementation 33
4.1 Discussion of Findings 33
4.2 Design of Logic of Sorting Algorithms 34
4.3 Pseudo code of Logic Design 34-36
4.4 Program Flowchart

CHAPTER FIVE
5.0 Recommendation and Conclusion and 43
5.1 Problems Encountered during the
Research work 43
5.2 Conclusion 44
5.3 Recommendation 44-45
Reference 46-56

CHAPTER ONE

INTRODUCTION
1.1 BACKGROUND OF STUDY

The need of information in general
Mangers need information to perform their function and not data. Information is to data what is finished product is to raw materials used in producing it. Information is the manger in his decision-making activity.
Information is to business system what blood circulatory system is to human body. When information fails to reach any part of the organization system, due to structural deficiency, that part become anemia and soon becomes a liability to the rest of the supper system. This is why the system theory states that every system is held together by information exchange.
For information to retain its quality resources it must have the following qualities: Brief/Detail, Accurate, Rare/Scare, Timeliness/Appropriateness, Frequency/Understanding and Transferable.
Computers are virtually used in all areas of life. It is difficult to see any aspect of the society that has not been affected by some form of computerization. Computer is used in preparing company patrol, record customers sales on items bought from a shop switching of telephone class when lines are overload, give detail of dentists, patients, analyze blood samples, control application in homes etc.
Therefore, computers can be in all sectors in the society such as business, health, and industry education, national development. Before the advent of computer manual method was used in data processing and calculators and the human brain were the only thing used.
This manual method is time wasting and mistake oriented. At present the use of computer in data processing has gone a long way in increasing the credibility of the system. The computer is able to process data quickly; making available information on stock levels slow moving items or trend in demand.
A business establishment equally apply computer in the preparation of payroll. When computer is used for this purpose, it helps to ensure efficiency and accuracy in calculation. In science research like medical, it is used for analysis data produced from experiment for instance in the trial of drugs. It is also a diagnostic tool in hospital, clinic and keeping patient.
In every organization especially an open system or social organization, information is very essential. Since what organization needed is information and not data, there is urgency that proper information should be diffused or be circulated within the organization.
Having defined information as the processed data that is meant to be used by the approved user. It is of paramount demand that no decision be taken in an organization without proper consultation of the computer data processing centre. Therefore, any organization that takes decision without computer analysis is prone to error.
In some real life application of computer, example in sorting information in a given order, often known as automation. Information is sorted in alphabetical order, numerical order either ascending or descending. The use of computer in sorting has eliminated the manually performed method, which is prone to error, mistake and time wasting hence the need for its automation. This is aimed at the automation of this manual method hence eliminating and minimizing the error encountered.

1.2 STATEMENT OF PROBLEM
The method of organization of data in the computer is the main focus of this work. Also the, mismanagement of computer memory and time is another problem to look into for solution. It could be recalled that the necessary and efficiency of sorting activities cannot be over emphasized.
However, this project research is aimed at taking a comprehensive look on some sorting algorithms in BASIC programming languages to access their performance. The above mentioned high-level programming language are used or considered for the implementation of the sorting concept.

1.3 OBJECTIVE/PURPOSE OF THE STUDY
This deals with the presentation of information or data in an appreciable from and also to minimize the time used in searching for items. However, it can be seen that a well-sorted or organized file enhances easy searching of data while unsorted one will pose little or great problem to locate a given item in a large list. However, the comparison process will be based on the following:
(i) Memory space used
(ii) Number of comparison made during sorting process
(iii) Coding based on the sorting algorithm
(iv) Computer.

1.4 SIGNIFICANCE OF THE STUDY
Sorting algorithm was designed to enable the people and the society to be acquainted with arrangement of data and item. Above topic of discussion will make the society to determine and know their stand in the arrangement and organization of data in the memory location and also make proper use and utilization of the computer time.

1.5 SCOPES AND LIMITATION OF THE STUDY
As was stated earlier, it is quite understood that there are lots of sorting technique. This project research will be focusing on the implication of some algorithms. It will also be critically base on the following.
a. The use of linear list (array) as the data structure.
b. Insertion sort, bubble sort, selection sort etc.
c. The use of BASIC as the programming language for coding implementation.

This research work was limited by some ups and downs, which was encountered at the process of carrying out the research. Some of the problems that limited the finding of research work are as follow:
(a) Lack of resourceful library for material that would aid further investigations and finding.
(b) Limited time to carryout more research as the research work is coupled with the other academic statues.
(c) Financial instability, which constituted more to the limitation as related to the movement from one place to another for materials for further aids towards the topic of discussion.

1.6 ORGANIZATION OF WORK
This is a project work that is written to analyze the implementation of sorting algorithm. This project is divided into five chapters. Chapter one is the introduction; chapter two is the literature review of the project topic under discussion. Chapter three is the research methodology; chapter four is the analysis of the technical procedures and various methods of data presentation/programs while chapter five is the summary conclusion and recommendation.

 

 

Save/Share This On Social Media:
MORE DESCRIPTION:

Sorting Algorithms:

Sorting algorithms are a fundamental part of computer science and are used to arrange a collection of elements in a specific order, typically in ascending or descending order. There are various sorting algorithms, each with its own advantages and disadvantages in terms of time complexity, space complexity, and stability. Here are some commonly used sorting algorithms:

  1. Bubble Sort:
    • Bubble sort repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.
    • Time Complexity: O(n^2) in the worst and average case, O(n) in the best case (when the list is already sorted).
  2. Selection Sort:
    • Selection sort divides the input list into two parts: the sorted part and the unsorted part. It repeatedly selects the smallest (or largest) element from the unsorted part and moves it to the sorted part.
    • Time Complexity: O(n^2) in all cases, making it inefficient for large lists.
  3. Insertion Sort:
    • Insertion sort builds the sorted array one item at a time. It takes each element from the unsorted part and inserts it into its correct position in the sorted part.
    • Time Complexity: O(n^2) in the worst and average case, O(n) in the best case (when the list is already sorted).
  4. Merge Sort:
    • Merge sort is a divide-and-conquer algorithm that recursively divides the input into smaller subproblems, sorts them, and then merges the sorted subproblems back together.
    • Time Complexity: O(n log n) in all cases, making it more efficient than the previous three for large lists.
  5. Quick Sort:
    • Quick sort is another divide-and-conquer algorithm that selects a ‘pivot’ element and partitions the list into two sublists: elements less than the pivot and elements greater than the pivot. It then recursively sorts the sublists.
    • Time Complexity: O(n^2) in the worst case, but on average, it has a time complexity of O(n log n). It’s often faster in practice than merge sort or heap sort due to its smaller constant factors.
  6. Heap Sort:
    • Heap sort first builds a binary heap data structure from the input array and then repeatedly extracts the maximum (for max-heap) or minimum (for min-heap) element from the heap and adds it to the sorted portion.
    • Time Complexity: O(n log n) in all cases. It has a slightly worse constant factor than merge sort but is often used when memory usage is a concern.
  7. Radix Sort:
    • Radix sort is a non-comparative integer sorting algorithm that sorts data with integer keys by grouping digits together. It can be used for sorting integers, strings, or other data types.
    • Time Complexity: O(n * k), where n is the number of elements, and k is the number of digits or characters in the keys.
  8. Counting Sort:
    • Counting sort is a non-comparative integer sorting algorithm that works by counting the number of occurrences of each element and then placing them in the correct order.
    • Time Complexity: O(n + k), where n is the number of elements, and k is the range of input values.

The choice of sorting algorithm depends on various factors, including the size of the dataset, the characteristics of the data, memory constraints, and the need for stability (i.e., whether the algorithm preserves the relative order of equal elements). Different algorithms may be more suitable for different scenarios.