Showing posts with label bağlı listeler. Show all posts
Showing posts with label bağlı listeler. Show all posts
Kendisine gönderilen bir integer sayıyı yine kendisine gönderilen bağlı listede bulunduran elemanı silen fonksiyonun c kodu
void liste_eleman_sil(int silinecek,struct eleman **ListeBasi){
struct dugum *b = *ListeBasi;
struct dugum *a;
while(*BagliListe != NULL){
a = b;
b = b->sonraki;
}
if(b == NULL){
return;
}
else if(b == *ListeBasi){
*ListeBasi = (*ListeBasi)->sonraki;
}
else{
a->sonraki = b->sonraki;
}
free(b);
}
void liste_eleman_sil(int silinecek,struct eleman **ListeBasi){
struct dugum *b = *ListeBasi;
struct dugum *a;
while(*BagliListe != NULL){
a = b;
b = b->sonraki;
}
if(b == NULL){
return;
}
else if(b == *ListeBasi){
*ListeBasi = (*ListeBasi)->sonraki;
}
else{
a->sonraki = b->sonraki;
}
free(b);
}
Kendisine gönderilen bağlı listeyi ters çeviren yani tüm bağlantıları tersine çeviren fonksiyonun C kodu
void liste_ters_cevir(struct dugum **BagliListe){
struct dugum *a,*b;
a = NULL;
While(*BagliListe != NULL){
b = *BagliListe;
*BagliListe = (*BagliListe)->sonraki;
b->sonraki = a;
a = b;
}
*BagliListe = a;
}
void liste_ters_cevir(struct dugum **BagliListe){
struct dugum *a,*b;
a = NULL;
While(*BagliListe != NULL){
b = *BagliListe;
*BagliListe = (*BagliListe)->sonraki;
b->sonraki = a;
a = b;
}
*BagliListe = a;
}
Kendisine gönderilen bağlı listedeki en küçük elemanı geri döndüren fonksiyonun c kodu
struct dugum* EnKucukDugum(struct dugum *BagliListe){
struct dugum *EnKucuk = NULL;
struct dugum *ListedeGez = BagliListe;
int EnKucukDeger = ListedeGez->icerik;
While(ListedeGez != NULL){
if(ListedeGez->icerik <= EnKucukDeger){
EnKucukDeger = ListedeGez->icerik;
EnKucuk= ListedeGez;
}
ListedeGez = ListedeGez->sonraki;
return EnKucuk;
}
struct dugum* EnKucukDugum(struct dugum *BagliListe){
struct dugum *EnKucuk = NULL;
struct dugum *ListedeGez = BagliListe;
int EnKucukDeger = ListedeGez->icerik;
While(ListedeGez != NULL){
if(ListedeGez->icerik <= EnKucukDeger){
EnKucukDeger = ListedeGez->icerik;
EnKucuk= ListedeGez;
}
ListedeGez = ListedeGez->sonraki;
return EnKucuk;
}

