Join Raghavendra Dixit for an in-depth discussion in this video Pseudo code: Bubble sort algorithm, part of Introduction to Data Structures & Algorithms in Java.
- [Narrator] Let's look at the pseudo code…for the Bubble Sort Algorithm.…Take some time to understand what this code is doing…and then try to implement the algorithm in Java, alright.…So let's first understand it.…In the outer for loop, we are varying i…from a value of zero all the way up to…two less than the size of the array, alright.…And in the inner loop, j varies from zero…all the way up to the size of the array minus 2 minus i.…
By the way, unlike the pseudo code in many textbooks,…I'm using a zero based index…so that translating it to Java code is easier.…It is through this j index that we access the elements.…When i is zero, j starts from zero…and goes all the way up to the second last element.…Then when i becomes one…in the next iteration of the outer loop,…j varies from zero and goes up to the third last element…of the array and so on.…
Thus for each outer iteration, the maximum value of j…decreases by one because the value of i increases by one.…And at each step, when the value of j changes,…we compare the element at the jth index…
Note: This course was created by Packt Publishing. We are pleased to host this training in our library.
- Why study data structures and algorithms?
- How to calculate the time complexity
- Using Big O notation
- Using basic sorting and search algorithms
- Searching elements in unordered arrays and ordered arrays
- Implementing a linked list in Java
- Implementing stacks using arrays
- Queues using arrays
- Binary search trees
- Representing heaps using arrays
Skill Level Intermediate
1. Introduction to Algorithms
2. Analysis of Algorithms
3. Basic Sorting and Search Algorithms
4. Linked Lists
5. Stacks and Queues
7. Binary Search Trees
8. More Sorting Algorithms
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.