SlideShare uma empresa Scribd logo
1 de 19
More Sorting

 radix sort
 bucket sort
 in-place sorting
 how fast can we sort?




                          1
Radix Sort
    Unlike other sorting methods, radix sort considers the
     structure of the keys
    Assume keys are represented in a base M number
     system (M = radix), i.e., if M = 2, the keys are
     represented in binary




Sorting is done by comparing bits in the same position

Extension to keys that are alphanumeric strings
                                                              2
Radix Exchange Sort
Examine bits from left to right:
1. Sort array with respect to leftmost bit


2. Partition array




3.Recursion
recursively sort top subarray, ignoring leftmost bit
recursively sort bottom subarray, ignoring leftmost bit
Time to sort n b-bit numbers:   O(b n)
                                                          3
Radix Exchange Sort
How do we do the sort from the previous page? Same idea as
partition in Quicksort.
                 repeat
                        scan top-down to find key starting with 1;
                        scan bottom-up to find key starting with 0
                        exchange keys;
                 until scan indices cross;




                                                            4
Radix Exchange Sort




                      5
Radix Exchange Sort vs. Quicksort
Similarities
       both partition array
       both recursively sort sub-arrays
Differences
       Method of partitioning
              radix exchange divides array based on greater
than or                less than 2b-1
              quicksort partitions based on greater  than or
less than              some element of the array
       Time complexity
              Radix exchange            O (bn)
              Quicksort average case O (n log n)


                                                           6
Straight Radix Sort
Examines bits from right to left
for k := 0 to b-1
       sort the array in a stable way,
       looking only at bit k




Note order of these bits after sort.
                                         7
What is “sort in a stable way”!!!
In a stable sort, the initial relative order of equal keys is
unchanged. For example, observe the first step of the sort
from the previous page:




Note that the relative order of those keys ending with 0
is unchanged, and the same is true for elements
ending in 1
                                                                8
The Algorithm is Correct (right?)
We show that any two keys are in the correct relative order
at the end of the algorithm

Given two keys, let k be the leftmost bit-position where
they differ




 At step k the two keys are put in the correct relative
 order
 Because of stability, the successive steps do not
 change the relative order of the two keys
                                                           9
For Instance,
Consider a sort on an array with these two keys:




                                                   10
Radix sorting applied to decimal numbers




                                     11
Straight Radix Sort Time Complexity
for k = 0 to b - 1
       sort the array in a stable way, looking only at bit k


Suppose we can perform the stable sort above in O(n)
time. The total time complexity would be
      O(bn)
As you might have guessed, we can perform a stable
sort based on the keys’ kth digit in O(n) time.

The method, you ask? Why it’s Bucket Sort, of course.


                                                               12
Bucket Sort

 BASICS:
     n numbers
     Each number  {1, 2, 3, ...
     m}
     Stable
     Time: O (n + m)
 For example, m = 3 and our array
 is:
(note that there are two “2”s and two “1”s)

                  First, we create M “buckets”

                                                 13
Bucket Sort
Each element of the array is put in one of the m “buckets”




                                                             14
Bucket Sort


Now, pull the elements
from the buckets into the
array




At last, the sorted array
(sorted in a stable way):
                            15
In-Place Sorting
   A sorting algorithm is said to be in-place if
      it uses no auxiliary data structures (however, O(1)
      auxiliary variables are allowed)
     it updates the input sequence only by means of
      operations replaceElement and swapElements
   Which sorting algorithms seen can be made to
    work in place?




                                                             16
Lower Bd. for Comparison Based Sorting
   internal node: comparison
   external node: permutation
   algorithm execution: root-to-leaf path




                                             17
How Fast Can We Sort?
 How Fast Can We Sort?
 Proposition: The running time of any
  comparison-based algorithm for sorting an n-
  element sequence S is (n log n).
 Justification: The running time of a
  comparison-based sorting algorithm must be
  equal to or greater than the depth of the
  decision tree T associated with this algorithm.



                                                    18
How Fast Can We Sort? (2)
 Each internal node of T is associated with a
  comparison that establishes the ordering of two
  elements of S.
 Each external node of T represents a distinct
  permutation of the elements of S.
 Hence T must have at least n! external nodes which
  again implies T has a height of at least log(n!)
 Since n! has at least n/2 terms that are greater than
  or equal to n/2, we have: log(n!) ≥ (n/2) log(n/2)
 Total Time Complexity: (n log n).


                                                   19

Mais conteúdo relacionado

Mais procurados (20)

Lec10
Lec10Lec10
Lec10
 
Nikit
NikitNikit
Nikit
 
Lec4
Lec4Lec4
Lec4
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
 
Merge sort
Merge sortMerge sort
Merge sort
 
Big o
Big oBig o
Big o
 
