Purchase Solution

Comparisons

Not what you're looking for?

Ask Custom Question

A. You are given a list of n names (all of the names are distinct) with instructions to put them in alphabetical order. How many comparisons are necessary to accomplish your task?

B. After you have accomplished the task to part a, you are given another name. How many comparisons are necessary to place this name in its place in the alphabetical list? What is the average or expected number of comparisons?

C. After you have accomplished the task in part a, you are given k more names to put in the list. How many comparisons are necessary? What is the average number of comparisons actually needed?

Purchase this Solution

Solution Summary

The solution examples of determining how many comparisons are necessary to complete given tasks.

Solution Preview

A. We can use bubble sort to accomplich this task. First we find the smallest name from n names and it requires n-1 comparisons; Second in the rest n-1 names we find the smallest name and it requires n-2 comparisons. And so on. Finally the total number of comparison is:
(n-1) + (n-2) + ... + 2 + 1 = n(n-1)/2

B. After I have accomplished task of part a, for a ...

Purchase this Solution


Free BrainMass Quizzes
Multiplying Complex Numbers

This is a short quiz to check your understanding of multiplication of complex numbers in rectangular form.

Know Your Linear Equations

Each question is a choice-summary multiple choice question that will present you with a linear equation and then make 4 statements about that equation. You must determine which of the 4 statements are true (if any) in regards to the equation.

Probability Quiz

Some questions on probability

Solving quadratic inequalities

This quiz test you on how well you are familiar with solving quadratic inequalities.

Graphs and Functions

This quiz helps you easily identify a function and test your understanding of ranges, domains , function inverses and transformations.