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. M

    MHB What does the algorithm calculate?

    Hey! :o We have the following i <- 0 j <- 0 x <- 1 y <- 1 z <- 1 c <- 1 u <- 1 while i<n do i <- i+1 j <- i x <- x*i z <- x y <- i+1 y <- x*y while j<2*i do j <- j+1 z <- z*j...
  2. G

    Hashing Problem Homework: Generate Hash Function from Table

    Homework Statement In a factory, machines are making cars (1-n) along the production line. One machine is making one part on the existing construction (part 1 is made by machine 1,...). Installation order of some parts is not important, but some parts have to be installed before others...
  3. binbagsss

    I Dijkstra's algorithm - Shortest Path Query

    Hi, I am just wondering what you should do in the case that you have a choice between two nodes to include for the next step, i..e both are equal to the minimal value of the set under consideration Do you need to follow through both cases and then see which way is the shortest, or is there a...
  4. doktorwho

    How can I analyze and understand tricky code in Pascal?

    Homework Statement This is a problem of the 10-minute test we had today in school. Its written in Pascal and it is asked of us to analyze it and figure out what is the output when it runs without writing it down. Homework Equations 3. The Attempt at a Solution [/B] I wrote it in the editor...
  5. R

    Where Can I Find an Algorithm Programmer for Number Manipulation Software?

    First of all, I have no idea what I'm doing. I need to know how to find someone to create software that will take millions of numbers divided into 3 to 6 digit sets and manipulate the numbers in certain sets to a desired value.
  6. T

    Algorithm for dB vs time graph for one frequency from FFT?

    I'm doing a physics experiment for school, for which I am measuring the reverb time for specific frequencies in a room. What I did was record a 1000 Hz sound, and some time after it, and looked at its FFT on Audacity to see the intensity of just 1000 Hz at a given time. Manually, I can do this...
  7. Superposed_Cat

    Is There an Error in My Q Deep Learning Algorithm? Need Help Troubleshooting!

    [mentor note: code blocks added for readability and syntax hilighting] Hey all, been trying to implement a Q deep learning algorithm, having an issue though, its not working, after 100 000 game plays and using 1000 iterations to train each step (although i have tried lower numbers for both)...
  8. B

    Pseudocode for Karplus-Strong algorithm

    Does anyone have some Pseudocode for Karplus-Strong algorithm?
  9. Uriel

    A Problem with a convolution algorithm

    Hi. I've been reading "Statistical Mechanics Algorithms and Computations". And I came to a problem while processing Algorithm 1.26 (I attach a link at the end). I don't get why the weights are the way they are, specially I can't understand the sequence {1/2l,1/l,...,1/l,1/2l}. Does anyone...
  10. L

    MHB Prim's algorithm for minimal spanning tree

    Quite stuck on this how do i do this and how do i document each step?
  11. M

    I Why does +bc become negative in the proof of the Euclidian Algorithm?

    In this video, at 5:35 He has d/(a-qb) for the first part. I was not sure how he got that. Why is it not d/(a+qb)? Because d/a and d/bc implies d/(a+bc) Why does +bc become negative?
  12. evinda

    MHB Is it the algorithm the optimal one?

    Hello! (Wave) I want to write an optimal algorithm that solves the following problem: Someone chooses a number from the set $\{ 1, \dots,1000\}$ and I have to find it. I can ask if the number that was chosen is $< , > , \leq $ or $ \geq $ from a number and the possible answers are yes or no...
  13. benarceneaux

    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)...
  14. A

    I Simon's Algorithm: Solving the Mystery of f(x+s)

    Hi all, I am sure some of you have heard of Simon's algorithm that calculates a secret string s when given a black box. Basically, let's say we have a qubit x that is n digits long. Now the black box contains a function f that outputs f(x+s) where s is the mystery string and + is bit-wise modulo...
  15. S

    Djikstra's algorithm with distance 1 between every node

    Does anyone know whether there exists a specialized Djikstra's algorithm for when every node has the same distance between it? Or to think of it another way, an algorithm for simply finding the minimum number of moves to get from 1 node to another? e.g. in the following A - B - C...
  16. lionliam96

    CNC acc/dec look ahead algorithm

    Homework Statement I`m having some trouble with an acceleration/deceleration look ahead algorithm I`m trying to implement in a CNC controller written in C#/F#, specifically the algorithms treatment of time. Homework Equations The white paper can be found at...
  17. Avatrin

    Exploring Algorithmic Composition and MIDI Programming with Python

    Python is the only programming language I know, and I know there is a huge library of MIDI music out there. I want to play around with machine learning and algorithmic composition to see what I can produce. So, what books should I read to be able to do this? What I am looking for is: Books to...
  18. S

    Largest permutation of elements in the range 1,....,N

    with at most k swaps. (In other words, like the largest number formed by swapping k digits.) Example. A=[4,2,3,5,1], k = 1 ---> [5,2,3,4,1] I'm wondering why my algorithm is failing the test cases which I'm unable to see. using System; using System.Collections.Generic; using System.IO...
  19. S

    Algorithm to find the smallest substring containing a set of....

    characters in a specified amount. I've been working on this for 10+ hours and can't seem to get it right. It passes all the unit tests I've written, but when I use it in the context of the program I'm writing it fails. The idea is like ACTAGACC { A : 2, C : 1} ------> 4, because smallest...
  20. S

    Largest number formed by replacing k digits

    I'm wondering if you guys can help me figure out where I'm going wrong here. The prompt is Given k and an n-digit number, help Sandy determine the largest possible number she can make by changing k digits. Full prompt here: https://www.hackerrank.com/challenges/richie-rich My solution is...
  21. dholbach

    A Barabasi-Albert Algorithm for Generating Scale-Free Graphs

    I've been working on implementing the Barabasi-Albert model in C++. Barabasi-Albert networks are supposed to be scale-free -- that is, their degree distribution is supposed to be power-law distributed. In order to test whether my program was working correctly, I plotted the degree distribution...
  22. S

    JavaScript Algorithm to return all subarrays of a given array

    I can't find this exact algorithm anywhere on the internet. What I'm trying to implement is the following function // Returns all subarrays of the given array, not including the empty array // ex. [a,b,c].subarrays() = [ [a], [b], [c], [a,b], [a,c], [b,c], [a,b,c] ] Array.prototype.subarrays...
  23. JesseJC

    Counting floating point operations in an algorithm

    Hey guys, another question regarding MatLab here. In this assignment, I need to create a function of 'k' to count the number of floating point operations in the algorithm that I've made. Here is my code so far: expAk = zeros(1000, 1000); load('CA3matrix.mat'); times = zeros(15, 1); for j =...
  24. E

    I First order logic - help with translation algorithm between

    given a dictionary \Sigma = \left \{f(),g(),R(,),c_0,c_1,c_2 \right \} and a sentence \phi over \Sigma, I need to find an algorithm to translate \phi to \psi over \Sigma' where \Sigma' = \left \{Q(,,,), = \right \} (Q is a 4-place relation symbol), so that \psi is valid iff \phi is valid. I...
  25. anorlunda

    I Making a quantum computer do Shor's algorithm

    I think I understand quantum superposition and entanglement, and a qubit. I just finished reading Scott Aaronson's brilliant blog post "Shor I'll Do It" that allowed me to understand Shor's Algorithm and how it relates to QM. But now I'm missing the next step. How does one "wire up" a number...
  26. M

    MHB Algorithm creates representative set of data

    Hi all, I have algorithm to analyze and make it easier to implement in programming language (Python). We have table with data and we want to select only representative part. It looks like: ID_PRODUCT | CARDINALITY | SET VARIANCE WITH THIS ELEMENT AND ABOVE 10 ---------------- 110...
  27. M

    A Algorithm creates representative set of data

    Hi all, I have algorithm to analyze and make it easier to implement in programming language (Python). We have table with data and we want to select only representative part. It looks like: ID_PRODUCT | CARDINALITY | SET VARIANCE WITH THIS ELEMENT AND ABOVE 10 ---------------- 110...
  28. I

    I Evolution style algorithm to determine EOM

    I had seen a documentary about an algorithm that uses notions of evolution to deduce the equation of motion of a system by sampling a variable connected with the system. For example, they used the double pendulum case where they sampled the position of the free end of the pendulum and arrived...
  29. S

    Proof of optimality of algorithm

    Homework Statement Given an array of positive integers A[1, . . . , n], and an integer M > 0, you want to partition the array into segments A[1, . . . , i1], A[i_1 + 1, . . . , i2], . . . , A[i_k−1 + 1, . . . , ik], so that the sum of integers in every segment does not exceed M, while...
  30. TheMathNoob

    Why does this sorting algorithm properly sort the array?

    Homework Statement Consider the following sorting algorithm for an array of numbers (Assume the size n of the array is divisible by 3): • Sort the initial 2/3 of the array. • Sort the final 2/3 and then again the initial 2/3. Reason that this algorithm properly sorts the array. What is its...
  31. A

    MHB Master algorithm design and upper bound proof

    Hello, I am currently preparing myself for exams and I have a past exam question which I can't solve. This question concerns online learning and the following picture illustrates it: Is anyone able to help me out and propose a solution to this question?
  32. J

    Finding a Local Minimum in a Complete Binary Tree with Log(N) Probes

    Homework Statement Consider a complete binary tree T with n nodes (n = 2^d − 1 for some d). Each node v of T is labeled with a distinct real number x. Define a node v of T to be a local minimum if the label x is less than the label y for all nodes m that are joined to v by an edge. You are...
  33. J

    Find p in a Sorted Array with Unique Property | O(log n) Algorithm

    Homework Statement Suppose you are given an array A of n distinct integers with the following property: There exists a unique index p such that the values of A[1 . . . p] are decreasing and the values of A[p . . . n] are is increasing. For instance, in the example below we have n = 10 and p =...
  34. A

    MHB How Does the DeBoor Algorithm Calculate Coefficients for Spline Fitting?

    Hi, I'm trying to implement the DeBoor algorithm for Spline fitting to data points. In the subroutine BSPLPP (which is used to convert the B representation to PP representation), the COEF array is of the size (k,l). But for a kth degree polynomial, the number of coefficients should be (k+1). I...
  35. Kingyou123

    Recursive Algorithm, does it look correct

    Homework Statement Homework Equations s1=1,sn=(sn-1) +n, and n>=2 The Attempt at a Solution It looks correct, but I'm not sure it'll work for negative values.[/B]
  36. kevin2016

    A What is the closed-form solution using ALS algorithm to optimize

    C \in \mathbb{R}^{m \times n}, X \in \mathbb{R}^{m \times n}, W \in \mathbb{R}^{m \times k}, H \in \mathbb{R}^{n \times k}, S \in \mathbb{R}^{m \times m}, P \in \mathbb{R}^{n \times n} ##{S}## and ##{P}## are similarity matrices (symmetric). ##\lambda##, ##\alpha## and ##\beta## are...
  37. wololo

    Efficiently Finding Cycles in a Graph: A Scientific Exploration

    Homework Statement Homework Equations Recursion, graphs, DFS The Attempt at a Solution To try to solve this algorithm, I first need to find all the basic cycles in the Graph G. When I have these cycles, I can simply pick the smallest edge in each of them and add them to the set F, while...
  38. newjerseyrunner

    Algorithm gives wrong answer, what's wrong?

    I have a point inside of a triangle and I want to move it to a position on the hypotenuse in the direction normal to it. The triangle's tip is located at position (l, b), the original point inside of it is located at (x, y). The triangle's sides have lengths w and h. That makes the measure of...
  39. M

    Shor's algorithm, definition of modulo

    Hi guys, My question shouldn't take too long to be answered but I simply can't find anything using a google search. It's more of a problem from number theory rather than a physical one. I am referring to the Wikipedia article to Shor's algorithm and I still can't get my head around how the...
  40. X

    Why is the complexity class expression this?

    I'm trying to understand complexity class algorithms off of my professor's lecture notes, but I still can't get a hang of it. void sort(int a[], int N) { //N is the length of the array for (int base=0; base<N; ++base) for (int check=base+1; check<N; ++check) if...
  41. S

    Issue with behavior of ray-plane intersection algorithm

    I'm trying to determine the point, in 3D space, where an arbitrary line/ray intersects with an infinite plane. Using an article on Wikipedia, I tried to reproduce the presented formulas in code. This seems to work fine so long the ray is emitted from the origin of the coordinate system (0, 0...
  42. H Smith 94

    Verlet algorithm: Why am I getting this output?

    Hi! I am currently trying to write a code in C to simulate the orbit of planets around the Sun in the solar system. I am using the velocity Verlet approach and finding that my code produces no acceleration in the ##y##-direction (aside from for ##t_n = 0##,) and that the planet just flies off...
  43. E

    How Does the Deutsch-Josza Algorithm Determine Function Constancy?

    Homework Statement Consider a general function ##f:\{0,1\}^n \rightarrow \{0,1\}## (not necessarily constant or balanced). The function gives ##f(x)=0## for a portion##z## of the different possible inputs ##x\in\{0,1\}^n##, and ##f(x)=1## for the rest of the inputs. Consider that we construct...
  44. ORF

    Is there any algorithm to find coincidences between 2 lists?

    Hello I need to find coincidences between items in 2 lists. The lists have disordered items, so the first idea I had was to sort the items in the correct order and then finding the coincidences would be easy. The main problem is the big amount of items in the lists. I was using "double-linked...
  45. iamjon.smith

    Comp Sci C++ search algorithm with 3 sublists

    Homework Statement This is the assignment instructions:[/B] In C++, code a search algorithm that searches a list of strings for a particular song. The searching algorithm will have two inputs: the playlist, which is a string array that contains a list of songs in alphabetical order; and a...
  46. B

    How Do I Calculate High Cycle Fatigue Life in Abaqus Using Strain Energy Models?

    Hi all, I'm hoping there's someone here who can give me a little help. So I've run a large number of fatigue tests, both stress and strain controlled, and using the data from these I've calibrated material constants for the chaboche model in Abaqus and run the simulations getting fairly similar...
  47. evinda

    MHB Solving System of Restrictions with Simplex Algorithm

    Hello! (Wave) I want to apply the simplex algorithm that finds the vertices of the following system of restrictions: $$2x_1+3x_2-x_3+4x_4=8 \\ -x_1+2x_2-6x_3+7x_4=3 \\ x_i \geq 0, i=1,2,3,4$$ I took at the beginning the basic feasible solution non degenerate solution $(1,2,0,0)$ and I wrote...
  48. gre_abandon

    Demon algorithm for microcanonical ensemble

    I simulated a microcanonical ensemble of 10 ideal gas particles in one dimension and yielded the expected normal distribution of velocities. However, I still did not get how the algorithm works. The demon has non-negative energy content and the demon together with the system constitutes a closed...
  49. barbara

    MHB Algorithm Type: Postorder Tree | Correct?

    + / \ / \ * - / \ / \ 2 3 * +...
  50. jedishrfu

    Landmark Algorithm for Graph Isomorphism

    Quanta Magazine published this article on a potentially new algorithm for graph isomorphism by Prof Laszlo Babai of the University of Chicago: https://www.quantamagazine.org/20151214-graph-isomorphism-algorithm/ There's a reference to the Arxiv preprint here: http://arxiv.org/abs/1512.03547v1
Back
Top