Mergesort
MergesortMergesort
Mergesort
 
Sorting
SortingSorting
Sorting
 
Lec3
Lec3Lec3
Lec3
 
Best,worst,average case .17581556 045
Best,worst,average case .17581556 045Best,worst,average case .17581556 045
Best,worst,average case .17581556 045
 
Sorting
SortingSorting
Sorting
 
Quicksort
QuicksortQuicksort
Quicksort
 
Time complexity (linear search vs binary search)
Time complexity (linear search vs binary search)Time complexity (linear search vs binary search)
Time complexity (linear search vs binary search)
 
Hub 102 - Lesson 5 - Algorithm: Sorting & Searching
Hub 102 - Lesson 5 - Algorithm: Sorting & SearchingHub 102 - Lesson 5 - Algorithm: Sorting & Searching
Hub 102 - Lesson 5 - Algorithm: Sorting & Searching
 
Lec2
Lec2Lec2
Lec2
 
Sorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha MajumderSorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha Majumder
 
Lec16
Lec16Lec16
Lec16
 
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sorting
 
Algorithm big o
Algorithm big oAlgorithm big o
Algorithm big o
 

Destaque (20)

Radix Sort
Radix SortRadix Sort
Radix Sort
 
Lec20
Lec20Lec20
Lec20
 
Lec19
Lec19Lec19
Lec19
 
Lec21
Lec21Lec21
Lec21
 
Shell sort slide
Shell sort slideShell sort slide
Shell sort slide
 
Shell sort
Shell sortShell sort
Shell sort
 
I 7
I 7I 7
I 7
 
Shell sort[1]
Shell sort[1]Shell sort[1]
Shell sort[1]
 
3.3 shell sort
3.3 shell sort3.3 shell sort
3.3 shell sort
 
Radix sort presentation
Radix sort presentationRadix sort presentation
Radix sort presentation
 
Counting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort AlgorithmsCounting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort Algorithms
 
Metodos de ordenacion radix sort
Metodos de ordenacion radix sortMetodos de ordenacion radix sort
Metodos de ordenacion radix sort
 
Radix sorting
Radix sortingRadix sorting
Radix sorting
 
Visualizing geolocated Internet measurements
Visualizing geolocated Internet measurementsVisualizing geolocated Internet measurements
Visualizing geolocated Internet measurements
 
History and Overview of Tobacco Policy Initiatives in Maine, 1897-Present
History and Overview of Tobacco Policy Initiatives in Maine, 1897-PresentHistory and Overview of Tobacco Policy Initiatives in Maine, 1897-Present
History and Overview of Tobacco Policy Initiatives in Maine, 1897-Present
 
Tearsofawoman
TearsofawomanTearsofawoman
Tearsofawoman
 
1172. su.-.pps_angelines
1172.  su.-.pps_angelines1172.  su.-.pps_angelines
1172. su.-.pps_angelines
 
The Voice 2000 edition
The Voice 2000 editionThe Voice 2000 edition
The Voice 2000 edition
 
Marikas blogi
Marikas blogiMarikas blogi
Marikas blogi
 
China's amazing bridges_-_2003v[1]
China's amazing bridges_-_2003v[1]China's amazing bridges_-_2003v[1]
China's amazing bridges_-_2003v[1]
 

Semelhante a Lec23 (20)

lecture 9
lecture 9lecture 9
lecture 9
 
Counting Sort Lowerbound
Counting Sort LowerboundCounting Sort Lowerbound
Counting Sort Lowerbound
 
Cis435 week06
Cis435 week06Cis435 week06
Cis435 week06
 
Linear sorting
Linear sortingLinear sorting
Linear sorting
 
Sorting2
Sorting2Sorting2
Sorting2
 
lecture 10
lecture 10lecture 10
lecture 10
 
Sorting
SortingSorting
Sorting
 
220exercises2
220exercises2220exercises2
220exercises2
 
sorting
sortingsorting
sorting
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.ppt
 
lecture-k-sorting.ppt
lecture-k-sorting.pptlecture-k-sorting.ppt
lecture-k-sorting.ppt
 
3.ppt
3.ppt3.ppt
3.ppt
 
Lecture k-sorting
Lecture k-sortingLecture k-sorting
Lecture k-sorting
 
Unit vii sorting
Unit   vii sorting Unit   vii sorting
Unit vii sorting
 
Binsort
BinsortBinsort
Binsort
 
Master of Computer Application (MCA) – Semester 4 MC0080
Master of Computer Application (MCA) – Semester 4  MC0080Master of Computer Application (MCA) – Semester 4  MC0080
Master of Computer Application (MCA) – Semester 4 MC0080
 
Daa chapter5
Daa chapter5Daa chapter5
Daa chapter5
 
