SlideShare ist ein Scribd-Unternehmen logo
1 von 1
Downloaden Sie, um offline zu lesen
(a) Show that the computational complexity of Bubble Sort in the worst case is O(n2). (b) Consider
the Quicksort algorithm. (i) Describe how Quicksort Algorithm would sort a list of n numbers. (ii)
Give a condition under which the Quicksort algorithm will perform at its worst. Justify your
answer.ALGORITHM BubbleSort (A[0..n1]) //Sorts a given array by bubble sort //Input: An array A[
0..n1] of orderable elements //Output: Array A[0..n1] sorted in nondecreasing order for i0 to n2 do
for j0 to n2i do if A[j+1]<A[j] swap A[j] and A[j+1]

Weitere ähnliche Inhalte

Mehr von janakjain2

A study examined the relationship between using a foreign la.pdf
A study examined the relationship between using a foreign la.pdfA study examined the relationship between using a foreign la.pdf
A study examined the relationship between using a foreign la.pdf
janakjain2
 

Mehr von janakjain2 (12)

A study examined the relationship between using a foreign la.pdf
A study examined the relationship between using a foreign la.pdfA study examined the relationship between using a foreign la.pdf
A study examined the relationship between using a foreign la.pdf
 
A student investigated the movement of substances through th.pdf
A student investigated the movement of substances through th.pdfA student investigated the movement of substances through th.pdf
A student investigated the movement of substances through th.pdf
 
A social researcher claims that the average adult lisens to .pdf
A social researcher claims that the average adult lisens to .pdfA social researcher claims that the average adult lisens to .pdf
A social researcher claims that the average adult lisens to .pdf
 
A species that has a high rate of longdistance dispersal is.pdf
A species that has a high rate of longdistance dispersal is.pdfA species that has a high rate of longdistance dispersal is.pdf
A species that has a high rate of longdistance dispersal is.pdf
 
A small country consists of five states A B C D and E.pdf
A small country consists of five states A B C D and E.pdfA small country consists of five states A B C D and E.pdf
A small country consists of five states A B C D and E.pdf
 
A simple random sample SRS of size n36 is drawn from a po.pdf
A simple random sample SRS of size n36 is drawn from a po.pdfA simple random sample SRS of size n36 is drawn from a po.pdf
A simple random sample SRS of size n36 is drawn from a po.pdf
 
A small liberal arts college would like to have an entering .pdf
A small liberal arts college would like to have an entering .pdfA small liberal arts college would like to have an entering .pdf
A small liberal arts college would like to have an entering .pdf
 
A species is diploid with the chromosomes AA BB CC DD where.pdf
A species is diploid with the chromosomes AA BB CC DD where.pdfA species is diploid with the chromosomes AA BB CC DD where.pdf
A species is diploid with the chromosomes AA BB CC DD where.pdf
 
A sixsided die has faces numbered 12345 and 6 Suppose .pdf
A sixsided die has faces numbered 12345 and 6 Suppose .pdfA sixsided die has faces numbered 12345 and 6 Suppose .pdf
A sixsided die has faces numbered 12345 and 6 Suppose .pdf
 
A simple random sample with n56 provided a sample mean of 2.pdf
A simple random sample with n56 provided a sample mean of 2.pdfA simple random sample with n56 provided a sample mean of 2.pdf
A simple random sample with n56 provided a sample mean of 2.pdf
 
A series of twopoint testcrosses was carried out among five.pdf
A series of twopoint testcrosses was carried out among five.pdfA series of twopoint testcrosses was carried out among five.pdf
A series of twopoint testcrosses was carried out among five.pdf
 
A sign of the organizations partnership approach to its wor.pdf
A sign of the organizations partnership approach to its wor.pdfA sign of the organizations partnership approach to its wor.pdf
A sign of the organizations partnership approach to its wor.pdf
 

Kürzlich hochgeladen

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Kürzlich hochgeladen (20)

FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 

a Show that the computational complexity of Bubble Sort in.pdf

  • 1. (a) Show that the computational complexity of Bubble Sort in the worst case is O(n2). (b) Consider the Quicksort algorithm. (i) Describe how Quicksort Algorithm would sort a list of n numbers. (ii) Give a condition under which the Quicksort algorithm will perform at its worst. Justify your answer.ALGORITHM BubbleSort (A[0..n1]) //Sorts a given array by bubble sort //Input: An array A[ 0..n1] of orderable elements //Output: Array A[0..n1] sorted in nondecreasing order for i0 to n2 do for j0 to n2i do if A[j+1]<A[j] swap A[j] and A[j+1]