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.
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 =...
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...
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...
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...
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...
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...
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...
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.
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...
[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)...
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...
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?
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...
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)...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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 =...
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...
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...
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...
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...
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...
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...
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...
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?
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...
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 =...
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...
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]
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...