تبلیغات
دانلود سورس پروژه های مختلف برنامه نویسی، آموزش برنامه نویسی - مرتب سازی ادغامی(Merge Sort) در C++
دانلود سورس پروژه های مختلف برنامه نویسی، آموزش برنامه نویسی
دانلود رایگان سورس پروژه
سایت برنامه نویسی تک کدر takcoder.ir


آموزش برنامه نویسی با استفاده از نوین ترین روش و ارائه پروژه های نمونه و مجموعه عظیم سورس کدهای آماده برای شما دوستان

مدیر سایت : Yahya Taherzadeh
نویسندگان
نظرسنجی
زبان برنامه نویسی مورد علاقه شما؟







File:Merge sort animation2.gif

مرتب سازی ادغامی، حل مسئله را به چند قسمت تبدیل کرده و آن ها را جدا حل میکند. به همین سبب از چندین تابع برخوردار است و متوسط عملکرد آن از رابطه O(n log n)  بدست می آید.

void mergeSort(int numbers[], int temp[], int array_size)
{
  m_sort(numbers, temp, 0, array_size - 1);
}


void m_sort(int numbers[], int temp[], int left, int right)
{
  int mid;

  if (right > left)
  {
    mid = (right + left) / 2;
    m_sort(numbers, temp, left, mid);
    m_sort(numbers, temp, (mid+1), right);

    merge(numbers, temp, left, (mid+1), right);
  }
}

void merge(int numbers[], int temp[], int left, int mid, int right)
{
  int i, left_end, num_elements, tmp_pos;

  left_end = (mid - 1);
  tmp_pos = left;
  num_elements = (right - left + 1);

  while ((left <= left_end) && (mid <= right))
  {
    if (numbers[left] <= numbers[mid])
    {
      temp[tmp_pos] = numbers[left];
      tmp_pos += 1;
      left += 1;
    }
    else
    {
      temp[tmp_pos] = numbers[mid];
      tmp_pos += 1;
      mid += 1;
    }
  }

  while (left <= left_end)
  {
    temp[tmp_pos] = numbers[left];
    left += 1;
    tmp_pos += 1;
  }
  while (mid <= right)
  {
    temp[tmp_pos] = numbers[mid];
    mid += 1;
    tmp_pos += 1;
  }

  //modified
  for (i=0; i < num_elements; i++)
  {
    numbers[right] = temp[right];
    right -= 1;
  }
}





نوع مطلب : آموزش، پروژه های رایگان، سی| سی پلاس پلاس، طراحی الگوریتم، ساختمان داده، 
برچسب ها : آرایه، مرتب سازی، ادغامی، Sort، merge، merge sort، function،
لینک های مرتبط :
Yahya Taherzadeh
سه شنبه 19 آذر 1392
دوشنبه 10 اردیبهشت 1397 10:18 ق.ظ
I do accept as true with all the ideas you have introduced on your
post. They're very convincing and can definitely work.
Still, the posts are very quick for novices. May you please extend them a bit from
subsequent time? Thanks for the post.
جمعه 6 مرداد 1396 06:45 ب.ظ
It's going to be ending of mine day, but before ending
I am reading this wonderful article to improve my knowledge.
یکشنبه 25 تیر 1396 06:45 ق.ظ
Thanks for finally writing about >دانلود سورس پروژه های مختلف برنامه
نویسی، آموزش برنامه نویسی
- مرتب سازی ادغامی(Merge Sort) در
C++ <Loved it!
دوشنبه 12 تیر 1396 09:27 ب.ظ
You can definitely see your expertise in the paintings you write.
The arena hopes for even more passionate writers like you who are not afraid to say how they believe.
Always go after your heart.
دوشنبه 12 تیر 1396 05:48 ب.ظ
This is the right webpage for anybody who hopes to understand this topic.
You know so much its almost tough to argue with you (not that I actually
will need to?HaHa). You definitely put a new spin on a topic that's
been written about for many years. Great stuff, just
great!
دوشنبه 12 تیر 1396 06:16 ق.ظ
I drop a leave a response whenever I like a article on a site
or I have something to contribute to the conversation. It is caused by the sincerness communicated in the post I
browsed. And after this post دانلود سورس پروژه های
مختلف برنامه نویسی، آموزش برنامه نویسی - مرتب سازی ادغامی(Merge Sort) در C++.

I was excited enough to drop a thought :-P I actually do have a few questions for you if you do
not mind. Is it only me or do a few of these responses come across like written by brain dead people?
:-P And, if you are writing on other online
social sites, I'd like to follow everything new you have to post.
Would you list all of all your shared sites
like your Facebook page, twitter feed, or linkedin profile?
شنبه 3 تیر 1396 05:17 ب.ظ
Because the admin of this web page is working, no hesitation very rapidly it will be renowned, due to its quality contents.
چهارشنبه 31 خرداد 1396 08:49 ب.ظ
I comment whenever I like a post on a site or if I have something to valuable to contribute to the discussion. It
is triggered by the sincerness communicated in the post
I looked at. And after this article دانلود سورس پروژه های
مختلف برنامه نویسی، آموزش برنامه نویسی - مرتب سازی ادغامی(Merge Sort) در C++.
I was actually excited enough to post a leave
a responsea response :-P I actually do have 2 questions for
you if it's okay. Is it simply me or do some of these remarks appear as if
they are coming from brain dead folks? :-P And, if you
are writing on other online sites, I would like to follow you.
Would you make a list every one of your social pages like your linkedin profile, Facebook page or twitter feed?
پنجشنبه 18 خرداد 1396 06:06 ق.ظ
Everything is very open with a precise description of the issues.

It was truly informative. Your site is extremely helpful.
Many thanks for sharing!
چهارشنبه 3 خرداد 1396 07:10 ب.ظ
After looking over a handful of the blog posts on your website, I honestly appreciate your technique of blogging.
I book marked it to my bookmark website list and will be checking back in the near future.
Take a look at my web site too and tell me what you think.
جمعه 29 اردیبهشت 1396 01:54 ق.ظ
Hey there! I'm at work browsing your blog from my new iphone 3gs!
Just wanted to say I love reading your blog and look forward to all your
posts! Carry on the outstanding work!
پنجشنبه 28 اردیبهشت 1396 10:26 ب.ظ
If you wish for to grow your know-how just keep visiting this site and be updated with the latest news posted here.
یکشنبه 27 فروردین 1396 09:30 ب.ظ
Woah! I'm really enjoying the template/theme of this
website. It's simple, yet effective. A lot of times it's very hard to get that "perfect balance" between usability and visual appearance.
I must say you've done a awesome job with this. Also, the blog loads very quick for
me on Internet explorer. Superb Blog!
 
لبخندناراحتچشمک
نیشخندبغلسوال
قلبخجالتزبان
ماچتعجبعصبانی
عینکشیطانگریه
خندهقهقههخداحافظ
سبزقهرهورا
دستگلتفکر




صفحات جانبی
آمار وبلاگ
تاییدیه پرداخت
تبلیغات
به سایت تک کدر خوش آمدید