- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 510 Articles for Algorithms
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
676 Views
A list of different locks and another list of keys are given. Our task is to find the correct match of lock and key from the given list, and assign that key with the lock when it is correct.In this approach we will traverse all of the locks and create a hash-map, after that, each key is searched in the hash-map. When the key is matches, then that is marked as a valid key and assigned with a lock.Input and OutputInput: The lists of locks and keys. lock = { ), @, *, ^, (, %, !, $, &, #} ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
A list of different nuts and another list of bolts are given. Our task is to find the correct match of nuts and bolts from the given list, and assign that nut with the Bolt, when it is matched.This problem is solved by the quick-sort technique. By taking the last element of the bolt as a pivot, rearrange the nuts list and get the final position of the nut whose bolt is the pivot element. After partitioning the nuts list, we can partition the bolts list using the selected nut. The same tasks are performed for left and right sub-lists ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
473 Views
Let us consider a string is given, we know that the string is a sequence of characters. The Lexicographical rotation is the rotation of string, to convert characters in lexicographical order.The solution is simple, we simply concatenate the given string with itself, then in another array, all rotation of strings are stored. After that sort the array in ascending order, the lowest value is the final result.Input and OutputInput: The String “BCAAFAABCD” Output: Rotated String: “AABCDBCAAF”AlgorithmminStrRotation(str)Input − The given string.Output − Minimum string rotation required.Begin n := length of str define strArr to store all rotations tempStr := ... Read More
![Monica Mona](https://www.tutorialspoint.com/assets/profiles/13520/profile/60_87298-1512650151.jpg)
849 Views
From a set of data, this algorithm will find the largest element to kth largest element of the array.This problem can be solved easily by sorting the array. We can sort them either in ascending order or in descending order. Solving it in descending order, we can get first k elements to find our result.Input and OutputInput: The elements of an array: {1, 23, 12, 9, 30, 2, 50, 63, 87, 12, 45, 21}, K = 4 Output: 4 largest elements are 87 63 50 45AlgorithmkthLargestElement(array, n, k)Input: The array, number of elements in the array, place k.Output: Display largest ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
3K+ Views
Jarvis March algorithm is used to detect the corner points of a convex hull from a given set of data points.Starting from a leftmost point of the data set, we keep the points in the convex hull by anti-clockwise rotation. From a current point, we can choose the next point by checking the orientations of those points from the current point. When the angle is largest, the point is chosen. After completing all points, when the next point is the start point, stop the algorithm.Input and OutputInput: Set of points: {(-7, 8), (-4, 6), (2, 6), (6, 4), (8, 6), ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
5K+ Views
The convex hull is the minimum closed area which can cover all given data points.Graham’s Scan algorithm will find the corner points of the convex hull. In this algorithm, at first, the lowest point is chosen. That point is the starting point of the convex hull. Remaining n-1 vertices are sorted based on the anti-clockwise direction from the start point. If two or more points are forming the same angle, then remove all points of the same angle except the farthest point from start.From the remaining points, push them into the stack. And remove items from stack one by one, ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
993 Views
All even numbers from 4, can be expressed as a sum of two prime numbers. Sometimes a number can have more than one sum of the prime number combination.For an example the number 10 = (5 + 5) and (7 + 3)This algorithm will find all of the combinations of prime sums for a given number. When one number x is prime, then only we will check whether (number - x) is prime or not, if yes, the sum of x and (number – x) represents the even number.Input and OutputInput: Even number: 70 Output: Prime sums 70 = 3 ... Read More
![Monica Mona](https://www.tutorialspoint.com/assets/profiles/13520/profile/60_87298-1512650151.jpg)
1K+ Views
One matrix is given; the matrix is representing the one screen. Each element (i, j) of the screen is denoted as a pixel, the color of that pixel is marked with different numbers. In this algorithm, the pixels will be filled with new color when it is already in selected previous color. If the previous color is not the previous color, that pixel will not be filled. After filling a pixel, it will check for its up, down, left and right pixels to do the same.The idea is really simple, first, we check whether the selected position is colored with ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
2K+ Views
This algorithm will convert a given number into English words. Like 564 will be Five Hundred and Sixty-Four. For this algorithm, some predefined strings are given, from that list, it will get the proper words to make into words.The lists are like Units: it will hold all words for (0 to 9) like Zero, One…Nine twoDigits: it will hold all numbers from (10 - 19), like Ten, eleven…NineteentenMul: For ten multiples, (20-90), like Twenty, Thirty, … Ninety.tenPower: It is for Hundred and Thousands as power 2 and 3 of 10Input and OutputInput: The number: 568 Output: Five Hundred And Sixty EightAlgorithmnumToWord(num)there are some ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
516 Views
Two numbers are given as a binary string, our task is to find the result of multiplication for those numbers in a faster and efficient way.Using the Divide and Conquer strategy, we can solve the problem, in a very efficient manner. We will split the numbers into two halves.let Xleft and Xright are two parts of first number X, and Yleft, Yright are two parts of second number Y. So the product;To make it simple, we can perform this operationInput and OutputInput: Two binary numbers: 1101 and 0111 Output: The result is: 91AlgorithmaddBitString(num1, num2)Input: Two numbers to add.Output: The result after ... Read More