logo

Sorting and Search Algorithms in C Programming

   

Added on  2022-10-15

11 Pages1306 Words352 Views
TEMAOS [Company address]
C PROGRAMMING
Sorting and Search Algorithms in C Programming_1
1
Table of Contents
Introduction..........................................................................................................................................2
Sorting algorithms...............................................................................................................................3
Search algorithms................................................................................................................................5
Conclusion............................................................................................................................................8
References.............................................................................................................................................9
pg. 1
Sorting and Search Algorithms in C Programming_2
2
Introduction
The project is based on human-computer interaction which is used to determine
how competent humans are when interacting with a computer screen. For the
sorting algorithms, an array or a list of elements is provided as come parameter.
A comparison factor is then used as part of the elements. The comparison factor
is then used to determine the order of the new elements using a data structure of
choice. The structure is defined which is used to store the information about the
array elements. The sorting and search algorithms use a different order to
arrange the items. Such that the items can be arranged in ascending or
descending order depending on the order of choice and the number of elements
that are found in the array.
pg. 2
Sorting and Search Algorithms in C Programming_3
3
Sorting algorithms
1. Selection Sort
This algorithm is used to sort the elements that are found in the array by using a
loop to find the minimum element using the unsorted array and putting the
minimum element at the beginning of the array. The array is first divided into
two subarrays with each array containing a reference of the main array. The
subarrays are maintained by the algorithm for the given array until sorting all of
the elements in the array is done (Friedman, 2018). The sorting of the elements
in the array is done by using a repetitive method which loops over the elements,
each time determining the smallest element in the array and putting the element
in the lowest index of the array. Once all the elements of the main array are
sorted, then the subarrays are joined to form the sorted array.
During the procedure, there are two types of arrays which include the sorted
arrays contained in the sub-arrays and the remaining unsorted arrays.
The time complexity for the selection sort algorithm used O(n2) since in the main
loop there contains other two nested loops which are used to move through the
elements determining the smallest element among the given array (Mahdavi,
Fesanghary & Damangir, 2017).
During each of the iterative steps involved, the minimum element from the array
I picked and the array is moved to the sorted subarray which contains other
elements from the main array.
Successive sort of the elements in the array involves selecting all the elements
from the main array and moving them into the sorted subarray which contains
other elements from the unsorted array.
An example showing the operations that are performed:
arr[] = 64 25 12 22 11
pg. 3
Sorting and Search Algorithms in C Programming_4

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Database Programming Assignment
|7
|863
|325

THE ARTIFICIAL INTELLIGENCE
|9
|1495
|22

Using Arrays for Sorting in Bash - Desklib
|7
|3564
|331

AVL Tree, Set Intersection Algorithms, Sloppy Inc. Communication, Array Search
|9
|2413
|78

Desklib SEO Suggestions
|9
|2414
|194

Problem Solving And Programming
|12
|1746
|50