Algorithms for Competitive Programming.

Linear Search Approach: A simple approach is to do a linear search. The time complexity of the Linear search is O(n). Another approach to perform the same task is using Binary Search.

Search Algorithms

Exponentiation by squaring or Binary exponentiation is a general method for fast computation of large positive integer powers of a number in O(log2N).

Exponentiation by Squaring

In computer science, pattern matching/searching is one of the most important problems. There has been a lot of research on the topic.

String Matching and Parsing

Knuth-Morris-Pratt algorithm is used in cases where we have to match a short pattern in a long string. For instance, when we Ctrl+F a keyword in a document.

KMP Algorithm (String Matching)

Many times we have to validate a string by parsing over a predefined restriction. It is heavily used in web development for URL parsing and matching.

Regular Expression (String Parsing)

There are deterministic and probabilistic ways of determining whether a given number is prime or not. Here are both deterministic and probabilistic (nondeterministic) ways.

Primality Testing Algorithms

The length of the range is a crucial factor because programmers have to allocate a certain amount of memory according to the range.

Sieve of Eratosthenes (deterministic)

If a number is proved to be composite, then it sure isn’t a prime number. Miller-Rabin is a more sophisticated one than Fermat’s.

Fermat primality test and Miller–Rabin primality test

In the field of computer science, sorting is the most thoroughly studied concept. The simple concept is to arrange the items of a list in a determined order.

Sort Algorithms

Dynamic programming (DP) is a method for solving a complex problem by breaking it down into simpler subproblems.

Dynamic Programming

Hash lookup is currently the most widely used technique to find appropriate data by key or ID. Formerly, to look for indexes programmers used to rely on sorting and binary search.


Next: MBA vs MS in Business Analytics.

+ +

+ +

Thanks For Reading!