# What is Algorithms: Definition and 151 Discussions

In mathematics and computer science, an algorithm ( (listen)) is a finite sequence of well-defined, computer-implementable instructions, typically to solve a class of specific problems or to perform a computation. Algorithms are always unambiguous and are used as specifications for performing calculations, data processing, automated reasoning, and other tasks. In contrast, a heuristic is a technique used in problem solving that uses practical methods and/or various estimates in order to produce solutions that may not be optimal but are sufficient given the circumstances. As an effective method, an algorithm can be expressed within a finite amount of space and time, and in a well-defined formal language for calculating a function. Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that, when executed, proceeds through a finite number of well-defined successive states, eventually producing "output" and terminating at a final ending state. The transition from one state to the next is not necessarily deterministic; some algorithms, known as randomized algorithms, incorporate random input.The concept of algorithm has existed since antiquity. Arithmetic algorithms, such as a division algorithm, were used by ancient Babylonian mathematicians c. 2500 BC and Egyptian mathematicians c. 1550 BC. Greek mathematicians later used algorithms in 240 BC in the sieve of Eratosthenes for finding prime numbers, and the Euclidean algorithm for finding the greatest common divisor of two numbers. Arabic mathematicians such as al-Kindi in the 9th century used cryptographic algorithms for code-breaking, based on frequency analysis.The word algorithm itself is derived from the name of the 9th-century mathematician Muḥammad ibn Mūsā al-Khwārizmī, whose nisba (identifying him as from Khwarazm) was Latinized as Algoritmi. A partial formalization of the modern concept of algorithm began with attempts to solve the Entscheidungsproblem (decision problem) posed by David Hilbert in 1928. Later formalizations were framed as attempts to define "effective calculability" or "effective method". Those formalizations included the Gödel–Herbrand–Kleene recursive functions of 1930, 1934 and 1935, Alonzo Church's lambda calculus of 1936, Emil Post's Formulation 1 of 1936, and Alan Turing's Turing machines of 1936–37 and 1939.

View More On Wikipedia.org
1. ### Python Question about learning programming

Hello, I am currently learning Python as a basis for further studies in programming. The course that I took at college was quite basic, teaching us the basic concepts required for programming, and some web oriented concepts like data scraping, APIs, automated tasks using bots. As I delved...
2. ### Non youtube courses and paid textbooks to learn algorithms?

I am not going to watch youtube anymore because of advertisements and it was never worth it anyways to pay for. I'm not going to pay for either a college fail student trying to earn some sidecash in India or some genuis professor who simply doesn't care if the students learn from him. Youtube is...
3. ### Courses Which C++ book is best for learning algorithms and data structures?

As I said earlier, I've already grasped basics of C++. Since my ultimate goal is to work in coding industry, for interviews, I need to prepare for algorithms and data structures, grind leetcode. Between C++ and Java, I choosed C++ because that was taught in our university. I won't read the...
4. ### Best courses to learn Data Structures and Algorithms in C/C++/JS

Do you know any such good resources? I want to improve my problem solving skills. I also want to practice competitive programming, so any good courses for that? I want to practice pointers any good courses for that?
5. ### Algorithms for quadcopters to use back-EMF to detect obstacles close?

Would it help to study Verilog (VHDL) or Field-Programmable-Gate-Arrays (FPGA) if self-crafted x64/aarch64-assembly would take too much power/be too slow?
6. ### Why did I get different accuracy for different algorithms?

Here are the codes(not all might be present, take it with grain of salt). https://github.com/prabesh-regmi/Employee-Promotion-Prediction
7. ### Comp Sci Using Single Source Shortest Path Algorithm to find the longest path

This is the weighted, directed acyclic graph I created in JavaScript class WeightedDirectedGraph { constructor() { this.adjacencyList = {}; } addNode(node) { if(!this.adjacencyList[node]) { this.adjacencyList[node] = []; } } addEdge(node1, node2, direction, weight) {...
8. ### Comp Sci Solving Complexity Issues: Merging Algorithms

So I have this problem to solve, I was thinking that for k=2, the threshold value is too low and inefficient, but I'm not sure when k is at logn or more. If 2 sorting algorithms have the same complexity, won’t merging them be pointless in terms of running time? For b), i think the merged...
9. ### Algorithms for Traveling Purchaser Problem (TPP)

Hey guys, how you doing? Im here to ask for you help. I am writing my bachelor paper as an implementation/review of the TPP algorithms out there. Almost every paper that I read references the Ramesh algorithm, that returns an exact solution for TPP problems, but I just can't find the algorithm...
10. ### MHB Ideals, Varieties and Algorithms

Here you have solutions for the section 1 of the Cox-Little-O'Shea textbook. Please, check exercises 6a and 6b of the Section 1 Chapter 1. You can text me to my whatsapp number +505 81974943 or send me a message to my email gerardforever1@gmail.com. (Ideals, Varieties, and Algorithms. An...
11. ### I Cryptology - Fast Factoring Integers by SVP Algorithms "destroys RSA"

The summary abstract (describes the method) and full paper are linked. Summary abstract https://eprint.iacr.org/2021/232.pdf
12. ### Comp Sci Prove Dijkstra's O(E + VlogV) complexity

My effort: I think that the sorting problem in question is Heap Sort which has an O(logV) complexity, but how can I operate with that information so I can solve this? Can you help me by giving me the outline of an idea?
13. ### Comp Sci Shortest path problem in bipartite graph

Hey guys, I need a little help with this exercise so I know I'm on the right path. My explanation: The Bellman-Ford-Moore algorithm computes shortest paths in O(nm) time, so in this situation we say that in a directed bipartite graph the number of iterations that the algorithm will do is...
14. ### Help understanding genetic algorithms please

HELLO, i have started working on Genetic Algorithm , i have studied evloution of fitness function, but i really could not get it. please help me in this regard wasi
15. ### The Mathematics of the Gods and the Algorithms of Men

Because of having enough on my plate I don't think I would have read this book even without the negative review here, but it is the sort of thing that interests many here. https://beta.spectator.co.uk/article/let-s-leave-philosophers-to-puzzle-over-the-reality-of-numbers (The reviewer is...
16. ### Identifying and understanding random number algorithms

Studying different ways to generate random numbers according to a distribution and the below algorithm describes the "box method". A search on Google led to the Box-Mueller method. Are they related? Also, what would be a simple implementation of this algorithm for ##f(x)=\sin{(x)}## on...
17. ### Comp Sci Time Complexity Algorithm Proof

Use the formal definition of Big-Oh to prove that if f (n) and g(n) are nonnegative functions such that f (n) = O(g(n)), f (n) + g(n) = Ω(g(n)). By the definition of Big-Oh: If f(n) and g(n) are non-negative functions such that f(n) = O(g(n)) there must be positive constants c and n0 such...
18. ### Comparing sorting algorithms -- Insertion Sort vs. Merge Sort

The answer says insertion sort runs faster when we're sorting less than 43 items. I agree but with the condition that the first item will not be faster. Why does the answer not mention this? Is it because it is insignificantly faster?
19. ### Dynamic Programming - Restoring white space between words in a file

All the white space among words in a text file was lost. Write a C++ program which using dynamic programming to get all of the possible original text files (i.e. with white spaces between words) and rank them in order of likelihood with the best possible runtime. You have a text file of...
20. ### MPPT algorithms, perturb and observe algorithm etc

Hi, I had thought that "hill climbing method" is a general terminology to refer to methods such as perturb and observe and incremental conductance. The same is also said here, "The hill climbing based techniques are so named because of the shape of the power-voltage (P-V) curve. This technique...
21. ### Books/Resources for Self Study - Algorithms?

I have a book called "Grokking Algorithms", and when I'm done with my current tabletop game project I plan to work through this as much as it seems worthwhile to do so. I was not at my best when I took the class that corresponds to what's in this book, so I figure it would be good to study it...
22. ### Proof by Induction of String exponentiation? (Algorithms)

Homework Statement Wherein α is a string, λ = ∅ = the empty string, and T* is the set of all strings in the Alphabet T. Homework Equations (exp-Recursive-Clause 1) : α0 = λ (exp-Recursive-Clause 2) : αn+1 = (αn) ⋅ α The Attempt at a Solution [/B] This one is proving difficult for me. I...
23. ### Efficient DC Estimator Algorithms for Half-Cycle Sampled Signals

I wanted to remove the dc component from a signal but i can't use the average method because i have only a half cycle sampled not a full cycle . Is there any algorithm or method that can remove the dc component using only a half cycle? (The signal is sin(x)+2*sin (2x) +3*cos (3x)+4*cos (4x) +5...
24. ### What Are the Best Ways to Contribute and Exchange New Algorithms?

I am someone who likes to come up with new algorithms. Is there a platform to exchange such ideas. Any mailing lists to advance computer science? Perhaps there are programs that accept new algorithms. Sorry if this is a vague post but this is a broad topic.
25. ### Insights Intro to Algorithms for Programming - Comments

Greg Bernhardt submitted a new PF Insights post Intro to Algorithms for Programming Continue reading the Original PF Insights Post.
26. ### Programs Prospects of Pursuing Graduate Studies in Quantum Computing

Hello, I am close to finishing my undergraduate degree in Computer Engineering, and I am very interested in pursuing graduate studies. For a long time, I have been passionate about computer science and I've been looking into the research done in various labs in the schools that I'm considering...
27. ### C/C++ Need Help with Monte Carlo Algorithms in C++?

I would like to discuss code for hit and miss monte carlo methods, and also monte carlo with veto algorithm in C++. Since I am coding in C++ after a long time, I am messed up with syntax too. I have a specific set of problems to work with. If interested we can start working on it here.
28. ### C/C++ What should I be most familiar w/for C++ Data Structs & Algorithms

Hey all, This coming Spring semester (starts in 6 weeks), I will be taking C++ Data Structures and Algorithms at my University. I started programming at University, so my experience is very limited (I've taken 3 programming courses, 1 in Python, 2 in C++). Topics we've covered in C++ were...
29. ### Understanding Big Oh: Exploring the Best Function for a Given Equation

Let me start by saying that this is from a 30 question assessment on Big Oh, Big Theta, and Big Omega. I understood every other question, however, even after being given the correct answer, I do not understand why my answer was wrong for this one. If you could point me in the direction of any...
30. ### Multiplying Big Numbers Using FFT

Multiplying big numbers is a very common application of the FFT, and as such, there are many papers on the subject available online. However, these papers all use sophisticated algorithms where a simple one seems to work. My question is, what's wrong with the simple algorithm: Multiplication...
31. ### Changing Algorithms compatible with AI?

Many have argued using a Godel diagonalization argument that there is no program that can tell ahead of time that the Turing Machine would halt. But would the way to get around this is to have a continuously, changing algorithm in response to learned input? I probably should say rapidly...
32. ### Is there an algorithms to determine correct angles

Homework Statement Hello! I am struggling with plotting polar graphs manually (without any help of the calculator). My main unresolved issue is with finding correct values of theta in a given range. For example, I have an equation: $r = cos(5\theta)$ Homework Equations and I know that the...
33. ### A Any thinking in applying evolutionary algorithms to fusion?

Has any thinking be done in applying evolutionary programs (cellular automata with a purpose) to fusion. It would seem that the current methods that can be applied are few. Evolution, itself, has been described as the dumbest way of realizing the smartest methods of achieving its goals...
34. ### How do you handle algorithms (memorize vs. reference)?

Hey everyone, I'm in my second semester of programming which covers an introduction to C++ (the prior course was Python). We just covered classes and arrays, and are moving onto intro. to algorithms and pointers (we're currently mid-semester). In the algorithms chapter, they covered 4 "basic"...
35. ### Approximation Algorithms: Greedy Load Balancing/Vertex Cover

Homework Statement You are asked to consult for a business where clients bring in jobs each day for processing. Each job has a processing time ti that is known when the job arrives. The company has a set of ten machines, and each job can be processed on any of these ten machines. At...
36. ### Network Flow - Bipartite Matching

Homework Statement You've periodically helped the medical consulting firm Doctors Without Weekends on various hospital scheduling issues, and they've just come to you with a new problem. For each of the next n days, the hospital has determined the number of doctors they want on hand; thus, on...
37. ### Different Node Deletion/Insertion in a Binary Search Tree

What happens, if instead of having any pointer pointing to a node's parent, we had pointer pointing to the node's successor? We know, that Searching would remain the same. But in my opinion Insertion and Deletion would change. This would happen, because in insertion, we would be needed to find...
38. ### I Asymptotics for finding the successors in a Binary Tree

Consider the algorithms : TREE-SUCCESSOR(x) 1. if x.right_child !=NIL 2. return TREE-MINIMUM(x.right_child) 3. y=x.parent 4. while y != NIL and x == y.right_child 5. x = y 6. y = y.parent 7. return y TREE-MINIMUM(x) 1. while x.left_child != NIL 2. x = x.left_child...
39. ### Proving n^2 + 3n^3 is Θ(n^3) for n >= 0

First off I'm studying for an exam tomorrow, this isn't homework. Also, I've already written the proof and verified I've gotten the correct answer. I'm here to ask some questions about the solution that I am not completely confident I understand. Here's the problem: Prove that n2 + 3n2 is Θ(n3)...
40. ### A Algorithms for solving recurrence relations?

Is there good survey of known algorithms for solving recurrence relations ? By "solving" a recurrence relation such as a_n = \sum_{i=1}^{k} { c_k a_{n-k}} , I mean to express a_n as a function of n . In the case that the c_i are constants the algorithm based on the "characteristic...
41. ### Other Neural networks and genetic algorithms

Hi. First of all, I am a beginner when it comes to NN and GA. I have a good enough math background though. Could anyone suggest me a good book that covers these topics in an intermediate level? Obviously a very in-depth coverage is hard to expect but I would like something more than a few pages...
42. ### Finding all the "move combinations" to partition an array

of size N into an K subgroups. I've been trying for hours to do this and still haven't found a solution. Example: The array {A,B,C} of size N=3 and I want all the move combinations that make it into K=1 subgroups. The only such subgroup is the one with all the elements, and I can get that with...
43. ### I The algorithms involved in finding a solution with numerical methods

what are all the algorithms involved in finding a solution with numerical methods ?
44. ### C data structures and algorithms - graph problem

Homework Statement Given connected, directed and weighted (positive weights) graph. Find the shortest cyclic path for each vertex. Cycles have back edges and can also be self loops. 2. The attempt at a solution I need some clarifications for this problem related to implementation in C. After...
45. ### MHB Ideals and GCDs in k[x] .... .... Cox Et al: "Ideals, Varieties and Algorithms"

I am reading the undergraduate introduction to algebraic geometry entitled "Ideals, Varieties and Algorithms: An introduction to Computational Algebraic Geometry and Commutative Algebra (Third Edition) by David Cox, John Little and Donal O'Shea ... ... I am currently focused on Chapter 1...
46. ### Courses Taking Automata Theory and Analysis of Algorithms together?

So I'm at a bit of a cross roads. For this summer semester, due to class restrictions I can only take either operating systems with Automata Theory, or Analysis of Algorithms with Automata Theory. I've heard from many people that Algorithms is a nightmare, and I'm not sure if taking Automata...
47. ### Proving n log n is Big-Oh of log(n!)

To prove that n log n is big oh of log(n!), I did: n log n <= C log(n!) n log n/ log(n!) <= C Let k = 1 n > k, so for n = 2 2 log 2 / log 2 <= C 2 <= C C is an element of [2, infinity) Taking C = 2 and k = 1 can we say, n log n <= 2 log(n!) and hence n log n is big oh of log(n!) ?
48. ### Data structure and algorithms time computation?

Assume the following set of instructions: 1. i = 0 2. if i < n, goto line 6 3. if A [ i ] = = x, goto line 7 4. i++ 5. goto line 2 6. return false 7. return true Assume that line i take Ci time, where Ci is a constant. The worst case total time of running this block of code can be calculated...
49. ### Can the entropy be reduced in maximization algorithms?

In maximization algorithm like that is used in artificial intelligence, the posterior probability distribution is more likely to favour one or few outcomes than the prior probability distribution. For example, in robots learning of localization, the posterior probability given certain sensor...
50. ### Data structures and algorithms: Priority queue as Binary Tree

Homework Statement Explain and compare two efficient implementations of a priority queue using binary tree. Ilustrate this on an example of ascending priority queue that is created when elements 15, 38, 45, 21, 8, 55,20 are inserted and the two largest elements are deleted. Homework Equations...