Thread: randomized version generally doesn't work

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    69

    randomized version of program generally doesn't work...

    i made a second version of a red black tree program i was working on. the first version used a standard reading of the input file sequentially adding each city to the tree. this wasn't working very well since the file provided sorted input. the resulting tree was heavily skewed to the right because of this.

    in this version of the program, i read the input file into a vector and then randomly sampled from the vector for input to the tree until each item was used.

    for some reason i haven't been able to figure out, the program runs fine sometimes and crashes or infinite loops other times. when it lets me debug, it points me to the line:

    Code:
    void leftrotate(Ptr& root, Ptr& x)
    {
    	Ptr y=x->right;				//new Ptr y = right[x]
    
    	Ptr spare=x;
    
    	x->right=y->left;			//right[x]=left[y]
    i'll attach the cpp file, header file, and data file on here
    Last edited by talz13; 11-04-2003 at 08:04 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGl Version
    By Nextstopearth in forum Game Programming
    Replies: 6
    Last Post: 11-26-2008, 07:56 AM
  2. No Version info tab in file properties?
    By cpjust in forum Windows Programming
    Replies: 2
    Last Post: 06-03-2008, 03:42 PM
  3. help getting program to work
    By jlmac2001 in forum C Programming
    Replies: 2
    Last Post: 11-13-2002, 11:04 PM
  4. DLL __cdecl doesnt seem to work?
    By Xei in forum C++ Programming
    Replies: 6
    Last Post: 08-21-2002, 04:36 PM
  5. Version info and ListBox
    By GaPe in forum Windows Programming
    Replies: 10
    Last Post: 03-28-2002, 12:08 AM