Address calculation-sort
Address calculation-sortAddress calculation-sort
Address calculation-sort
 
Selection sort lab mannual
Selection sort lab mannualSelection sort lab mannual
Selection sort lab mannual
 
Selection sort
Selection sortSelection sort
Selection sort
 

Mais de Anjneya Varshney (7)

Lec16
Lec16Lec16
Lec16
 
Lec12
Lec12Lec12
Lec12
 
Lec11
Lec11Lec11
Lec11
 
Lec8
Lec8Lec8
Lec8
 
Lec7
Lec7Lec7
Lec7
 
Lec6
Lec6Lec6
Lec6
 
Lec13
Lec13Lec13
Lec13
 

Último

MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 

Último (20)

MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 

Lec23

  • 1. More Sorting  radix sort  bucket sort  in-place sorting  how fast can we sort? 1
  • 2. Radix Sort  Unlike other sorting methods, radix sort considers the structure of the keys  Assume keys are represented in a base M number system (M = radix), i.e., if M = 2, the keys are represented in binary Sorting is done by comparing bits in the same position Extension to keys that are alphanumeric strings 2
  • 3. Radix Exchange Sort Examine bits from left to right: 1. Sort array with respect to leftmost bit 2. Partition array 3.Recursion recursively sort top subarray, ignoring leftmost bit recursively sort bottom subarray, ignoring leftmost bit Time to sort n b-bit numbers: O(b n) 3
  • 4. Radix Exchange Sort How do we do the sort from the previous page? Same idea as partition in Quicksort. repeat scan top-down to find key starting with 1; scan bottom-up to find key starting with 0 exchange keys; until scan indices cross; 4
  • 6. Radix Exchange Sort vs. Quicksort Similarities both partition array both recursively sort sub-arrays Differences Method of partitioning radix exchange divides array based on greater than or less than 2b-1 quicksort partitions based on greater than or less than some element of the array Time complexity Radix exchange O (bn) Quicksort average case O (n log n) 6
  • 7. Straight Radix Sort Examines bits from right to left for k := 0 to b-1 sort the array in a stable way, looking only at bit k Note order of these bits after sort. 7
  • 8. What is “sort in a stable way”!!! In a stable sort, the initial relative order of equal keys is unchanged. For example, observe the first step of the sort from the previous page: Note that the relative order of those keys ending with 0 is unchanged, and the same is true for elements ending in 1 8
  • 9. The Algorithm is Correct (right?) We show that any two keys are in the correct relative order at the end of the algorithm Given two keys, let k be the leftmost bit-position where they differ At step k the two keys are put in the correct relative order Because of stability, the successive steps do not change the relative order of the two keys 9
  • 10. For Instance, Consider a sort on an array with these two keys: 10
  • 11. Radix sorting applied to decimal numbers 11
  • 12. Straight Radix Sort Time Complexity for k = 0 to b - 1 sort the array in a stable way, looking only at bit k Suppose we can perform the stable sort above in O(n) time. The total time complexity would be O(bn) As you might have guessed, we can perform a stable sort based on the keys’ kth digit in O(n) time. The method, you ask? Why it’s Bucket Sort, of course. 12
  • 13. Bucket Sort BASICS: n numbers Each number  {1, 2, 3, ... m} Stable Time: O (n + m) For example, m = 3 and our array is: (note that there are two “2”s and two “1”s) First, we create M “buckets” 13
  • 14. Bucket Sort Each element of the array is put in one of the m “buckets” 14
  • 15. Bucket Sort Now, pull the elements from the buckets into the array At last, the sorted array (sorted in a stable way): 15
  • 16. In-Place Sorting  A sorting algorithm is said to be in-place if  it uses no auxiliary data structures (however, O(1) auxiliary variables are allowed)  it updates the input sequence only by means of operations replaceElement and swapElements  Which sorting algorithms seen can be made to work in place? 16
  • 17. Lower Bd. for Comparison Based Sorting  internal node: comparison  external node: permutation  algorithm execution: root-to-leaf path 17
  • 18. How Fast Can We Sort?  How Fast Can We Sort?  Proposition: The running time of any comparison-based algorithm for sorting an n- element sequence S is (n log n).  Justification: The running time of a comparison-based sorting algorithm must be equal to or greater than the depth of the decision tree T associated with this algorithm. 18
  • 19. How Fast Can We Sort? (2)  Each internal node of T is associated with a comparison that establishes the ordering of two elements of S.  Each external node of T represents a distinct permutation of the elements of S.  Hence T must have at least n! external nodes which again implies T has a height of at least log(n!)  Since n! has at least n/2 terms that are greater than or equal to n/2, we have: log(n!) ≥ (n/2) log(n/2)  Total Time Complexity: (n log n). 19