Conclusion
of usecases
An algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output. An algorithm is thus a sequence of computational steps that transform the input into the output.
Lets rephrase it
Forms,
CRMs
REST services
etc.
NO
YES
New revolutionary products & platforms,
science,
devices
You not learning algorithms, you learning techniques, which will help you to solve your task more efficiently
Knowing algorithms will help you:
We didn't cover
Or may be we did ?
The problem at hand is coin change problem, which goes like given coins of denominations 1,5,10,25,100; find out a way to give a customer an amount with the fewest number of coins.
Amount: 30
Solutions : 3 X 10 ( 3 coins )
6 X 5 ( 6 coins )
1 X 25 + 5 X 1 ( 6 coins )
1 X 25 + 1 X 5 ( 2 coins )
Isn't this a Dynamic Programming problem ?
const nominals = [1, 5, 10, 25];
function gready(amount, nominals) {
let res = [];
let totalAmount = amount;
for(let i = nominals.length - 1; i >= 0; i--) {
const coinValue = nominals[i];
const typeCount = Math.floor(totalAmount / coinValue );
res.push({ nominal: coinValue, count: typeCount });
totalAmount -= ( typeCount * coinValue);
}
return res;
}
function dpChange(amount = 5, nominals = [1, 5]) {
const cache = [ { count: 0, combo: [] } ];
for(let curr of nominals) {
for(let i = 1; i <= amount; i++) {
let minPossible = { count: Infinity };
if (curr <= i) {
const left = cache[i - curr]
const cand = left.count + 1;
if (cand < minPossible.count) {
minPossible = { count: cand, combo: [curr, ...left.combo] }
}
}
if (!cache[i] || cache[i].count > minPossible.count) {
cache[i] = minPossible;
}
}
}
return cache[amount]
}
What's the difference between greedy algorithm and dynamic programming?
A Greedy algorithm is an algorithmic paradigm that builds up a solution piece by piece, always choosing the next piece that offers the most obvious and immediate benefit.
Typical problems
In Theoretical Computer Science, the two most basic classes of problems are P and NP
P includes all problems that can be solved efficiently. For example: add two numbers. The formal definition of "efficiently" is in time that's polynomial in the input's size.
NP includes all problems that given a solution, one can efficient verify that the solution is correct
There are optimization problems associated with several of the NP-complete problems that we have encountered. Here are a few.
Traveling Salesman Optimization Problem. Given a distance matrix, find the shortest traveling salesman tour.
Maximum Clique Problem. Given an undirected graph G, find a largest possible clique in G.
Min-Color Problem. Given an undirected graph G, color the vertices G with the fewest possible colors, ensuring that no two adjacent vertices have the same color.
Longest Path Problem. Given an undirected graph G and two vertices u and v, find a longest simple path from u to v.
All of those problems are NP-hard. Each one is closely related to a known NP-complete problem. Let's take the Maximum Clique problem (MAX-CLIQUE) as an example. CP is the Clique problem.
NP-hard problems are often tackled with rules-based languages in areas including:
Prime number is important when it comes to Cryptography. Specially RSA algorithm. This is because to hack it a common method is to use addition subtraction, and other elementary operators which can be difficult with prime number codes.
AKS algorithm
The Bitwise Algorithms are used to perform operations at bit-level or to manipulate bits in different ways. The bitwise operations are found to be much faster and are some times used to improve the efficiency of a program.
Non IT person
everage
outsource developer
You after compleating and (realizing/practicing) the cource
What should be your goal
Ability to solve complex problems graph
Introduction to Algorithms, 3rd Edition (The MIT Press)
Cracking the Coding Interview: 189 Programming Questions and Solutions