Join Raghavendra Dixit for an in-depth discussion in this video Sorting any type of object, part of Introduction to Data Structures & Algorithms in Java.
- [Instructor] Until now, we have been dealing…with arrays of integers as the only data type…for the various algorithms that we talked about.…Let's consider a Circle class as shown here.…This class has a radius member variable,…which is initialized through the constructor.…What if we want to sort an array of Circle type objects…based on their radius value?…How would you do that?…Well, one approach is to write another sorting routine.…
So, let's say in the InsertionSorter class we overload…the sort method such that it takes either…an array of integers as parameters…or an array of Circles as parameter, alright?…But then for each new type like a Circle,…we need to keep writing different sort methods…which do exactly the same thing,…but the way we compare the objects is different.…Well, Java provides a better way to handle this kind…of situation.…
We can use what are called as generics…and write code such that we don't have to rewrite…the sort method for different types of objects.…Now, this is more to do with Java…
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.