June 2020 – Brain Mentors Skip to content

Single Number | Arrays | Data Structures and Algorithms

Single Number is a problem statement that is based on arrays from Data Structures and Algorithms. In this problem, we can find the single number that occurs an odd number of times in the given array. The first approach to solve this problem is: Brute Force Algorithm As you can see we have an array with size 5. To find the single number that occurring the odd number of times in this given array. So, we can traverse from left to right side of the array, one by one select each element and compare it with all the remaining elements of the array. If the selected element is equal to any remaining elements of the array, so for this we keep one variable that is count variable which is used to increment it’s value by 1 each time and If the count variable’s value is odd. It means, it is

What is Recursion? | Concepts of Recursion

The process in which a function calls itself is called recursion. Recursion is a method where the solution of a problem depends upon the solutions that are small instances of the same problem.  The diagram shows how recursion works:  Why we need recursion? Any problem can be solved by a recursive method as well as by the iterative method. But whenever we have a problem that is complex to do just by iterative/looping method. Then we are going to divide the problem into a smaller instance of the same problem that means we solve it by the recursive method. Recursion vs Iteration Recursion Iteration Function calls itself. A set of instructions repeatedly executed. For functions For loops Infinite recursion can lead to system crash/stack overflow. Whereas, infinite iteration consumes CPU cycles. The time complexity of recursion can be found by finding the value of the nth recursive call in terms

Leaders In An Array – Data Structures & Algorithms

Leaders in an array is an easy problem of arrays from Data Structures and Algorithms. Leaders in the array mean that element is greater than all its right side elements of the array. So there are two approaches to find the leaders in an array: Brute Force Algorithm  Scan Array from Right 1. Brute Force Algorithm As you can see, we have an array of size 5. In this approach, we can traverse the array from left to right and each element picks one by one and check with all its right side elements of the array, which is used to checking that it is greater or not than its right side elements of the array. So those are greater than their right side elements of the array, then they become the leaders of this given array. The rightmost element is always a leader because there is no element to

Introduction to Natural Language Processing

NLP short for Natural Language Processing is one of the major areas of Data Science. When it comes to text processing or when you send or receive some sort of data in any text format whether it is a mail or a message or anything else then just think about it that how you are going to apply machine learning on it. A lot of applications are using NLP like Apple Siri, Windows Cortona, Amazon Alex, etc. In this blog we are going to cover : Usage of NLP Text Processing Approach Convert Text document to vector form Implementation using Python and NLTK Usage of NLP Let’s understand the use of NLP with the help of a few examples : Gmail (Spam Classification) When you receive a mail on Gmail then how Gmail finds out whether this mail will go to your inbox or the spam box. Sentiment Analysis When

Sign Up and Start Learning