Preview

7.2-3 Show That The Splits At Every Level Of Quicksort?

Good Essays
Open Document
Open Document
1551 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
7.2-3 Show That The Splits At Every Level Of Quicksort?
7.2-3 Show that the running time of QUICKSORT is ‚.n2/ when the array A contains distinct elements and is sorted in decreasing order.
QUICKSORT becomes T(n)=T(n-1)+∅(n)
T(n)=T(n-1)+∅(┤)
=T(n-2)+∅(n-1)+∅(n)
=T(n-3)+∅(n-2)+∅(n-1)+∅(n)
=∅(n)+∅∑_(k=1)^n▒k
=∅(n^2)
7.2-5 Suppose that the splits at every level of quicksort are in the proportion 1˛ to ˛, where 0<˛ 1=2 is a constant. Show that the minimum depth of a leaf in the recursion tree is approximately lgn=lg˛ and the maximum depth is approximately lgn=lg.1˛/. (Don’t worry about integer round-off.)
For the minimum depth, it follows a path. This path is one that is a smaller part of the partition. For example, the partition multiplies the number of elements by α. One iteration of minimum depth reduces the number of elements from n to αn. It then takes that iterations, and reduces the number of
…show more content…
Where does your proof need the assumption that the intermediate sort is stable?

Base step: Assume that d=1. That is, there is only single digit in the given numbers. Then radix sorts the array on that single digit. That is, of d=1, radix sort performs sort on one column and gives the sorted array. Therefore, radix sort works for single digit numbers.
Sort on the dth digit:
In the proof, the assumption that the intermediate sort is stable. This is required when sorting numbers on their d^thdigit. Also who’s d^thdigits were equal. Since the d^thdigits were equal, the correct order of numbers is already determined. This is by after sorting by their lower-order d-1 digits. If the intermediate sort was not stable, the numbers correctly ordered by sorting on their lower ordered d-1 digits are rearranged. This is done while sorting on d^thdigit.The assumption is required when sorting numbers on their d^th digit. And also who’s d^thdigits were equal.
12.1-1 for the set of {1,4,5,10,16,17,21} of keys, draw binary search trees of height 2,3,4,5 and 6
Height 1

Height

You May Also Find These Documents Helpful

  • Satisfactory Essays

    a. Solve parts a and b of problem 103 on page 605 and problem 104 on page 606 of Elementary and Intermediate Algebra .…

    • 548 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    b. b. Include the function written in Exercise 8a in a working program. Make sure your…

    • 720 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Nt1420 Unit 6

    • 1145 Words
    • 5 Pages

    INSTRUCTIONS: 1. THERE ARE SIX (6) QUESTIONS IN THIS PAPER. 2. ANSWER FIVE (5) QUESTIONS ONLY. Question 1 Arrays are used when storing a large number of values. You are required to create an array named a and answer the following questions regarding array manipulation. a. Write a method fillRandom(int[] a, int min, int max), fill the array a with a random integer value. (Note: Math.random() returns a double in the range of 0.0 and 1.0, therefore it is cast to an integer number, between the minimum and maximum value). [6 marks] b. Write the Bubble sort method to sort array a into descending order. [10 marks] c. In the quicksort, an algorithm an element is chosen from the unsorted list. This element is called the…

    • 1145 Words
    • 5 Pages
    Good Essays
  • Good Essays

    Exercise 1: Review of array-based lists Create a project using the classes in the DocSharing area labeled “User-defined array list." Compile it, run it, and review the code that is given carefully. This code tests the ArrayList class provided in the lecture.…

    • 714 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    b. Ch. 2: RQs 1 – 9, 10, 11 and Problems #1 and 2 (include all attributes).…

    • 2322 Words
    • 10 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Pt1420 Unit 4

    • 380 Words
    • 2 Pages

    The term ________sort_________ refers to the process of rearranging information in alphabetical, numerical, or chronological order.…

    • 380 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    ECET 370 Week 5 Lab 5

    • 650 Words
    • 3 Pages

    Exercise 3: Searching Applications Select one of the following two problems to solve: Problem 1: Design and implement an algorithm that determines whether or not a given array of elements, listl, is completely contained within another given array of elements, Iist2. Consider two different scenarios: 1) both arrays are sorted; 2) both arrays are unsorted. Problem 2: Design an algorithm that when given a collection of integers in an unsorted array, determines the second smallest number (or second minimum). For example, if the array consists of the values 12, 23, 9, 17, 3, the algorithm should report the value 9, since it is the second smallest number in the array. Write a function that...…

    • 650 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Nt1310 Unit 1 Test Paper

    • 381 Words
    • 2 Pages

    3. Create a binary search function that tells whether a given value exists in the tree or not.…

    • 381 Words
    • 2 Pages
    Good Essays
  • Good Essays

    examination. It is intended that the specimen papers and mark schemes contained in this booklet…

    • 2875 Words
    • 12 Pages
    Good Essays
  • Good Essays

    When sorting by number, there will be a significant time difference. The low vision cards will cause confusion since they lack the corresponding number of symbols to the card number.…

    • 1300 Words
    • 6 Pages
    Good Essays
  • Satisfactory Essays

    Whole Numbers Quiz

    • 3725 Words
    • 15 Pages

    The digit to its right is 5 or greater, so the digit in the rounded place increases.…

    • 3725 Words
    • 15 Pages
    Satisfactory Essays
  • Good Essays

    *Note: All asterisked Questions, Exercises, and Problems relate to material contained in the appendix*to the chapter.…

    • 7223 Words
    • 29 Pages
    Good Essays
  • Better Essays

    Medical Records

    • 980 Words
    • 4 Pages

    Under this system, numbers are grouped into units containing two digits each. The medical staff used use a six-digit number which they divide it with a hyphen into three parts. The six-digit numbers are often read from right to left. Notably, the last two digits of a number are referred to as primary digits and comprise of first indexing unit. The middle two digits which represent second indexing unit are referred to as secondary digits. The first two digits represent the third indexing units are referred to as third indexing unit. This is illustrated below.…

    • 980 Words
    • 4 Pages
    Better Essays
  • Good Essays

    Problem Set Chapter 3

    • 899 Words
    • 4 Pages

    Professor Smith – A silly mistake by me to do the problems that were requested for problem set chapter 5…Here is the second question that I should have completed instead of #6 for Chapter 4.…

    • 899 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Sum of Gp

    • 696 Words
    • 3 Pages

    4. Remember our objective is to calculate S n . From equation (4), S n is obvious to…

    • 696 Words
    • 3 Pages
    Good Essays