Question

In: Computer Science

Assume your sorting algorithms have to deal with lists that can potentially contain duplicates. Assume the...

Assume your sorting algorithms have to deal with lists that can potentially contain duplicates. Assume the same sorting algorithms as discussed in class / in the textbook.

(a) What is the running time of Insertion Sort when all elements in a given list of length N are equal? Explain your answer.

(b) Give a Θ-bound on the running time of Mergesort for the case that all elements in a given list of length N are equal (assuming N is a power of 2). Explain your answer.

Solutions

Expert Solution

Solution)

A)

When entire or all elements in a givened list of length N are equal or equivalent,it is the finest or best case of Insertion Sort. So that the O(N) is the running time of insertion sort. Insertion sort require only 1 full traversal of the array to complete the sort.

B)

In Merge Sort, there are 3 steps those are 1)Divide step, 2)the Conqer step and the 3)Combine step.The time complexity of first step Divide step is O(1), the time complexity of second step Conquer step is O(log n) and the time complexity of third step Combine step is O(n), If entire elements of the list are equal or equivalent, O(log N). Here the base of logarithm is 2. Let Assume N is a power of 2, say for instance N = 2^V, the time complexity is O(V), where V is a very little number when comparing to N, if N tending to big. Thus for large lists, so that the time complexity of merge sort is minor or negligible.

I HOPE THIS ANSWER WILL HELP YOU PLEASE DO UP VOTE THAT MEANS A LOT TO ME THANK YOU.


Related Solutions

Mergesort is known to be one of the fastest algorithms for sorting lists of data. In...
Mergesort is known to be one of the fastest algorithms for sorting lists of data. In fact, the runtime of mergesort is proportional to n· logn where n is the size of the list to be sorted. Bubblesort, on the other hand is a much slower algorithm, since it's runtime is proportional to n2 , where n is the size of the list to be sorted. As an experiment, mergesort is run on a slow computer, bubblesort is run on...
C++ Analysis of Sorting Algorithms Design a class AbstractSort that can be used to analyze the...
C++ Analysis of Sorting Algorithms Design a class AbstractSort that can be used to analyze the number of comparisons performed by a sorting algorithm. The class should have a member function compare that is capable of comparing two array elements, and a means of keeping track of the number of comparisons performed. The class should be an abstract class with a pure virtual member function void sort(int arr[ ], int size) which, when overridden, will sort the array by calling...
Problem Description Objective This practical will test your knowledge on sorting and searching algorithms. In this...
Problem Description Objective This practical will test your knowledge on sorting and searching algorithms. In this practical, you will be implementing a number of algorithms. Each of these algorithms will be constructed in a different class. You should make sure that you know the complexity of the algorithms you implement. Design Think of how you are going to solve the problem and test your implementation with the test cases you designed based on the stages below. Testing Hint: it’s easier...
Please use Java You have to write a programing for the following sorting algorithms in increasing...
Please use Java You have to write a programing for the following sorting algorithms in increasing order and print required steps in order to explain how your sorting algorithms work. 3. Implement the merge sort algorithm. With answers in this link (https://www.chegg.com/homework-help/questions-and-answers/write-programing-following-sorting-algorithms-increasing-order-print-required-steps-order--q53916147?trackid=PJ_TOK85), answer the above questions.
For your initial post, utilizing credible sources, describe the various types of sorting and searching algorithms...
For your initial post, utilizing credible sources, describe the various types of sorting and searching algorithms and give an example of each other than the examples provided in the assigned readings. Apply algorithmic design and data structure techniques in developing structured programs by discussing time and space complexity in relation to whether using a sort algorithm is better than using a search algorithm. Does it really matter with the capabilities of computers today? Provide justification to support your answers.
Sets can be though of as lists that don't contain any repeated elements. For example, [a,4,6]...
Sets can be though of as lists that don't contain any repeated elements. For example, [a,4,6] is a set, but [a,4,6,a] is not (as it contains 2 occurrences of a). Write a Prolog program, powerset/2 that generates the set of all subsets of a list in sorted order. (Note the input list may not, itself, be a set.) Example1: powerset([a,b],X). should yield: X = [[],[a],[a,b],[b],[b,a]]. Example2: powerset([a,b,a],X). should also yield (note input list is not actually a set): X =...
Suppose you have algorithms with the five running times listed below. (Assume these are the exact...
Suppose you have algorithms with the five running times listed below. (Assume these are the exact running times.) How much slower (i.e., you need check the ratio) do each of these algorithms get when you (a) double the input size, (b) increase the input size by one? 5nlog(n)
Errors in the program evaluation process can occur at any stage and can potentially have disastrous...
Errors in the program evaluation process can occur at any stage and can potentially have disastrous effects on the acceptance or proper interpretation of the results. These errors encompass many areas including, but not limited to relationships, logic, scapegoating, and population masking. For this discussion, respond to the following: Analyze which errors have the most damaging impact on an evaluation. Provide clear examples to support your perspective from your experiences, course materials, or your own research. Use APA formatting to...
Can you think of any potentially important technologies that have languished because they have lacked political...
Can you think of any potentially important technologies that have languished because they have lacked political support? How would you suggest a better system for managing technologies?
What are devices in your home that appear to use computers or algorithms? Can you name...
What are devices in your home that appear to use computers or algorithms? Can you name at least one device for every room in your house? Describe one algorithm each device performs
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT