CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: Zachm

Page 1 of 25 1 2 3 4

Search: Search took 0.05 seconds.

  1. Replies
    2
    Views
    1,223

    Re: Algorithm problem

    This is in fact a clustering problem - you wish to cluster n airports to gi groups where each group centroid is a gas station coordinate.
    Simplest (but maybe not best) method is to use the K-means...
  2. Re: Erase element from std::list, old iterators still valid?

    See here:

    "Lists have the important property that insertion and splicing do not invalidate iterators to list elements, and that even removal invalidates only the iterators that point to the...
  3. Thread: sort array

    by Zachm
    Replies
    3
    Views
    4,762

    Re: sort array

    If you *KNOW* there are exactly n/2 1's and n/2 2's, then why sort ?
    Go over the array and assign 1 to the first n/2 elements and 2 for the rest.
    Exactly n assignments and no need for comparison......
  4. Replies
    1
    Views
    4,089

    Re: sort multiple reference

    Basically you are rearranging each of the matrices rows according to the sorted ordering of a given column in a given matrix.

    You just need to figure out what is the new row index of each of the...
  5. Replies
    5
    Views
    9,349

    Re: Best math programming language?

    Mathematica is also a good option, in my experience.

    Regards,
    Zachm
  6. Replies
    7
    Views
    900

    Re: Estimation of program run-time

    Computationally speaking, just emulating the program run and counting the number of steps is not so hard - but if a program with finite run-time may still run for a VERY long time depending on the...
  7. Re: Is it possible to have an infix expression in a Ternary Tree and above?

    Seems to me that a ternary tree could be used the same way as a binary tree is used - by, for example, ignoring the right-most child (keeping it NULL) of each node, and considering the left-most and...
  8. Replies
    1
    Views
    756

    Re: Need some help with exam

    As I remember, the number of moves required is (2^n) - 1,
    anyhow, this number is Theta(2^n) if and only if it's O(2^n) and also Omega(2^n).

    Go back to the mathematical definition of the big-Oh...
  9. Replies
    1
    Views
    447

    Re: anomalous loop behavior

    You can use [ code ] tags to wrap around your code - '#' icon in rich edit mode.
    The reason your code goes into an infinite loop is that the for loop exit condition is that i > 255 (since if i <=...
  10. Thread: Cin problem

    by Zachm
    Replies
    3
    Views
    642

    Re: Cin problem

    Well, that's how cin works.


    Good idea! (except for the 'but that seems too complicated' part :)).
    If you try doing as you suggested, maybe it won't seem so complicated.

    Regards,
    Zachm
  11. Replies
    1
    Views
    1,570

    Re: A* algorithm help

    To find the ratio between your "world" coordinate units to the cost/heuristic function units, just look at the distance cost between 2 adjacent points relative to the "coordinate" distance between...
  12. Re: Help I can't get this simple flex/bison compiler to work

    This is because this is not C++ or C code at all. This is bison(or yacc) BNF input format.
    Maybe this yacc calculator example will prove handy ?
    I am absolutely *not* the master of bison(or yacc),...
  13. Replies
    7
    Views
    4,852

    Re: Sorting faster than n log n?

    Right.

    Regards,
    Zachm
  14. Replies
    7
    Views
    4,852

    Re: Sorting faster than n log n?

    Radix Sort can give you run-time complexity of O(n).

    Regards,
    Zachm
  15. Re: Find the sum of two numbers that are from two different arrays.

    Do you want to find two numbers X, Y, where X is a number from the first array and Y is a number from the second, such that X + Y = S, and S is some predefined value ?

    Are the arrays sorted ?
    ...
  16. Replies
    10
    Views
    1,282

    Re: How slick are you?

    Or you can do this:


    #include <stdio.h>
    main(int t,char _,char *a)
    {
    return!0<t ? t<3 ? main(-79,-13,a+main(-87,1-_,main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a )&&t==...
  17. Replies
    3
    Views
    782

    Re: recursive function logic.

    bool Mob::checkLeader(Mob* L)
    {
    if(leader != NULL) //leader exists
    {
    if(leader != L) //leader is not me
    {
    if(checkLeader(L)) ...
  18. Replies
    6
    Views
    2,007

    Re: The best location of a path

    Yes, it is.
    Think about how you can sum the value of a path starting at index i, given the sum of the path starting at index i-1, in O(1):
    161 = 97 + 32 + 32
    164 = 32 + 32 + 100

    164 = 161 - 97...
  19. Replies
    6
    Views
    2,007

    Re: The best location of a path

    This makes it even simpler.
    You can think of your segment as having only ranges which are 1 unit in length by dividing each range with weight w of x units length to x ranges with weight w each.
    ...
  20. Replies
    6
    Views
    2,007

    Re: The best location of a path

    This seems like a rather straight forward problem, though some optimizations come to my mind. There exists an O(n) algorithm to solve this problem, where n is the total number of units.

    What did...
  21. Replies
    2
    Views
    2,163

    Re: how to find pixels common to an object?

    In general, you can use the Flood Fill algorithm in order to find all pixels with the same color, starting from a given pixel.
    But what will you do if you have two different circles which are...
  22. Re: Looking for C#, C++ Programmer For A Quick Program Fix. Willing To Pay ~$500

    Hi,

    I'm interested.
    I have 5 years of commercial development experience in both C++ and C#.
    You can PM me if this is still relevant and we will close the details (I couldn't PM you since you...
  23. Replies
    2
    Views
    3,025

    Re: Cohen–Sutherland Algorithm Modification

    If I put code lines which does the majority of the computation in your example code, it would be the following lines:


    cornerSlope = (ymax - p1y) / (xmin - p1x); //in clipEnd()
    ...
    ...
  24. Replies
    10
    Views
    3,667

    Re: Really hard to solve

    If we're going for an overkill, there are many funny ways of doing stuff ;).
    For instance, this some what odd way of approximating Pi :


    #include <stdio.h>
    #define _ F-->00 || F-OO--;
    long...
  25. Replies
    6
    Views
    2,034

    Re: Number of ways of splitting a graph

    I don't think this case is possible since the clique is maximum:
    Assume there is some vertex v in the IS which is connected to all vertices of the clique, it follows that degree(v) >= m and...
Results 1 to 25 of 619
Page 1 of 25 1 2 3 4





Click Here to Expand Forum to Full Width

Featured