Thread: merge sort: recursive is fasfter than non-recursive

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    6

    merge sort: recursive is faster than non-recursive

    greeting all:

    i'm making merge sort function for arrays as a project in my computer science class and found a very interesting phenomina. i implemented both recursive and non-recursive versions and non-recursive version is much slower than recursive version. ( OS: Windows XP Pro. compiler: Microsoft Visual Studio 2005 Pro. Ed. )

    excuse me for my messy source code but you can find my recursive version as MergeSort and non-recursive version as MergeSort2.

    does anyone know why recursive version is faster than non-recursive version? i suspect that somehow compiler optimized well so that CPU cached function's return address and other information in register rather than in main memory but i'm not really familier with that kinda hardware related topics so... any help please.

    sincerely,
    Last edited by rio_cat; 11-24-2006 at 10:45 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Merge Sort Help
    By blindman858 in forum C++ Programming
    Replies: 5
    Last Post: 05-14-2005, 09:47 PM
  2. Merge Sort
    By blindman858 in forum C++ Programming
    Replies: 2
    Last Post: 05-12-2005, 11:14 AM
  3. threaded merge sort
    By AusTex in forum Linux Programming
    Replies: 4
    Last Post: 05-04-2005, 04:03 AM
  4. Recursive Array Sort
    By Nakeerb in forum C++ Programming
    Replies: 3
    Last Post: 12-13-2002, 08:27 PM
  5. help with merge sort
    By maloy in forum C Programming
    Replies: 4
    Last Post: 03-04-2002, 06:22 PM