In this module, you will learn various algorithms on two very important techniques, namely ‘searching’ and ‘sorting’.
Now, there are various algorithms designed for the implementation of each technique. You will go through most of them and see which one is the best. This analysis will be done based on what you already learnt about Big O in the Algorithm Analysis module. You will learn that using the divide and conquer technique is of immense help when it comes to improving the efficiency of algorithms.
Primarily, we will discuss the following in this module:
Searching
Linear search
Binary search
Sorting
Bubble sort
Selection sort
Insertion sort
Merge sort
Quick sort
This session will cover search techniques. You will learn two techniques, namely ‘linear search’ and ‘binary search’. So let’s begin.
Subject Matter Expert
Aishwarya Rai
Ex-Product Engineer, EdgeVerve
She worked as a software developer for Finacle at Edgeverve and helped in creating financial and e-banking software applications. She is currently working with Software Development content team at UpGrad.
Industry Expert
Technical Lead, ImpactRun
ImpactRun is a fitness philanthropy Android application in which your every walk or run raises funds for a social cause you care about.
Presenter
Rachit Goyal
So, as Ankit discussed, it is very important to optimise the search technique you use, especially when dealing with big data sets. Also, Ankit talked about one of the regular tasks he used to work on at his previous organisation. He then talked about two important queries:
To fetch the score of the user, based on the email ID
To fetch the top k players on the leaderboard
Hello. In this module you will learn about an extremely important and effective technique called divide and conquer. Let's first look at the roadmap you will follow. In this module, you will learn about various algorithms using two different techniques searching and sorting. You will try to optimize these algorithms using the divide and conquer technique. In the first session, you will learn about the first important technique called searching, where you will learn how to smartly search for an element in a small or big data set. This will help you save on time and go through datasets quickly. You will learn the next technique known as sorting in the next session. So let's begin your journey towards becoming an expert in the concepts of searching and sorting using the divide and conquer techniques. To become as time efficient as possible, all of you must have visited Facebook website, where you type in your email address and press Enter. Website then starts searching for the email address you entered in the database. If the email address is found, it would then try to find the match for the password that you entered with the email address. If the email address is not found, it would tell you that the email address doesn't exist in the database. Now imagine the case when your email ID is somewhere at the end of the database, which has 2 billion entries matching the email ID you entered with. Every ID in the database in such a case will take an insane amount of time. That's where the algorithm analysis you learned in the previous module will be of immense use to you. In reality, it certainly takes much less time for them to find your ID and ask you for the password. How do you think they make it possible with such a huge database? Also, how does the Google search engine find things on internet so quickly when there are billions of entries in it to search for? In this session, we will see if we have better ways algorithms for searching, which saves a lot of time and makes results available to us quickly. So first we will teach you simple but slow order and algorithms. And then we'll teach you faster algorithms that will run in order login time based on the idea of divide and conquer. Any algorithm we try, we will measure its efficiency using big O, which we learned about in the previous module. In my previous company where we used to make mobile games, I came across a situation where I had to design a real time leaderboard for our users. In that leaderboard, our users should be able to see at what ran they stand among the other players and who were the top players in the charts. In the leaderboard we had user objects, and in those user objects, we used to have email ID of the user. Email ID was the primary Identifier of the user and we used to store the score of the user. The scoring was cumulative. So every time a user scored, it used to get added to his previous score.
The two most important queries which we received in our system were the first one was get my score. That request had an email address and we had to fetch the score of the user based on the email address. The second query was Get top k players. That request had a parameter k and we had to fetch the top k players in the leaderboard. And both of these queries had to be as fast as possible. These sort of requests are pretty common when you are designing leaderboards. Whatever you learned in this module will be of immense help to you in solving such problems.
This module teaches the divide and conquer technique for algorithm design optimization.
The module covers searching and sorting algorithms, optimizing them using divide and conquer.
The first session covers searching for elements in datasets using efficient algorithms to save time.
The next session covers sorting techniques using divide and conquer.
Algorithm efficiency is measured using Big O notation.
Real-life examples are given, such as Facebook's search for email addresses and Google's search engine.
The module concludes with practical applications of the techniques learned, such as designing real-time leaderboards.
Let’s now move to the first search technique, linear search.