Liner List Manipulation
What will be the status of the following list after the First, Second and Third pass of the bubble sort method used for arranging the following elements in descending order ?
Note: Show the status of all the elements after each pass very clearly underlining the changes.
152, 104, -100, 604, 190, 204
Phase I
152 |
104 |
-100 |
604 |
190 |
204 |
152 |
104 |
-100 |
604 |
190 |
204 |
152 |
104 |
-100 |
604 |
190 |
204 |
152 |
104 |
604 |
-100 |
190 |
204 |
152 |
104 |
604 |
190 |
-100 |
204 |
152 |
104 |
604 |
190 |
204 |
-100 |
Phase II
152 |
104 |
604 |
190 |
204 |
-100 |
152 |
104 |
604 |
190 |
204 |
-100 |
152 |
604 |
104 |
190 |
204 |
-100 |
152 |
604 |
190 |
104 |
204 |
-100 |
152 |
604 |
190 |
204 |
104 |
-100 |
Phase III
152 |
604 |
190 |
204 |
104 |
-100 |
604 |
152 |
190 |
204 |
104 |
-100 |
604 |
190 |
152 |
204 |
104 |
-100 |
604 |
190 |
204 |
152 |
104 |
-100 |
Sponsor Area
Write a method in python to search for a value in a given list (assuming that the elements in the list are in ascending order) with the help of Binary Search method. The method should return –1 if the value does not present else it should return the position of the value present in the list.
Sponsor Area
Sponsor Area