Algorithm Definition and 651 Threads

  1. T

    Proof of Altered Division Algorithm

    Homework Statement Show that, for positive integers a and b, there exists unique integers q and r such that a = bq + r and -b/2 < r \leq b/2. Homework Equations We can assume the standard division algorithm holds. That is, for integers a and b, there exists unique integers q and r such...
  2. C

    MHB Complexity of Algorithm to calculate number of nodes in a binary tree

    I guess this is the first question on partly CS topic in this forum. But I think you guys will be able to help me. I have an algorithm which goes as follows: int CN(struct node *node) { if(node==null) return 0; return 1 + CN(node->left) +...
  3. Z

    Algorithm for cutting a polygon into specific shapes

    Hello everybody, I have a shape (polygon) made up from pixels (squares) similar to the image below. I need an algorithm to cut it into "lines" i.e. shapes of 1x[1..20] pixels. The lines should not be necessarily straight, but they should fill the entire area. Any ideas on where to start...
  4. N

    A fast image recognition algorithm for box?

    If you have an image (just black and white) with a box SOMEWHERE in the image, but there's also some noise in the image, is there a good way to find four corners? I'm sure someone has herd of an algorithm for this, it would just be good if I had a direction to go in.
  5. S

    What Does Converting a Matrix to Tridiagonal Form Indicate in Practical Terms?

    Hi, I need to write a code to convert a symmetic matrix into tridiagonal form and am planning to use the Householder algorithm. I understand the mathematical steps. Can anyone explain that when we are converting a matrix "A" into a tridiagonal form what does it physically indiacte? I...
  6. L

    Algorithm for acceleration of projectile undergoing squared velocity drag?

    I am trying to write a java program to simulate the motion of a projectile undergoing a drag proportional to the velocity squared, but i am having some issues writing the acceleration part. This is my attempt, not sure if its right though; a=g-kv^2 da/dt=-k dv^2/dt since dv^2/dt=2vdv/dt...
  7. A

    Help Me Debug My Merge Sort Algorithm

    Hi I'm trying to program a merge sort algorithm on python but it just doesn't work! I first implemented a fusion algorithm which takes as arguments a list A divided into 2 sorted sub lists A[p..q] and A[q+1..r]. Fusion then returns the list A completely sorted. This program seems to work...
  8. P

    Doubt about quicksort algorithm

    Good evening, I have a doubt concerning the worst case scenario of the quicksort algorithm, based on the number of comparisons made by the algorithm. Every source about this subject seems to agree that the worst case scenario is when the list to be sorted is already sorted and the pivot is...
  9. A

    Solving Finite Difference BVP with Thomas Algorithm

    hye all... we know that in solving of finite difference methode of boundary value problem, the thomas algorithm is needed to solve it.. anyone here know how to use the thomas algorithm? thanks.
  10. L

    Develop an algorithm or write pseudocode

    Homework Statement Develop an algorithm or write pseudocode to determine the winning candidate for a constituency in the national elections. The algorithm must accept as input the names of the four candidates and the number of votes each candidate receives. The successful candidate is the...
  11. J

    I need a clustering algorithm for complex #'s

    I'm going to be clustering sleep spindles (see pic below) based on both phase shift and amplitude at a yet-to-be-determined time during the event. The baseline will be the Cz channel, one of the 23 EEG channels. There are about 100-200 sleep spindles on each patient's recording, so I'll have...
  12. Y

    Why Does the Levenberg-Marquardt Algorithm Focus on Minimizing Functions?

    Hello Physics Forums, In my project work, I've had to use the LMA technique for some non linear fitting. I really want to understand what it's doing rather than just using it. I have a poor knowledge of non linear fitting so please bear with me! When producing the line of best fit, it...
  13. X

    Abstract Algebra Problem using the division algorithm

    Homework Statement Apply the division algorithm for polynomials to find the quotient and remainder when (x^4)-(2x^3)+(x^2)-x+1 is divided by (2x^2)+x+1 in Z7. Homework Equations The Attempt at a Solution I worked the problem and got that the quotient was (4x^2)-3x-1 and the...
  14. E

    How Does the MUSIC Algorithm Derive the Auto-Correlation Matrix?

    I'm studying the MUSIC algorithm in order to implement it in some project of mine, but I have some difficulties understanding the mathematical derivations done in the original Schmidt paper. For those of you who have access to this paper, I'll appreciate your time and help. The author begins...
  15. S

    Simplest algorithm for computing the resultant of a boolean expression?

    hi, let's take something simple, for example: (a>b) && ((b>c) && c>d) || (d > c) Intuitively, it's easy to work out given the values of a, b, c and d and just evaluating the brackets in order of precedence. i.e. Is b > c?? then is c > d Then in addition to the above answer being...
  16. T

    Euchre Tournament random seating algorithm

    Hi All, I'm hoping I can find some help to solve a puzzle that came up last night with friends. I thought I could find a solution but have been out of college too long. We had 3 couples over (8 adults), and wanted to play a single round for each possible pairing of the 8 people. After playing...
  17. P

    How to Implement IDEA Algorithm in VHDL?

    Hi all ... Does anyone knows how to implement IDEA algorithm in VHDL, especially the multiplier part(Low High Algorithm)? Kindly help me out in this
  18. D

    What is the Solution to the Extended Euclidean Algorithm Homework?

    Homework Statement There's a couple of questions that require the use of this, I'm having trouble with one of them, could anyone help? Homework Equations a) 520x - 1001y = 13 b) 520x - 1001y = -26 c) 520x - 1001y = 1The Attempt at a Solution The first two are easy to do, where you set 1001...
  19. M

    Deutsch's algorithm vs classical algorithm

    How the Deutsch's algorithm outperforms a classical algorithm? In both algorithms we need two particles (two bits and two qubits). In the quantum case the two qubits are processed by the FCNOT gate simultaneously but it's equivalent to two classical "black boxes". So if we take two classical...
  20. I

    Further Maths, D1 - Dijkstra's Algorithm

    Hi, I can do Dijkstra's Algorithm alright, but I always have problems with questions which have some relevance to the "Order of the Algorithm". For example, in the Further Maths, Decision 1 (OCR) textbook: 8) Suppose you purchase a new computer which is 100 times as fast as your old one...
  21. P

    Understand Grover's Algorithm: Classical Problem vs Quantum Solution

    Could anyone explain me how Grover's algorithm works. I read the article on wiki about it: http://en.wikipedia.org/wiki/Grover_algorithm" but I don't see any relation between classical problem of searching an element in unsorted database and its alledge quicker quantum solution. In classical...
  22. T

    Gauss elimination algorithm for matrix inversion

    Hello guys, I'm writing a C++ function for matrix inversion. I saw many algorithms online, but I'm concerned about the case when a diagonal element equals zero, which is, for some reason, not taken into account by those websites. When we do the elimination for solving a system of linear...
  23. T

    Fit with least squares, Levenberg–Marquardt algorithm

    Hello guys, I need your help with understanding a fitting Algorithm, so that I could make it in a C++ program. I have the following function: g(f; f0, phi0, a, b) = phi0 + a ArcTan((f-f0)/b) Which is a function of "f", frequency. I would like to fit this function with the...
  24. D

    Need help understanding U.S. Naval Observatory's messed up algorithm

    Hello! I'm trying to calculate the equation of time and the declination of the sun based on the U.S. Naval Observatory's algorithm: http://aa.usno.navy.mil/faq/docs/SunApprox.php" But not the U.S. Naval Obseravtory, or any of the astronomers I've tried to contact, has been eager to help me...
  25. D

    Fast algorithm to find root of strictly decreasing function

    What is the fastest algorithm to find the closest root (such that the function value at that point is positive to an error but never negative, if not exactly zero) for a strictly decreasing function?
  26. B

    Efficient Algorithms for Counting Line Crossings on a Grid

    Hello, there's this problem about line crossings I saw somewhere and was trying to solve. There's a 64x64 grid of 8 bit pixels and it has a bunch of 1 pixel wide vertical and horizontal lines of different colors on it. All parallel lines have at least one space between them. The problem is...
  27. K

    Question on the Euclidean Algorithm

    Homework Statement Let a,b\in\mathbb{Z}. Suppose r_{0}=a and r_{1}=b. By the algorithm, r_{i}=0 for some i\geq 2 is the first remainder that terminates. Show that r_{i-1}=\gcd(a,b). Homework Equations The Attempt at a Solution I've shown that c|r_{i-1}, and I know that I should...
  28. F

    Is bases the same as basis ? (Simplex Algorithm)

    Homework Statement [PLAIN]http://img193.imageshack.us/img193/3662/unledmcg.png The Attempt at a Solution I rewrote the whole thing in dictionary x_3 = 15 - 8x_1 - 4x_2 x_4 = 7 - 2x_1 - 6x_2 z = 0 + 22x_1 - 12x_2 x_i \geq 0 1\leq i \leq 4 a) So my basis/bases is x...
  29. T

    Visual basic algorithm for computing hermite polynomials

    Please I need Visual Basic algorithm for computing Hermite polynomials. Any one with useful info? Thanks.
  30. J

    Question abou Patterson Algorithm

    Hi every one In the preliminaries section, the item c), there a proposition that say: "So by our choice of g we get "\theta/p | \psi/p" whence "\theta | \psi" ". I am not understanding this propositión, Please help me ...
  31. B

    Proof of the The Division Algorithm

    This is going to be kind of a long post, and I'm citing the author because it's directly from a textbook, but I'm assuming this proof is standard and I won't be doing anything unethical. I'm basically going to post it with my questions interrupting the text. I'm not sure how he got from some...
  32. O

    Iteration/Root finding algorithm

    Homework Statement The Attempt at a Solution I've managed to do part a), by factorising the cubic you get when you rearrange the terms. I'm mostly stumped for part b). I know the sequence has to be contractive, otherwise it wouldn't converge. Also, how do I show it's the only...
  33. A

    Simulation of Grover's Quantum Database Search Algorithm

    I have a basic understanding of Grover's algorithm, and I do know it searches through an unstructured database for some value. I recently downloaded the Quantum Processing Simulation (QPS), and after trying out the Grover simulator I became confused: through what database is it searching? It...
  34. T

    Levenberg-Marquardt Algorithm with Several Functions

    Hi there, I have been testing out the Levenberg-Marquardt algorithm. I've successfully coded a method in MATLAB for the example I saw on wikipedia: f(x) = a*cos(bx)+b*sin(ax) and this has worked well. The application I'm using the algorithm for is a system of 3 equations, however. Does...
  35. K

    Basic A* pathfinding algorithm question

    Just looking for some advice here.(This is the first time I'm doing anything like this so please bare with me) I have been given a project where we have a game and 4 agents (the other 3 agents are other computer science students) The idea is to program a good AI that can beat theirs. I am...
  36. L

    Mathematica Gillespie Algorithm (Monte Carlo Simulation) for simple process in Mathematica

    I am trying to model a simple birth and death process in Mathematica using the Gillespie Algorithm. I am using 1 DNA molecule that is transcribed to mRNA with rate k1, \mbox{DNA} \longrightarrow \mbox{DNA + RNA} and the transcribed RNA are subject to degradation with rate k2...
  37. P

    Analyzing the time complexity of an algorithm

    Homework Statement Analyze the worst-case time complexity of the following algorithm, which finds the first term of a sequence of integers equal to some previous term. procedure find (a1, a2, a3,..., an: integers) location := 0 i := 2 while i ≤ n and location = 0 begin j := 1 while j < i...
  38. D

    What are the pitfalls in implementing binary search?

    On the website http://stackoverflow.com/questions/504335/what-are-the-pitfalls-in-implementing-binary-search, it states that the Pascal code (note that in Pascal, the array indexing starts with 1) PROCEDURE BinarySearch (A : anArray, Size : anArraySize...
  39. L

    Euclide's Algorithm to Calculate GCD

    Homework Statement Using Euclid's algorithm write a program with a function that determines and returns the GCD of two integer arguments. This is what i wrote, when i print the remainder is zero, How can i get the last remaninder before the zero value? :confused: Thanks Homework...
  40. D

    Using the Insertion Sort algorithm on a linked list

    Homework Statement Hi there, I wish this wasn't my first post but unfortunately, it is. I will try to contribute later in the semester when my workload is less. On to the topic, the problem is I have to implement the insertion sort algorithm on a linked list. I have the algorithm for Java...
  41. S

    How can the Extended Euclidean Algorithm be simplified for faster computation?

    Hi all, ok so below is an example of the Extended Euclidean Algorithm, and i understand the first part perfectly to find the g.c.d. 701 − 2 × 322 = 57, 322 − 5 × 57 = 37, 57 − 37 = 20, 37 − 20 = 17, 20 − 17 = 3, 17 − 5 × 3 = 2, 3 − 2 = 1, and 1 = 3 − 2 = 6 × 3 − 17 = 6 × 20 − 7...
  42. W

    Is there a method for the simplex algorithm that avoids cycling?

    Homework Statement "There exists an implementation of the simplex algorithm that avoids cycling. (If your answer is `yes', describe the strategy; if your answer is `no' give an example and explain briefly why every strategy must fail.)" The Attempt at a Solution We normally do the...
  43. P

    How reason that an algorithm has n*logn time complexity?

    Some time ago I wrote an exam where I had to write a pseudocode to sort elemens in a list. I used a quicksort with the pivot in the middle and wrote that the algorithm has time complexity in best case O(n*logn) because it is a divide-and-conquer algorithm. That didn't satisfy my teacher and he...
  44. W

    Simplex algorithm - phase one - why do I need to use it here?

    Hello everyone, I hope I've posted in the right section! I have the following linear program. All I've done is added my slack variables (w) and made each constraint the subject, as you do. \mathrm{maximize} \ z=x_1+3x_2 \ w_1 = -3 + x_1 + x_2 \\ w_2 = -1 + x_1 - x_2 \\ w_3 = 4 - x_1 -2x_2...
  45. A

    Calculators Algorithm for Calculator application

    I need an algorithm for developing a calculator application. When I googled , I got results that perform the ordinary push and pop operations . I need the complete algorithm that can be useful to code a calculator application in GUI.
  46. N

    Find Largest & Second Largest Number Index in Array - Ask Algorithm

    a function: can give the index of the largest number in an array. also give the index of the second largest number, and the index of the third and the forth. such as a={1,2,3,5,7,99,121,3,2,24,10} the code can give the result followed: 6,5,9,10 how to make the function?
  47. S

    Using Reme's Algorithm to Find q2(x) for ex on [-1,1]

    Homework Statement Find q2(x) for f(x) = ex on [-1,1] using Reme's second algorithm. Homework Equations The Attempt at a Solution For the first iteration: Step a of the algorithm gives a0 = 0.989141, a1 = 1.130864, a2 = 0.553940 and E = 0.0443369. The question I am asking is how...
  48. B

    Master the Eigenvalue Algorithm for Math GRE Exams

    I'm taking the math subject GRE in just over a year's time... and I was wondering if there are "ideal" algorithms to have in our tool box to do a computation like this quickly. Obviously the type of matrices in a standardized exam are going to be fairly clean or look dirty but have some less...
  49. A

    Locating Pixels with Bresenham's line algorithm

    hi,I wanted to locate the pixels of a line drawn from (0,0) to (-4,-8) with bresenham's algorithm.I couldn't find a suitable algorithm for finding these pixel locations.Can anyone help me please?(the algorithm can be without computer and work by hand)
  50. A

    Locating Pixels with Bresenham's line algorithm

    hi,I wanted to locate the pixels of a line drawn from (0,0) to (-4,-8) with bresenham's algorithm.I couldn't find a suitable algorithm for finding these pixel locations.Can anyone help me please?(the algorithm can be without computer and work by hand)
Back
Top