מיון בחירה
מתוך ויקיפדיה, האנציקלופדיה החופשית
מיון בחירה (selection sort בלעז) הוא אלגוריתם מיון השוואתי פשוט אך לא יעיל.
זמן הריצה הממוצע של האלגוריתם הוא פעולות (כמו, למשל, מיון בועות). מבחינת צריכת זיכרון האלגוריתם חסכוני, והוא דורש .
[עריכה] פרטי האלגוריתם
- מצא את הערך בעל הערך הנמוך ביותר במערך
- החלף אותו עם האיבר הראשון במערך
- המשך באותה שיטה על שאר המערך (ללא האיבר הראשון)
זו כנראה הדרך האינטואיטיבית ביותר למיין, אך כאמור היא איננה יעילה במיוחד במונחים של זמן ריצה.
[עריכה] ניתוח זמן הריצה
בהינתן מערך בגודל n, זמן הריצה של האלגוריתם הוא קבוע, כלומר אין מקרה טוב ומקרה רע. בכל מקרה לפי צעד 3, סורקים את שארית המערך n פעמים. זה מביא אותנו לסיבוכיות של .