+ 4

how the data structures works with java codes?

3rd Jul 2017, 7:56 PM
Chapa Priyadarshani
Chapa Priyadarshani - avatar
7 odpowiedzi
0
bubble sort is no data structure, it is an algorithm. Data structures are Vector, Linked List, Deque, Stack and so on while algorithm are ways of solving problems, often with a special Data structure. Bubble sort works like a bubble, the smallest go to the left because it has less "weight" while the biggest go to the right because it has more "weight". I am not really clear right know but with an example it will be better [6] 4 2 9 3 4 [6] 2 9 3 : 6 switch with 4 as 6>4 4 2 [6] 9 3 : 6 switch with 2 as 6>2 4 2 6 [9] 3 : 6 do not move, we take 9 as 9>6 4 2 6 3 [9] : 9 switch with 3 as 9>3 Now the last value of the array is the biggest, so we sort all other values using the same method [4] 2 6 3 | 9 2 [4] 6 3 | 9 : 4 switch with 2 as 4>2 2 4 [6] 3 | 9 : 4 do not move, we take 6 as 6>4 2 4 3 [6] | 9 : 6 switch with 3 as 6>3 Now the last two values are sorted, so we continue with : [2] 4 3 | 6 9 Try to end it by yourself but it is the exact same logic :)
4th Jul 2017, 12:24 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 3
thank you, can u give me a one example?
3rd Jul 2017, 8:00 PM
Chapa Priyadarshani
Chapa Priyadarshani - avatar
+ 3
bubble sort
3rd Jul 2017, 11:52 PM
Chapa Priyadarshani
Chapa Priyadarshani - avatar
+ 3
Thank you very much 🙂
4th Jul 2017, 12:25 AM
Chapa Priyadarshani
Chapa Priyadarshani - avatar
0
Same as for other languages :)
3rd Jul 2017, 7:59 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
0
Of which data structure ?
3rd Jul 2017, 8:15 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
0
Your welcome :)
4th Jul 2017, 12:26 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar