Join Raghavendra Dixit for an in-depth discussion in this video Introduction to insertion sort, part of Introduction to Data Structures & Algorithms in Java.
- [Instructor] Now, let's see one more n-square time…algorithm which is the insertion sort algorithm.…This algorithm is inspired by the way…we usually arrange cards when we are playing a card game.…A typical way to arrange the cards is we draw a card…and then see if the number on the card is smaller than…the topmost card in hand.…So here we compare 10 with five,…and because 10 is greater than five,…we just put that 10 of diamond on top of five of diamond.…
Then we draw the next card from the pack.…Let's say we get a nine of diamonds now.…We compare the number nine with 10.…Nine is smaller than 10, so we move the 10 of diamonds…to make space for the new card.…Then we compare five of diamonds with nine,…and because nine is greater than five,…we don't move any more cards…and place nine in the newly-created space…between five and 10.…Then let's say we get an eight.…
We compare the eight and 10.…Eight is smaller than 10,…so we move 10 to the right to make space.…Then we compare eight and nine.…Eight being smaller again, we move nine…
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.