Why study data structures & algorithms
Correctness of an algorithm
Chapter Quiz
Analysis of Algorithms
Note on this section
How to calculate the time complexity
The RAM model of computation
Time complexity of Bubble sort algorithm
Pseudo code : Bubble sort algorithm
The Big O notation
Using Big O notation : Examples
Comparison of running times
Basic Sorting and Search Algorithms
Selection Sort
One of the problems that people face in writing algorithms is how to translate their thoughts into a programming language. Many people cannot even start writing the very first statement of an algorithm. I suggest that if you are having such trouble, don't try to solve the whole problem together, rather break it down into smaller, easier parts. For e.g. try doing the following in writing code for the selection sort algorithm -
- First try to write a method, which just finds the minimum number in the data array. Don't think about anything else, just that method. If you write it in a different method, then you may need to pass the data array as a parameter to that method. Return the index of that minimum element from this method.
- Now change the method to find the minimum number STARTING FROM A PARTICULAR INDEX. So you will need to pass this index as a parameter.
- Write another method which can swap items in an array, located at two different indexes. What parameters should be passed to this method?
Hopefully, by this time you will have enough clarity on completing the sorting algorithm, if you understood the pseudo code.
Introduction to Insertion Sort
Applying Insertion Sort algorithm to cue balls
Insertion Sort: Pseudocode
O(n²) sorting algorithms - Comparison
In place sorting
Stable Vs Unstable Sorts
Searching elements in an un ordered array
Searching elements in an ORDERED array
Searching elements in an ORDERED array - contd.
Inserting and Deleting items in an ORDERED array
Try to write generic sort methods, like shown in the InsertionSortWithGenerics.java, for Bubble sort and Selection sort algorithms as an exercise. But if you don't want to get into generics at this point, you may choose to skip this section.
Assignment
Linked Lists
What is a Linked List?
Implementing a Linked List in Java
Inserting a new Node
Length of a Linked List
Deleting the head node
Searching for an Item
Using java generics to parameterize the LinkedList
Doubly Ended Lists
Inserting data in a sorted Linked List
Doubly Linked List
Insertion Sort revisited
Stacks and Queues
Stacks
Abstract Data Types
Implementing Stacks using Arrays
Queues
Queues using Arrays
Double Ended Queues
Double Ended Queues using Arrays
Recursion
Understanding Recursion
Tail recursion
Tower of Hanoi
Tower of Hanoi - Implementation
Merge Sort
Merge Sort - Pseudocode
Merge Step - Pseudocode
Time Complexity of Merge Sort
Binary Search Trees
The Tree Data structure
Binary Trees
Finding an item in a Binary Search Tree
Implementing the find method
Inserting an item in a Binary Search Tree
Deleting an Item : Case 1
Deleting an Item - Case 2
Deleting an Item - Case 3
Deleting an Item - Soft Delete
Finding smallest & largest values
Tree Traversal : In Order
Tree Traversal : Pre Order
Tree Traversal : Post Order
Unbalanced Trees Vs Balanced Trees
Height of a Binary Tree
Time Complexity of Operations on Binary Search Trees
More Sorting Algorithms
QuickSort
QuickSort: The partition step
Shell Sort
Shell Sort: Example
Counting Sort
Radix Sort
Bucket Sort