CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2010
    Posts
    5

    Important - demonstration

    hello! i need your help about this exercise:

    Let { xi } i=0, .. .. .. , 2n 2n+1 distinct points on the real line



    2n
    we define ∑ 0 = ∑ | x(0) - x(i)|
    i=0



    2n
    ∑ 1 = ∑ | x(1) - x(i)|
    i=0


    prove that there is a linear algorythm that says: ∑ = {∑ | i:0,.. .. .. ,2n}
    min i


    i solve this exercise (i found that the element that minimizes this function is the element nearest to the average of the numbers that i gave in input, and the compexity is O(6n + 2) in the worst case. Do you know how to demonstrate this algorythm???


    p.s. when i write for example x(0), x(1), 0 and 1 are the subscripts of x.
    thank you!
    Last edited by Lordofnazgul; May 9th, 2010 at 02:14 PM.

  2. #2
    Join Date
    Oct 2006
    Posts
    616

    Re: Important - demonstration

    Your phrasing and formulas are not very clear.
    I'm not sure what the linear algorithm should do. The formula is strange.
    Please describe it also in words or attach a bitmap of the exact equations.

    Regards,
    Zachm

  3. #3
    Join Date
    Mar 2010
    Posts
    5

    Re: Important - demonstration

    Quote Originally Posted by Zachm View Post
    Your phrasing and formulas are not very clear.
    I'm not sure what the linear algorithm should do. The formula is strange.
    Please describe it also in words or attach a bitmap of the exact equations.

    Regards,
    Zachm
    here it is:

    http://img98.imageshack.us/img98/6299/algorythm.jpg


    sorry for bad posting before. The Algorythm i created finds the average of the numbers, and then finds the element that is the nearest to the average. the complexity is O(6n + 2). but i don't know how to demonstrate that my algortyhm works. thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured