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.
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
Your developing a set of algorithms for a librarian robot that can put newly arrived books...
Your developing a set of algorithms for a librarian robot that can put newly arrived books to the main book shelf (of a sufficient capacity) while maintaining an alphabetical order. Design an algorithm that minimises Ccmp, the number of comparisons of two books’ labels in the alphabetical order, and Cmov, the number of book movements (one movement is counted whenever a book is moved from one location to another) in the worst case. Suppose there are n books on the...
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?
[jAVA] Assume the following array is defined and initialized (it will already contain numbers before your...
[jAVA] Assume the following array is defined and initialized (it will already contain numbers before your code runs): public static void main( String [ ] args ) { int [ ] numbers = . . . ; // An array of integers 1) Provide code that will print the entire contents of numbers in reverse order (from the end to the beginning) 2) Provide code that will print true if the numbers are in strictly ascending order (that is, if...
Where do YOUR own errors of perception come from? 2. -How can they potentially impact your...
Where do YOUR own errors of perception come from? 2. -How can they potentially impact your effectiveness as a critical thinker? 3. -What are some of the assumptions we make as healthcare professionals that could possibly have a negative impact?   Please support your answers; you MUST use Ruggerio, you are welcome to add other sources. Use APA format for citations and reference page. You may use first person in your discussion post.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT