kth smallest element
الدرس 10 من 11 في دورة الفرز الفقاعي (Bubble Sort) على Coddy.
التحدي
سهلقم بإنشاء دالة تسمى <strong>kth_smallest</strong> تستقبل مصفوفة من العناصر المميزة، وطول المصفوفة (n) وعددًا صحيحًا k (k<=n). قم بإرجاع العنصر الأصغر رقم k في المصفوفة.
مثال للمدخلات: arr=[2,4,6,1,5,7,8]، n=7، k=3
العنصر الأصغر الثالث هو 4.
المخرجات: 4
جرّب بنفسك
#include <stdio.h>
#include <stdlib.h>
int kth_smallest(int* arr, int arr_size, int n, int k) {
// اكتب الكود هنا
return 0;
}
جميع دروس الفرز الفقاعي (Bubble Sort)
1Basics of Bubble Sort
IntroductionWorking of the Bubble SortSwap adjacent elementsBubble Sort Algorithm