User Profile

Collapse

Profile Sidebar

Collapse
tc18a
tc18a
Last Activity: Apr 8 '10, 06:13 AM
Joined: Apr 7 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • I figured out n lg(n) algorithm;

    I created a new array called location[].
    While I am creating my master list, I store the location of each data value into location. For example, if in the master list 5 is in location 10, I do location[5] = 10. Now I have a way of looking up the location of any data value in constant time.

    I then did a qsort(array1, length of array1, sizeof(int), compare);

    Where compare...
    See more | Go to post

    Leave a comment:


  • Algorithm for sorting array of integers w/ respect to another array (c code would be

    I'm looking for a fast algorithm for sorting an array of integers with respect to a master list.

    For example:

    Master List: 7 3 9 1 32 6 5 4 99 100 201 13
    Array that needs to be sorted array1: 1 5 4 3 6

    The "sorted" array would be: 3 1 6 5 4

    The order of the array that needs to sorted is originally random. Neither the master list nor the array that needs to be sorted will...
    See more | Go to post
No activity results to display
Show More
Working...