Question

Date: December 12th, 2019 4. Describe why you selected the worstcase runtime above. Recall what we said about inversions and
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please do understand my concern, as per HOMEWORKLIB RULES we are supposed to answer the first question if there is more than one question in a post, your downvote effects my career a lot, if I get a downvote for a wrong answer or incomplete answer I will accept it. Please give a positive rating

1)

a) as we are doing the insertion sort

let p1,p2,p3,p4 are 1,2,3,4 respectively then there are no swaps done, so it is not always mandatory that there will be 4 swaps prior to iteration 5

b) in the insertion sort the loop invariant is the if x is the iterator then all the elements prior to x are always in a sorted manner

since now we are at p5 all the elements before p5 are sorted

Add a comment
Know the answer?
Add Answer to:
Date: December 12th, 2019 4. Describe why you selected the worstcase runtime above. Recall what we...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 4 Problem 4 -Extra Credit Given an array A, we say that elements A and Al...

    4 Problem 4 -Extra Credit Given an array A, we say that elements A and Al are swapped if J >「 but Alj]< A[i]. For example, if A - [8,5,9,7], then there are a total of3 swapped pairs, namely 8 and 5; 8 and 7; and 9 and 7 Describe a recursive algorithm that given an array A, determines the number of swapped pairs in the array in O(n log(n)) time. To analyze the algorithm, you must state the recurrence...

  • [Code in C] Help me with this. Not sure what to do. 1 Couting Sort You...

    [Code in C] Help me with this. Not sure what to do. 1 Couting Sort You may have learned some sorting algorithms - such as bubble sort ad quicksort in CS 110 and CS 210. This homework is about counting sort. Let n be the number of elements to be sorted. Bubble sort and quicksort assume tha time, which one is larger and which one is smaller. They make no assumption on the values of the elements t we can...

  • C++ Sorting and Searching 1. Mark the following statements as true or false. a. A sequential...

    C++ Sorting and Searching 1. Mark the following statements as true or false. a. A sequential search of a list assumes that the list elements are sorted in ascending order. b. A binary search of a list assumes that the list is sorted. 2. Consider the following list: 63 45 32 98 46 57 28 100 Using a sequential search, how many comparisons are required to determine whether the following items are in the list or not? (Recall that comparisons...

  • Can you please help with the below? 1)   Which of the following is true about using...

    Can you please help with the below? 1)   Which of the following is true about using a 2-3-4 tree? a.   It is designed to minimize node visits while keeping to an O(log n) search performance b.   It is designed to self-balance as new values are inserted into the tree c.   As soon as a node becomes full, it performs the split routine d.   None of the above 2)   Which of the following is true about a binary search tree? a.  ...

  • Practical 5: Write a program that implements several sorting algorithms, and use it to demonstrate the comparative perfo...

    Practical 5: Write a program that implements several sorting algorithms, and use it to demonstrate the comparative performance of the algorithms for a variety of data sets. Need Help With this Sorting Algorithm task for C++ Base Code for sorting.cpp is given. The header file is not included in this. Help would be much appreciated as I have not started on this due to personal reasons #include <cstdlib> #include <iostream> #include <getopt.h> using namespace std; long compares; // for counting...

  • I REALLY NEED HELP WITH THIS ASAP!! THANK YOU. In the context of the Web, the...

    I REALLY NEED HELP WITH THIS ASAP!! THANK YOU. In the context of the Web, the main applications include building meta-search engines, combining ranking functions, selecting documents based on multiple criteria. When we use Google search engine to search information, Google always show us a long list links one by one. Suppose Google considers combining ranking results from different sources. At beginning they treat each source equally. In other words, they just sum all ranks from various sources for each...

  • in JAVA program.Use top-down design to design and implement a program to ask the user to...

    in JAVA program.Use top-down design to design and implement a program to ask the user to enter a list of integers, and then display to the user the mean and median of this list. You should first prompt the user to specify the length of the list of integers. For this assignment, your code should create an array of size 10, and then allow the user to specify the number of integers in their list, up to a maximum of...

  • What is the role of polymorphism? Question options: Polymorphism allows a programmer to manipulate objects that...

    What is the role of polymorphism? Question options: Polymorphism allows a programmer to manipulate objects that share a set of tasks, even though the tasks are executed in different ways. Polymorphism allows a programmer to use a subclass object in place of a superclass object. Polymorphism allows a subclass to override a superclass method by providing a completely new implementation. Polymorphism allows a subclass to extend a superclass method by performing the superclass task plus some additional work. Assume that...

  • Step One This is the Measurable interface we saw in class; you will need to provide...

    Step One This is the Measurable interface we saw in class; you will need to provide this class; this is it in its entirety (this is literally all you have to do for this step): public interface Measurable double getMeasure(); Step Two This is the Comparable interface that is a part of the standard Java library: public interface Comparable int compareTo (Object otherObject); Finish this class to represent a PiggyBank. A PiggyBank holds quarters, dimes, nickels, and pennies. You will...

  • Return to the original model. We now introduce a Poisson intensity parameter X for every time point and denote the parameter () that gives the canonical exponential family representation as above by...

    Return to the original model. We now introduce a Poisson intensity parameter X for every time point and denote the parameter () that gives the canonical exponential family representation as above by θ, . We choose to employ a linear model connecting the time points t with the canonical parameter of the Poisson distribution above, i.e., n other words, we choose a generalized linear model with Poisson distribution and its canonical link function. That also means that conditioned on t,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT