What is Algorithm: Definition and 721 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. shlomi123

    I Roulette Prediction Algorithm Problem

    The roulette prediction algorithm is described here: http://pingless.co.il/roulette.pdf And I have a problem with the formula attached Where teta θ is position, velocity and acceleration of the ball. g is garvity force. r is the ball radius from center of the roulette. a is stator incline...
  2. D

    I HHL Algorithm for Solving Linear Equations

    I have a question about HHL algorithm https://arxiv.org/pdf/0811.3171.pdf for solving linear equations of the form: A x = b Where A, x and b are matrices Take for example 4x1 + 2x2 =14 5x1 + 3x2 = 19 HHL apply the momentum operator eiAτto/T on the state, do a Fourier Transform on |b> and...
  3. D

    I Oracle questions in Grover's Algorithm

    Following these links: https://people.cs.umass.edu/~strubell/doc/quantum_tutorial.pdf https://www.codeproject.com/Articles/1131573/Grovers-Search-Algorithm-explained I have these questions: The Oracle "knows" the correct bits in the first invocation itself. So why do sqrt(N) invocations where...
  4. M

    Why must q be the least element for (q+1)a to be greater than b?

    Homework Statement Let a, b be natural numbers then there exists a unique pair (q,r) that are elements of the non-negative integers such that b=aq+r and 0 is less than or equal to r which is less than a I have a question regarding the existence part of the proof, now if I assumed a is less...
  5. Arman777

    Python Verlet algorithm and Lorentz force trajectory

    I need to write a code to calculate the trajectory of the particle under lorentz force.Since the position depended equations are hard to solve I ll use a code, how can I appraoch this problem. I should use veloctiy-verlet algorithm or any suggestions ? You should consider that lorentz force is a...
  6. A

    MHB Does Algorithm Terminate when Input is not in the Finite Set?

    A theorem states: Any finite set of natural numbers is effectively decidable. I understand the construction of the (brute force) algorithm to check every input for inclusion in the set. However, if the input is not included in the set, the algorithm would not terminate, and we require...
  7. Joppy

    MHB Fast algorithm for polygon/line intersects

    If we define our polygons as a collection of lines, then each polygon has slopes $\vec{m}$ and y-intercepts $\vec{c}$. For a single line in the plane $y = ax + b$ amounts to finding $x = \dfrac{b - \vec{c}}{\vec{m} - a}$, which is fine. But then we need to sift through the solution vector $x$...
  8. Arman777

    Making an Algorithm to Check Whether a Number is a Prime Number

    1. The problem statement, all variables, and given/known data Create algorithm steps that for a given number (N) is prime or not Homework Equations 3. The Attempt at a Solution I am trying to create an algorithm but I am stuck at some place. Here is my trying. 1-Input a...
  9. S

    Is there a flaw in my longest common subsequence algorithm?

    What I have is /// <summary> /// Provides a solution to the Common Child string problem /// https://www.hackerrank.com/challenges/common-child/problem /// </summary> public static class CommonChild { public static int Solve(string first, string second)...
  10. Pereskia

    MHB Algorithm: maximize sum of increasing functions

    Hi! (Not sure which forum to pick for this question. This looked like the best one. I apologies if it is not) I have a number of functions (say m functions) with integer domain. All functions are increasing. (Increasing in the sense not decreasing, $f(n+1) \ge f(n)$.) I want an algorithm to...
  11. I

    A Algorithm to Pair Even Boolean Array Elements

    Suppose an array of booleans with an even number of true values. I need an algorithm that, given an address containing a true (say, 3), returns the address of another true (say, 25), such that if I call the algorithm for 25, it returns 3. No storage of old choices are allowed since this...
  12. ChrisVer

    What is the Most Efficient Algorithm for Finding Duplicates in an Array?

    Hi, I was wondering (and I am somewhat non-confident about my time measurement)... if I have an object that has several numbers (associated with each event): A = (A_0, A_1, A_2,...,A_{N-1})... what's the best way to find if there are duplicates in them? At first I thought the simplest piece of...
  13. T

    Perceptron algorithm initial vector

    In a scientific paper (Neural Networks: A Systematic Introduction, page 86) about the Perceptron Algorithm I found: A good initial heuristic is to start with the average of the positive input vectors minus the average of the negative input vectors. In many cases this yields an initial vector...
  14. S

    O(log k) GCD Algorithm which yields x and y |GCD(a,b)=ax+by

    Homework Statement For some reason, my book's solution for this problem is given in a very wordy way, rather than in (Pascal-style) pseudo-code (which is what this book usually gives its solutions in). Here is the problem's statement and solution.: PROBLEM STATEMENT: PROBLEM SOLUTION...
  15. S

    Given this modification to Euclid's algorithm, prove [....]

    Homework Statement PROBLEM STATEMENT: http://dpaste.com/0GN9MQ2 BOOK'S SOLUTION: http://dpaste.com/0ZQ0YQM Homework Equations m ⋅ u + n ⋅ v = 2ab GCD(a,b) ⋅ LCM(a,b) = ab z = 2 * LCM(a,b) z ?=? (m ⋅ u + n ⋅ v) / GCD(a,b) The Attempt at a Solution How does the author go from m ⋅ u + n ⋅ v =...
  16. S

    Question about O(log n) algorithm for computing a^n

    Homework Statement Let a be an integer and n be a non-negative integer. Without changing the values of a and n, produce an algorithm, of O(log n) complexity, which computes a^n. Homework Equations For integers a, n and i, where n >= 0 and is even, where i >= 1 and where a has no further...
  17. J

    A Shor's algorithm - need to uncompute auxiliary qubits?

    Due to required reversibility, classical function (f(a)=y^a \mod N) in Shor's algorithm needs a lot of auxiliary qubits. I was afraid that their later treatment might influence the computation - and just got confirmation from Peter Shor himself: that we need to "uncompute" these auxiliary...
  18. D

    Algorithm to matrix product MSR format

    Hi everybody, I'm writing some algebra classes in C++ , Now I'm implementing the modified sparse row matrix , I wrote all most all of the class, but I didn't find the way saving computing time to perform the product of two Modified sparse row matrix .. if you don't know it you can read in the...
  19. evinda

    MHB Questions about analysis of algorithm

    Hello! (Wave) The following algorithm is given: And it says the following: First of all, at the first line do they mean that the content of j is i? About the second line, why don't we subtract the polynomial $f[i] \cdot u \cdot h \cdot X^i $ from $(f[0], \dots, f[d'])$? Is there then...
  20. S

    Algorithm for computing the depths of all the nodes of tree

    Homework Statement Give an algorithm for computing the depths of all the nodes of a tree T, where n is the number of nodes of T. a) What is the complexity of your algorithm in terms of Big-O? b) What is the best possible complexity that you believe can be achieved when solving such problem...
  21. Erenjaeger

    B Bellman's and Bellman-Ford algorithm

    In the SPP part of my networks textbook, it refers to Bellman's algorithm but also at times Bellman-Ford's algorithm, is there a difference between the two or is that just the writers of the textbook not being consistent with what they call it?
  22. Erenjaeger

    I Is A→E→D→F a valid solution for Dijkstra's algorithm?

    In this video the solution is: A→B→D→F but the paths A→B→D and A→E→D both have a distance of 9, so when you get to D you can either have [B,9] or [E,9] where the first entry is the predecessor and the second entry is the 'cost' on that path so far, or here the distance. is the solution A→E→D→F...
  23. A

    Why does this algorithm work for calculating ln(x)?

    Homework Statement I found this algorithm online for computing ln(x). I use the babylonians method for computing square root if it is relevant. fun naturalLog(desired: Double): Double { var naturalLog = desired // desired = x for(number in 0..9) { naturalLog =...
  24. S

    Calculations prior to determining algorithm complexity order

    Hello to everyone who's reading this. The problem that I'm struggling with, and it's solution, are typed below.: Homework Statement PROBLEM STATEMENT: Assume an array [0, ... n - 1] of int, and assume the following code segment: for (int i = 0; i < n - 1; i++) if(a[i] > a[i+1])...
  25. P

    I Algorithm to create a composite score

    Hi everyone! This is an application question. I would like to get some advice about how to calculate a score based on a set of individual scores in a way that makes most sense. CONTEXT: I am going over some criteria for judging usability of hypotheses. I came up with a whole bunch about a...
  26. T

    Performing Metropolis-Hastings algorithm for a Poisson Distribution

    Homework Statement The number of busy lines in a trunk group (Erlang system) is given by a truncated Poisson distribution. I am asked to generate values from this distribution by applying the Metropolis-Hastings algorithm. Homework Equations The distribution is given in the attached picture...
  27. evinda

    MHB Number of steps of euclidean algorithm

    Hello! (Wave) I am looking at the following exercise: Let $b=r_0, r_1, r_2, \dots$ be the successive remainders in the Euclidean algorithm applied to $a$ and $b$. Show that after every two steps, the remainder is reduced by at least one half. In other words, verify that $$r_{i+2}< \frac{1}{2}...
  28. T

    Euclidean Algorithm terminates in at most 7x the digits of b

    Homework Statement please see the image Homework Equations I'm not sure if this is relevant: ##r_2 \leq \frac{1}{2}r_1## ... ##r_n \leq (\frac{1}{2})^nr_1## The Attempt at a Solution i have shown that ##r_{i+2} < r_i## by showing the ##r_{i+2} - r_i## is negative, but how do I show that the...
  29. kolleamm

    I Arm reaching algorithm determine angles

    I'm trying to find an algorithm for extending an arm as close as possible to an object. There's two bones the upper arm bone and the lower arm bone, and three points : shoulder , elbow, hand How can I figure out the closest possible configuration towards a fourth point which is the object it's...
  30. J

    A Shor's algorithm and similar exploitation of QM?

    Shor's algorithm is rather the most interesting quantum algorithm as it shifts a problem which is believed to need exponential classical time, to polynomial time for quantum computer, additionally endangering asymmetric encryption like RSA and ECC. The real question is if there are other...
  31. S

    Comp Sci Is my (Java-code) algorithm for Regula Falsi 100% correct?

    Homework Statement I'm just trying to do homework problems involving the Regula Falsi numerical method, and the solutions in my books seem to have a lot of mistakes, so I was hoping I could make a program to generate solutions for myself, so that I could check if I'm doing things correctly when...
  32. F

    Using a recursive algorithm to find the value of a game

    Homework Statement Imagine you are playing a game with me, of drawing balls from a box. There are two blue balls and two red balls. They are picked with equal probability, and are drawn without replacement. If you draw a blue ball, I give you $1. If you draw a red ball, you pay me $1.25. What...
  33. uzi kiko

    Is there a more efficient algorithm for solving license plate math game?

    Hi We have a family game when we are stuck in traffic similar to https://en.wikipedia.org/wiki/Countdown_(game_show) (I know I am a nerd ) In the game we are looking at license plate of the car in front and trying to get 120 using the 4 arithmetic operators (+-*/) and the numbers in the license...
  34. Jamison Lahman

    Algorithm Optimization [Python]

    Homework Statement Given a list of integers and a single sum value, return the first two values (parse from the left please) in order of appearance that add up to form the sum. sum_pairs([11, 3, 7, 5], 10) # ^--^ 3 + 7 = 10 == [3, 7] sum_pairs([4, 3, 2, 3, 4]...
  35. Telemachus

    Is this algorithm stable? (time dependent diffusion equation)

    Hi there. I was trying to solve the time dependent diffusion equation in only one dimension. I derived a explicit scheme using a finite difference in the time variable. The equation I am trying to solve is: ##\displaystyle \frac{1}{c} \frac{\partial \phi(x,t)}{\partial t} -...
  36. S

    Counterexamples to Claim that A = (10,1,1,10) for B = (10,1,1,10)?

    I'm trying to solve a problem that amounts to: Given b0, ..., bn-1 where1 <= bi, find the max of |a0 - a1| + |a1 - a2| + ... + |an-2 - an-1| where 1 <= ai <= bi. I'm 100% confident that each ai is either 1 or bi. I'm 90% confident that the elements a0, ..., an-1 are either 1, b0, 1, b1...
  37. R

    I Shor Algorithm - Post measurement state

    Hello! So I'm working to try to understand shor algorithm and I have some doubts. So, after the hadamard gates we apply the unitary gate that construct the function yk mod N. Next we do a measurement in the second register to get some function value. So, when I do this measurement on the...
  38. S

    Is there an easy way to find ints i,j,k satisfying i*j=k^2?

    Long-story short, as part of a larger problem I'm trying to solve, I need all i,j>=0 such that i*j=k2 for all k in [1, ..., n]. What I'm doing currently is iterating through [12, 22, ..., n2] and for each value m I'm using public static IEnumerable<Tuple<int, int>> Multipliers(ulong...
  39. R

    I Arithmetic Block in Shor Algorithm

    Hello everyone! So I was looking at Shor Algorithm for prime factorization and I have some doubts in the arithmetic part. Let's define a function f that : f(x) = ax mod N. The middle step in shor algorithm is to calculate, simultaneously, all values of f. In some papers and books, I saw some...
  40. binbagsss

    Maximal flow problem: ford-fulkerson algorithm

    Homework Statement Question attached: Homework Equations see below The Attempt at a Solution - The theorem without prove i require needed is that the cut of maximum flow is given by the cut of minimal capacity. My proof would be along the lines of: - using this theorem, obviously 100 is a...
  41. A

    Rienforced Concrete Column Cost Optimization with Genetic Algorithm

    Hi, I'm a Civil Engineering student doing my final project for my BE degree. I have developed a software that uses a genetic algorithm for optimizing reinforced concrete columns. I have tested my program with a 17 stories building, and got some very unusual results in the design but much...
  42. V

    Why does not this Erdos-Renyi C code work?

    Homework Statement I need to write an Erdos-Renyi random graph, by using the adjacency matrix (or alternatively list) and calculate the fitness of the graph. Definition: G(n, p) is a random graph with n vertices where each possible edge has probability p of existing.Homework Equations The...
  43. D

    I They physics of phase inversion in Grover's algorithm

    How would this operator be implemented physically if we had a quantum computer? In Grover's algorithm this magical operator is often called "phase inversion". Here is the operator from wiki: https://wikimedia.org/api/rest_v1/media/math/render/svg/07fb23bffa787430b084971c6a108a8f6ff6c2b3 It’s...
  44. E

    Algorithm Efficiency: Analyzing "xyzzy" Operation

    Homework Statement Consider the ##xyzzy## algorithm below. This algorithm takes a linear collection (e.g., a list or array) of size ##n## as an argument (i.e., as the input to the algorithm) and produces no return value (i.e., has no output, but might alter the linear collection). Note that the...
  45. E

    Algorithm Analysis - Growth of Functions

    The problem statements, all variables and given/known data: Question 1 Question 2 Relevant equations: Provided in question snips. The attempt at a solution: Question 1: I think qux is the answer because it properly increments k by 1 in each iteration. j = j * 2 means j is always 0 so its...
  46. S

    Is my code suffering from an arithmetic error?

    What it does is described well in my comments. I'm using decimal, which is more precise than double but has a smaller range of values. https://msdn.microsoft.com/en-us/library/ms228360(v=vs.90).aspx const decimal pi =...
  47. S

    Rounding error making my graphics barely off?

    I'm trying to draw a circle and a (possibly rotated) square on a grid. I have the circle part down and it's the square that is giving me trouble. I am originally given 2 points which represent the coordinates containing opposite ends of the square. For example, those 2 points would be (8,14) and...
  48. F

    How Does the Metropolis Algorithm Calculate Specific Heat in a 2D XY Model?

    Homework Statement In a XY - model in two dimensional square lattice. I want to calculate specific heat capacity, <E> and <E^2>. By using the formula: H = -Jsum(<i,j>)Cos(tetha(i)-tetha(j)) The Metropolis algorithm reads: Simulations for Statistical and Thermal PhysicsHomework Equations H =...
  49. S

    How to do a running median in n*log2(n)?

    So I came up with the following solution which is n*log2(n) since the input is n elements and I use a binary insertion and calculating the median is constant time. This is passes all the test cases in the tests that don't time out. I need to figure out how to make it faster so I beat the...
  50. A

    Algorithm for checking clumps inside an array not working

    Homework Statement Say that a "clump" in an array is a series of 2 or more adjacent elements of the same value. Return the number of clumps in the given array. countClumps([1, 2, 2, 3, 4, 4]) → 2 countClumps([1, 1, 2, 1, 1]) → 2 countClumps([1, 1, 1, 1, 1]) → 1 Homework Equations The logic is...
Back
Top