Professional Documents
Culture Documents
Dsa Lab 04
Dsa Lab 04
Dsa Lab 04
Instructions:
Take snapshots of both input and output and provide a brief summary explaining what you
have learned in this lab.
Lab Tasks:
Code:
Output:
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering
2) Modify the task 1 code and print out the number of iteration.
Code:
Output:
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering
3) Implement the Bubble Sort algorithm to sort the array in ascending order using a separate function for
swapping.
Code:
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering
Output:
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering
4) Take a worst case scenario array and apply bubble sorting technique to sort it.
Code:
Output:
5) Make change in your previous algorithm. This time perform sorting in descending Order.
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering
Code:
Output:
Output:
Summary:
In this lab we have learnt bubble sorting algorithm grasping the bubble sort algorithm by solving and analyzing various
problems like making function of swapping, doing ascending, and descending of swapping etc.