Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need the report like this (idea) *Sorting Algorithms: A sorting algorithm is an algorithm that puts elements of a list in a certain order.

I need the report like this (idea) *Sorting Algorithms: A sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order and lexicographical order. Efficient sorting is important for optimizing the use of other algorithms (such as search and merge algorithms) which require input data to be in sorted lists; it is also often useful for canonical zing data and for producing human-readable output. More formally, the output must satisfy two conditions: 1. The output is in no decreasing order (each element is no smaller than the previous element according to the desired total order). 2. The output is a permutation (reordering) of the input. Further, the data is often taken to be in an array, which allows random access, rather than a list, which only allows sequential access, though often algorithms can be applied with suitable modification to either type of data. Some Popular Sorting Algorithms: Selection sort: Selection sort is an in-place comparison sort. It has complexity, making it inefficient on large lists, and generally performs worse than the similar insertion sort. Selection sort is noted for its simplicity, and has performance advantages over more complicated algorithms in certain situations. Merge sort: Merge sort takes advantage of the ease of merging already sorted lists into a new-sorted list. It starts by comparing every two elements (i.e., 1 with 2, then 3 with 4...) and swapping them if the first should come after the second. It then merges each of the resulting lists of two into lists of four, then merges those lists of four, and so on; until at last two lists are merged into the final sorted list. Heap sort: Heap sort is a much more efficient version of selection sort. It also works by determining the largest (or smallest) element of the list, placing that at the end (or beginning) of the list, then continuing with the rest of the list, but accomplishes this task efficiently by using a data structure called a heap, a special type of binary tree. Once the data list has been made into a heap, the root node is guaranteed to be the largest (or smallest) element. When it is removed and placed at the endp of the array). Instead of searching an array as a whole, the bubble sort works by comparing adjacent pairs of the objects in the array. If the objects are not in the correct order, they are swapped, so that the largest of the two moves up. This process continues until the largest of the objects, eventually bubbles up to the highest position in the array. After this occurs, the search for the next largest object begins. The swapping continues until the whole array is in the correct order. * How Bubble Sort works? The process is simple, you keep comparing pairs of adjacent elements of the sequence, if the they are in the wrong order swap them and do this till there are no swapping to do. Ex: Sort an array {5, 3, 1, 4, 2} using Bubble Sort {5,3,1,4,2} Compare first two, as 5 > 3, they are swapped {3,5,1,4,2} Again compare next two, as 5 >1, they are swapped {3, 1,5,4,2} Like this it keep swapping and iterate [go through] all the elements once to get this. {3, 1,4,2,5} Now they start doing the second run, compare 3 & 1, as 3> 1 they are swapped. {1,3,4,2,5} compare 3,4 they are in correct order Likewise, you compare until no swaps occur while examining the whole sequence and then the function says "I am done with this" and the looping stops. Bubble Sort Flow Chart: Bubble Sort C++ Code: for( i=n-1, i >1, i++){ for( i=1, i <=n, i++){ for( j=n-1, j >=i, j-){ if (a[j]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Technology. Refer to Case

Answered: 1 week ago