Join Raghavendra Dixit for an in-depth discussion in this video Insertion sort: Pseudocode, part of Introduction to Data Structures & Algorithms in Java.
- [Instructor] Let's look at the pseudocode…for this algorithm.…Let's start with an array,…and we need to go over all the elements of the array,…one by one,…inserting the newly-accessed element in its right place,…so that the already-accessed part of the array…remains sorted.…So we must write a for-loop,…using which we can access each element of the array…one by one.…That is, we should be able to access elements…from the zeroth index up to the last index,…which is given by one less than the size of the array.…
Here, we represent the array with a capital letter A.…The first thing we do…is to save the element at index i into a variable,…and let's call it current,…so that even when we write over the index i,…the element at i is saved in another variable,…and we are able to access it later.…Then we start accessing the elements of the array,…starting from the previous index, which is i minus 1.…
Now we would like to compare the elements of the array…one by one with the current element,…going to the left…to check if the current element is less than these elements.…
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.