Join Raghavendra Dixit for an in-depth discussion in this video Time complexity of bubble sort algorithm, part of Introduction to Data Structures & Algorithms in Java.
- [Instructor] Let's analyze the bubble sort algorithm…in terms of the number of steps.…Where each step is either some operation or memory access.…And as already said, each of such step takes a unit, time.…Consider an array like the one shown here.…Because we are doing the worst case analysis,…we have used an array that is reversed sorted.…So that the algorithm has to do the most…number of steps possible to sort this array…in ascending order, okay?…That is, we will get the worst case performance…of the bubble sort algorithm when the data…is sorted the other way.…
And let's kind of draw a table to track the number…of comparisons or swaps that may be involved in each step.…So we start by comparing 12 and eight.…So that is one comparison.…And the swap is done in three memory access steps, alright.…Because we used a temporary bin, or in a program,…we will use a temporary variable to do this swap, alright.…That is eight goes to the temporary variable,…then 12 comes to the place of eight,…and then eight is moved to the first slot.…
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.