diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_bfs.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_bfs.cpp" new file mode 100644 index 0000000..b04f4e7 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_bfs.cpp" @@ -0,0 +1,216 @@ +//binary tree silme islemleri + +#include +#include + +struct n{ + int data; + n * sol; + n * sag; +}; + +typedef n node; + +//ekleme - insertion +node *ekle(node *agac, int x) +{ + //agac bos ise node olustur + if(agac==NULL) + { + node *root = (node *)malloc(sizeof(node)); + root->sol = NULL; + root->sag = NULL; + root->data = x; + return root; + } + //agac dolu ise + //agac icin isaretci olsutur ve iter eklenmek istenen degerden kucuk ise + node *iter = agac; + if(iter->data < x) + { + agac->sag = ekle(agac->sag,x); + return agac; + } + agac->sol = ekle(agac->sol,x); + return agac; +} + +//dolasma- traversal +//infix, prefix, postfix + +//infix - kucukten buyuge siralama - LNR +void dolas(node *agac) +{ + if(agac==NULL) + { + return; + } + printf("%d - ", agac->data); + dolas(agac->sol); + + dolas(agac->sag); +} + +//buyukten kucuge siralama - RNL +void dolas_bk(node *agac) +{ + if(agac==NULL) + { + return; + } + printf("%d - ", agac->data); + dolas_bk(agac->sag); + + dolas_bk(agac->sol); +} + +//arama - search +int bul(node * agac, int aranan) +{ + if(agac == NULL) + { + return -1; + } + if(agac->data==aranan) + { + return 1; + } + if(bul(agac->sag,aranan)==1) + { + return 1; + } + if(bul(agac->sol,aranan)==1) + { + return 1; + } + return -1; +} + + +//min ve max bulma +int max(node *agac) +{ + while(agac->sag!=NULL) + { + agac=agac->sag; + } + return agac->data; +} + +int min(node *agac) +{ + while(agac->sol!=NULL) + { + agac=agac->sol; + } + return agac->data; +} + + +//eleman silme +node *sil(node *agac, int x){ + if(agac==NULL) + { + return NULL; + } + if(agac->data == x) + { + if(agac->sol == NULL && agac->sag == NULL) + { + return NULL; + } + if(agac->sag!=NULL) + { + agac->data = min(agac->sag); + agac->sag = sil(agac->sag, min(agac->sag)); + return agac; + } + agac->data = max(agac->sol); + agac->sol = sil(agac->sol, max(agac->sol)); + return agac; + + //sil(agac(min(agac->sag))); + + } + if(agac->datasag = sil(agac->sag,x); + return agac; + } + agac->sol = sil(agac->sol,x); + return agac; +} + +// BFS (Genişlik Öncelikli Arama) +void BFS(node* agac) +{ + if(agac == NULL) + return; + + // Kuyruk veri yapısını kullanarak düğümleri tutacağız + node* kuyruk[100]; + int bas = 0; + int son = 0; + + kuyruk[son] = agac; + son++; + + while(bas < son) + { + node* temp = kuyruk[bas]; + printf("%d ", temp->data); + + if(temp->sol != NULL) + { + kuyruk[son] = temp->sol; + son++; + } + + if(temp->sag != NULL) + { + kuyruk[son] = temp->sag; + son++; + } + + bas++; + } +} + +//BFS algoritmasını kullanarak düğümleri genişlik öncelikli olarak dolaşır. + +int main() +{ + node *agac = NULL; + agac = ekle(agac,56); + agac = ekle(agac,200); + agac = ekle(agac,26); + agac = ekle(agac,190); + agac = ekle(agac,213); + agac = ekle(agac,18); + agac = ekle(agac,28); + agac = ekle(agac,12); + agac = ekle(agac,24); + agac = ekle(agac,27); + + //kucukten buyuge siralama - LNR + dolas(agac); + printf("\n"); + //buyukten kucuge siralama RNL + dolas_bk(agac); + printf("\n"); + //arama + printf("Arama sonucu : %d",bul(agac,100)); + printf("\n"); + printf("Arama sonucu : %d",bul(agac,24)); + printf("\n"); + //min ve max bulma + printf("max = %d min %d",max(agac),min(agac)); + printf("\n"); + + printf("BFS: "); + BFS(agac); + printf("\n"); + + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_bfs.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_bfs.exe" new file mode 100644 index 0000000..f18a514 Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_bfs.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_eklemeli_insertion_siralama.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_eklemeli_insertion_siralama.cpp" new file mode 100644 index 0000000..7d60e24 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_eklemeli_insertion_siralama.cpp" @@ -0,0 +1,218 @@ +//Eklemeli Sıralama (Insertion Sort) + +//binary tree silme islemleri + +#include +#include + +struct n{ + int data; + n * sol; + n * sag; +}; + +typedef n node; + +//ekleme - insertion +node *ekle(node *agac, int x) +{ + //agac bos ise node olustur + if(agac==NULL) + { + node *root = (node *)malloc(sizeof(node)); + root->sol = NULL; + root->sag = NULL; + root->data = x; + return root; + } + //agac dolu ise + //agac icin isaretci olsutur ve iter eklenmek istenen degerden kucuk ise + node *iter = agac; + if(iter->data < x) + { + agac->sag = ekle(agac->sag,x); + return agac; + } + agac->sol = ekle(agac->sol,x); + return agac; +} + +//dolasma- traversal +//infix, prefix, postfix + +//infix - kucukten buyuge siralama - LNR +void dolas(node *agac) +{ + if(agac==NULL) + { + return; + } + printf("%d - ", agac->data); + dolas(agac->sol); + + dolas(agac->sag); +} + +//buyukten kucuge siralama - RNL +void dolas_bk(node *agac) +{ + if(agac==NULL) + { + return; + } + printf("%d - ", agac->data); + dolas_bk(agac->sag); + + dolas_bk(agac->sol); +} + +//arama - search +int bul(node * agac, int aranan) +{ + if(agac == NULL) + { + return -1; + } + if(agac->data==aranan) + { + return 1; + } + if(bul(agac->sag,aranan)==1) + { + return 1; + } + if(bul(agac->sol,aranan)==1) + { + return 1; + } + return -1; +} + + +//min ve max bulma +int max(node *agac) +{ + while(agac->sag!=NULL) + { + agac=agac->sag; + } + return agac->data; +} + +int min(node *agac) +{ + while(agac->sol!=NULL) + { + agac=agac->sol; + } + return agac->data; +} + + +//eleman silme +node *sil(node *agac, int x){ + if(agac==NULL) + { + return NULL; + } + if(agac->data == x) + { + if(agac->sol == NULL && agac->sag == NULL) + { + return NULL; + } + if(agac->sag!=NULL) + { + agac->data = min(agac->sag); + agac->sag = sil(agac->sag, min(agac->sag)); + return agac; + } + agac->data = max(agac->sol); + agac->sol = sil(agac->sol, max(agac->sol)); + return agac; + + //sil(agac(min(agac->sag))); + + } + if(agac->datasag = sil(agac->sag,x); + return agac; + } + agac->sol = sil(agac->sol,x); + return agac; +} + + +// Eklemeli Sıralama (Insertion Sort) +void insertionSort(node* agac) { + if (agac == NULL) + return; + + node* sorted = NULL; + node* current = agac; + + while (current != NULL) { + node* temp = current->sag; + + // Sorted listeyi tarayarak current düğümünün yerini bulma + if (sorted == NULL || current->data <= sorted->data) { + current->sag = sorted; + sorted = current; + } + else { + node* traverse = sorted; + while (traverse->sag != NULL && current->data > traverse->sag->data) { + traverse = traverse->sag; + } + current->sag = traverse->sag; + traverse->sag = current; + } + + current = temp; + } + + // Sıralanmış düğümleri ekrana yazdırma + node* traverse = sorted; + printf("Insertion Sort: "); + while (traverse != NULL) { + printf("%d ", traverse->data); + traverse = traverse->sag; + } + printf("\n"); +} +int main() +{ + node *agac = NULL; + agac = ekle(agac,56); + agac = ekle(agac,200); + agac = ekle(agac,26); + agac = ekle(agac,190); + agac = ekle(agac,213); + agac = ekle(agac,18); + agac = ekle(agac,28); + agac = ekle(agac,12); + agac = ekle(agac,24); + agac = ekle(agac,27); + + //kucukten buyuge siralama - LNR + dolas(agac); + printf("\n"); + //buyukten kucuge siralama RNL + dolas_bk(agac); + printf("\n"); + //arama + printf("Arama sonucu : %d",bul(agac,100)); + printf("\n"); + printf("Arama sonucu : %d",bul(agac,24)); + printf("\n"); + //min ve max bulma + printf("max = %d min %d",max(agac),min(agac)); + printf("\n"); + + // Eklemeli Sıralama (Insertion Sort) + insertionSort(agac); + + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_eklemeli_insertion_siralama.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_eklemeli_insertion_siralama.exe" new file mode 100644 index 0000000..29ee0ee Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_eklemeli_insertion_siralama.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_kabarcik_siralama.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_kabarcik_siralama.cpp" new file mode 100644 index 0000000..e83861b --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_kabarcik_siralama.cpp" @@ -0,0 +1,210 @@ +//kabarcik siralama + +//binary tree silme islemleri + +#include +#include + +struct n{ + int data; + n * sol; + n * sag; +}; + +typedef n node; + +//ekleme - insertion +node *ekle(node *agac, int x) +{ + //agac bos ise node olustur + if(agac==NULL) + { + node *root = (node *)malloc(sizeof(node)); + root->sol = NULL; + root->sag = NULL; + root->data = x; + return root; + } + //agac dolu ise + //agac icin isaretci olsutur ve iter eklenmek istenen degerden kucuk ise + node *iter = agac; + if(iter->data < x) + { + agac->sag = ekle(agac->sag,x); + return agac; + } + agac->sol = ekle(agac->sol,x); + return agac; +} + +//dolasma- traversal +//infix, prefix, postfix + +//infix - kucukten buyuge siralama - LNR +void dolas(node *agac) +{ + if(agac==NULL) + { + return; + } + printf("%d - ", agac->data); + dolas(agac->sol); + + dolas(agac->sag); +} + +//buyukten kucuge siralama - RNL +void dolas_bk(node *agac) +{ + if(agac==NULL) + { + return; + } + printf("%d - ", agac->data); + dolas_bk(agac->sag); + + dolas_bk(agac->sol); +} + +//arama - search +int bul(node * agac, int aranan) +{ + if(agac == NULL) + { + return -1; + } + if(agac->data==aranan) + { + return 1; + } + if(bul(agac->sag,aranan)==1) + { + return 1; + } + if(bul(agac->sol,aranan)==1) + { + return 1; + } + return -1; +} + + +//min ve max bulma +int max(node *agac) +{ + while(agac->sag!=NULL) + { + agac=agac->sag; + } + return agac->data; +} + +int min(node *agac) +{ + while(agac->sol!=NULL) + { + agac=agac->sol; + } + return agac->data; +} + + +//eleman silme +node *sil(node *agac, int x){ + if(agac==NULL) + { + return NULL; + } + if(agac->data == x) + { + if(agac->sol == NULL && agac->sag == NULL) + { + return NULL; + } + if(agac->sag!=NULL) + { + agac->data = min(agac->sag); + agac->sag = sil(agac->sag, min(agac->sag)); + return agac; + } + agac->data = max(agac->sol); + agac->sol = sil(agac->sol, max(agac->sol)); + return agac; + + //sil(agac(min(agac->sag))); + + } + if(agac->datasag = sil(agac->sag,x); + return agac; + } + agac->sol = sil(agac->sol,x); + return agac; +} + + +// Kabarcık sıralama (Bubble Sort) +void bubbleSort(node *agac) { + if (agac == NULL) + return; + + int swapped; + node *ptr1; + node *lptr = NULL; + + do { + swapped = 0; + ptr1 = agac; + + while (ptr1->sag != lptr) { + if (ptr1->data > ptr1->sag->data) { + int temp = ptr1->data; + ptr1->data = ptr1->sag->data; + ptr1->sag->data = temp; + swapped = 1; + } + ptr1 = ptr1->sag; + } + lptr = ptr1; + } while (swapped); +} + +int main() +{ + node *agac = NULL; + agac = ekle(agac,56); + agac = ekle(agac,200); + agac = ekle(agac,26); + agac = ekle(agac,190); + agac = ekle(agac,213); + agac = ekle(agac,18); + agac = ekle(agac,28); + agac = ekle(agac,12); + agac = ekle(agac,24); + agac = ekle(agac,27); + + //kucukten buyuge siralama - LNR + dolas(agac); + printf("\n"); + //buyukten kucuge siralama RNL + dolas_bk(agac); + printf("\n"); + //arama + printf("Arama sonucu : %d",bul(agac,100)); + printf("\n"); + printf("Arama sonucu : %d",bul(agac,24)); + printf("\n"); + //min ve max bulma + printf("max = %d min %d",max(agac),min(agac)); + printf("\n"); + + //bubblesort + bubbleSort(agac); + printf("Sorted tree: "); + dolas(agac); + printf("\n"); + + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_kabarcik_siralama.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_kabarcik_siralama.exe" new file mode 100644 index 0000000..6aef29b Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_kabarcik_siralama.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_selection_secmeli_siralama.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_selection_secmeli_siralama.cpp" new file mode 100644 index 0000000..f3ec4c2 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_selection_secmeli_siralama.cpp" @@ -0,0 +1,215 @@ +//binary tree silme islemleri + +#include +#include + +struct n{ + int data; + n * sol; + n * sag; +}; + +typedef n node; + +//ekleme - insertion +node *ekle(node *agac, int x) +{ + //agac bos ise node olustur + if(agac==NULL) + { + node *root = (node *)malloc(sizeof(node)); + root->sol = NULL; + root->sag = NULL; + root->data = x; + return root; + } + //agac dolu ise + //agac icin isaretci olsutur ve iter eklenmek istenen degerden kucuk ise + node *iter = agac; + if(iter->data < x) + { + agac->sag = ekle(agac->sag,x); + return agac; + } + agac->sol = ekle(agac->sol,x); + return agac; +} + +//dolasma- traversal +//infix, prefix, postfix + +//infix - kucukten buyuge siralama - LNR +void dolas(node *agac) +{ + if(agac==NULL) + { + return; + } + printf("%d - ", agac->data); + dolas(agac->sol); + + dolas(agac->sag); +} + +//buyukten kucuge siralama - RNL +void dolas_bk(node *agac) +{ + if(agac==NULL) + { + return; + } + printf("%d - ", agac->data); + dolas_bk(agac->sag); + + dolas_bk(agac->sol); +} + +//arama - search +int bul(node * agac, int aranan) +{ + if(agac == NULL) + { + return -1; + } + if(agac->data==aranan) + { + return 1; + } + if(bul(agac->sag,aranan)==1) + { + return 1; + } + if(bul(agac->sol,aranan)==1) + { + return 1; + } + return -1; +} + + +//min ve max bulma +int max(node *agac) +{ + while(agac->sag!=NULL) + { + agac=agac->sag; + } + return agac->data; +} + +int min(node *agac) +{ + while(agac->sol!=NULL) + { + agac=agac->sol; + } + return agac->data; +} + + +//eleman silme +node *sil(node *agac, int x){ + if(agac==NULL) + { + return NULL; + } + if(agac->data == x) + { + if(agac->sol == NULL && agac->sag == NULL) + { + return NULL; + } + if(agac->sag!=NULL) + { + agac->data = min(agac->sag); + agac->sag = sil(agac->sag, min(agac->sag)); + return agac; + } + agac->data = max(agac->sol); + agac->sol = sil(agac->sol, max(agac->sol)); + return agac; + + //sil(agac(min(agac->sag))); + + } + if(agac->datasag = sil(agac->sag,x); + return agac; + } + agac->sol = sil(agac->sol,x); + return agac; +} + + + +// Selection Sort +void selectionSort(node *agac) +{ + if (agac == NULL) + return; + + node *minNode = agac; + node *iter = agac; + + while (iter != NULL) + { + node *temp = iter; + while (temp != NULL) + { + if (temp->data < minNode->data) + minNode = temp; + + temp = temp->sag; + } + + // Swap data values + int tempData = iter->data; + iter->data = minNode->data; + minNode->data = tempData; + + iter = iter->sag; + minNode = iter; + } +} + +int main() +{ + node *agac = NULL; + agac = ekle(agac,56); + agac = ekle(agac,200); + agac = ekle(agac,26); + agac = ekle(agac,190); + agac = ekle(agac,213); + agac = ekle(agac,18); + agac = ekle(agac,28); + agac = ekle(agac,12); + agac = ekle(agac,24); + agac = ekle(agac,27); + + //kucukten buyuge siralama - LNR + dolas(agac); + printf("\n"); + //buyukten kucuge siralama RNL + dolas_bk(agac); + printf("\n"); + //arama + printf("Arama sonucu : %d",bul(agac,100)); + printf("\n"); + printf("Arama sonucu : %d",bul(agac,24)); + printf("\n"); + //min ve max bulma + printf("max = %d min %d",max(agac),min(agac)); + printf("\n"); + + // Selection Sort + selectionSort(agac); + printf("Selection Sort: "); + dolas(agac); + printf("\n"); + + + + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_selection_secmeli_siralama.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_selection_secmeli_siralama.exe" new file mode 100644 index 0000000..b2f259d Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary tree_selection_secmeli_siralama.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree.cpp" new file mode 100644 index 0000000..aaaf500 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree.cpp" @@ -0,0 +1,54 @@ +//binary tree +//basit bir yapidir +//bir node en fazla iki alt node alabilir + +//7 elemanli bir tree graph olusturulacaktir. + +#include +#include + +struct node +{ + int data; + //sag ve sol veriler + struct node *left; + struct node *right; +}; + +//yeni bir alan ac ve node olustur +struct node *newNode(int data) +{ + struct node *neww = (struct node *)malloc(sizeof(struct node)); + neww->data = data; + neww->left = NULL; + neww->right = NULL; + + return neww; +} + + +int main() +{ + //root olustur + struct node *root = newNode(1); + + //yeni bir node olustur ve root'a bagla + root->left = newNode(2); + root->right = newNode(3); + + //root'a bagli nodelarain altina node baglama + root->left->left = newNode(4); + root->left->right = newNode(5); + root->right->left = newNode(6); + root->right->right = newNode(7); + + printf("Root : %d \n", root->data); + printf("Root left : %d \n",root->left->data); + printf("Root right : %d \n",root->right->data); + printf("Root left left : %d \n",root->left->left->data); + printf("Root left right : %d \n",root->left->right->data); + printf("Root right left : %d \n",root->right->left->data); + printf("Root right right : %d \n",root->right->right->data); + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree.exe" new file mode 100644 index 0000000..0bb525a Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_1.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_1.cpp" new file mode 100644 index 0000000..5781df3 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_1.cpp" @@ -0,0 +1,135 @@ +#include +#include + +struct n{ + int data; + n * sol; + n * sag; +}; + +typedef n node; + +//ekleme - insertion +node *ekle(node *agac, int x) +{ + //agac bos ise node olustur + if(agac==NULL) + { + node *root = (node *)malloc(sizeof(node)); + root->sol = NULL; + root->sag = NULL; + root->data = x; + return root; + } + //agac dolu ise + //agac icin isaretci olsutur ve iter eklenmek istenen degerden kucuk ise + node *iter = agac; + if(iter->data < x) + { + agac->sag = ekle(agac->sag,x); + return agac; + } + agac->sol = ekle(agac->sol,x); + return agac; +} + +//dolasma- traversal +//infix, prefix, postfix + +//infix - kucukten buyuge siralama - LNR +void dolas(node *agac) +{ + if(agac==NULL) + { + return; + } + dolas(agac->sol); + printf("%d - ", agac->data); + dolas(agac->sag); +} + +//buyukten kucuge siralama - RNL +void dolas_bk(node *agac) +{ + if(agac==NULL) + { + return; + } + dolas_bk(agac->sag); + printf("%d - ", agac->data); + dolas_bk(agac->sol); +} + +//arama - search +int bul(node * agac, int aranan) +{ + if(agac == NULL) + { + return -1; + } + if(agac->data==aranan) + { + return 1; + } + if(bul(agac->sag,aranan)==1) + { + return 1; + } + if(bul(agac->sol,aranan)==1) + { + return 1; + } + return -1; +} + + +//min ve max bulma +int max(node *agac) +{ + while(agac->sag!=NULL) + { + agac=agac->sag; + } + return agac->data; +} + +int min(node *agac) +{ + while(agac->sol!=NULL) + { + agac=agac->sol; + } + return agac->data; +} + +int main() +{ + node *agac = NULL; + agac = ekle(agac,12); + agac = ekle(agac,200); + agac = ekle(agac,190); + agac = ekle(agac,213); + agac = ekle(agac,56); + agac = ekle(agac,24); + agac = ekle(agac,18); + agac = ekle(agac,27); + agac = ekle(agac,28); + + //kucukten buyuge siralama - LNR + dolas(agac); + printf("\n"); + //buyukten kucuge siralama RNL + dolas_bk(agac); + printf("\n"); + //arama + printf("Arama sonucu : %d",bul(agac,100)); + printf("\n"); + printf("Arama sonucu : %d",bul(agac,24)); + printf("\n"); + //min ve max bulma + printf("max = %d min %d",max(agac),min(agac)); + printf("\n"); + + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_1.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_1.exe" new file mode 100644 index 0000000..3218588 Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_1.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_avl-yapilmadi.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_avl-yapilmadi.cpp" new file mode 100644 index 0000000..8f39fe0 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_avl-yapilmadi.cpp" @@ -0,0 +1,181 @@ +//AVL Ağacı Arama: AVL ağacı, bir dengeleme mekanizması kullanarak sıralı bir ikili ağaç oluşturur. + +//binary tree silme islemleri + +#include +#include + +struct n{ + int data; + n * sol; + n * sag; +}; + +typedef n node; + +//ekleme - insertion +node *ekle(node *agac, int x) +{ + //agac bos ise node olustur + if(agac==NULL) + { + node *root = (node *)malloc(sizeof(node)); + root->sol = NULL; + root->sag = NULL; + root->data = x; + return root; + } + //agac dolu ise + //agac icin isaretci olsutur ve iter eklenmek istenen degerden kucuk ise + node *iter = agac; + if(iter->data < x) + { + agac->sag = ekle(agac->sag,x); + return agac; + } + agac->sol = ekle(agac->sol,x); + return agac; +} + +//dolasma- traversal +//infix, prefix, postfix + +//infix - kucukten buyuge siralama - LNR +void dolas(node *agac) +{ + if(agac==NULL) + { + return; + } + printf("%d - ", agac->data); + dolas(agac->sol); + + dolas(agac->sag); +} + +//buyukten kucuge siralama - RNL +void dolas_bk(node *agac) +{ + if(agac==NULL) + { + return; + } + printf("%d - ", agac->data); + dolas_bk(agac->sag); + + dolas_bk(agac->sol); +} + +//arama - search +int bul(node * agac, int aranan) +{ + if(agac == NULL) + { + return -1; + } + if(agac->data==aranan) + { + return 1; + } + if(bul(agac->sag,aranan)==1) + { + return 1; + } + if(bul(agac->sol,aranan)==1) + { + return 1; + } + return -1; +} + + +//min ve max bulma +int max(node *agac) +{ + while(agac->sag!=NULL) + { + agac=agac->sag; + } + return agac->data; +} + +int min(node *agac) +{ + while(agac->sol!=NULL) + { + agac=agac->sol; + } + return agac->data; +} + + +//eleman silme +node *sil(node *agac, int x){ + if(agac==NULL) + { + return NULL; + } + if(agac->data == x) + { + if(agac->sol == NULL && agac->sag == NULL) + { + return NULL; + } + if(agac->sag!=NULL) + { + agac->data = min(agac->sag); + agac->sag = sil(agac->sag, min(agac->sag)); + return agac; + } + agac->data = max(agac->sol); + agac->sol = sil(agac->sol, max(agac->sol)); + return agac; + + //sil(agac(min(agac->sag))); + + } + if(agac->datasag = sil(agac->sag,x); + return agac; + } + agac->sol = sil(agac->sol,x); + return agac; +} + + + +int main() +{ + node *agac = NULL; + agac = ekle(agac,56); + agac = ekle(agac,200); + agac = ekle(agac,26); + agac = ekle(agac,190); + agac = ekle(agac,213); + agac = ekle(agac,18); + agac = ekle(agac,28); + agac = ekle(agac,12); + agac = ekle(agac,24); + agac = ekle(agac,27); + + //kucukten buyuge siralama - LNR + dolas(agac); + printf("\n"); + //buyukten kucuge siralama RNL + dolas_bk(agac); + printf("\n"); + //arama + printf("Arama sonucu : %d",bul(agac,100)); + printf("\n"); + printf("Arama sonucu : %d",bul(agac,24)); + printf("\n"); + //min ve max bulma + printf("max = %d min %d",max(agac),min(agac)); + printf("\n"); + + + + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_dfs.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_dfs.cpp" new file mode 100644 index 0000000..0b154be --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_dfs.cpp" @@ -0,0 +1,227 @@ +//binary tree silme islemleri + +#include +#include + +struct n{ + int data; + n * sol; + n * sag; +}; + +typedef n node; + +//ekleme - insertion +node *ekle(node *agac, int x) +{ + //agac bos ise node olustur + if(agac==NULL) + { + node *root = (node *)malloc(sizeof(node)); + root->sol = NULL; + root->sag = NULL; + root->data = x; + return root; + } + //agac dolu ise + //agac icin isaretci olsutur ve iter eklenmek istenen degerden kucuk ise + node *iter = agac; + if(iter->data < x) + { + agac->sag = ekle(agac->sag,x); + return agac; + } + agac->sol = ekle(agac->sol,x); + return agac; +} + +//dolasma- traversal +//infix, prefix, postfix + +//infix - kucukten buyuge siralama - LNR +void dolas(node *agac) +{ + if(agac==NULL) + { + return; + } + printf("%d - ", agac->data); + dolas(agac->sol); + + dolas(agac->sag); +} + +//buyukten kucuge siralama - RNL +void dolas_bk(node *agac) +{ + if(agac==NULL) + { + return; + } + printf("%d - ", agac->data); + dolas_bk(agac->sag); + + dolas_bk(agac->sol); +} + +//arama - search +int bul(node * agac, int aranan) +{ + if(agac == NULL) + { + return -1; + } + if(agac->data==aranan) + { + return 1; + } + if(bul(agac->sag,aranan)==1) + { + return 1; + } + if(bul(agac->sol,aranan)==1) + { + return 1; + } + return -1; +} + + +//min ve max bulma +int max(node *agac) +{ + while(agac->sag!=NULL) + { + agac=agac->sag; + } + return agac->data; +} + +int min(node *agac) +{ + while(agac->sol!=NULL) + { + agac=agac->sol; + } + return agac->data; +} + + +//eleman silme +node *sil(node *agac, int x){ + if(agac==NULL) + { + return NULL; + } + if(agac->data == x) + { + if(agac->sol == NULL && agac->sag == NULL) + { + return NULL; + } + if(agac->sag!=NULL) + { + agac->data = min(agac->sag); + agac->sag = sil(agac->sag, min(agac->sag)); + return agac; + } + agac->data = max(agac->sol); + agac->sol = sil(agac->sol, max(agac->sol)); + return agac; + + //sil(agac(min(agac->sag))); + + } + if(agac->datasag = sil(agac->sag,x); + return agac; + } + agac->sol = sil(agac->sol,x); + return agac; +} + + + +// DFS - Preorder (Kök - Sol - Sağ) +void preOrderDFS(node* agac) +{ + if(agac == NULL) + return; + + printf("%d ", agac->data); + preOrderDFS(agac->sol); + preOrderDFS(agac->sag); +} + +// DFS - Inorder (Sol - Kök - Sağ) +void inOrderDFS(node* agac) +{ + if(agac == NULL) + return; + + inOrderDFS(agac->sol); + printf("%d ", agac->data); + inOrderDFS(agac->sag); +} + +// DFS - Postorder (Sol - Sağ - Kök) +void postOrderDFS(node* agac) +{ + if(agac == NULL) + return; + + postOrderDFS(agac->sol); + postOrderDFS(agac->sag); + printf("%d ", agac->data); +} + +//Preorder, Kök-Sol-Sağ +//Inorder Sol-Kök-Sağ +//Postorder Sol-Sağ-Kök + +int main() +{ + node *agac = NULL; + agac = ekle(agac,56); + agac = ekle(agac,200); + agac = ekle(agac,26); + agac = ekle(agac,190); + agac = ekle(agac,213); + agac = ekle(agac,18); + agac = ekle(agac,28); + agac = ekle(agac,12); + agac = ekle(agac,24); + agac = ekle(agac,27); + + //kucukten buyuge siralama - LNR + dolas(agac); + printf("\n"); + //buyukten kucuge siralama RNL + dolas_bk(agac); + printf("\n"); + //arama + printf("Arama sonucu : %d",bul(agac,100)); + printf("\n"); + printf("Arama sonucu : %d",bul(agac,24)); + printf("\n"); + //min ve max bulma + printf("max = %d min %d",max(agac),min(agac)); + printf("\n"); + + printf("DFS - Preorder: "); + preOrderDFS(agac); + printf("\n"); + + printf("DFS - Inorder: "); + inOrderDFS(agac); + printf("\n"); + + printf("DFS - Postorder: "); + postOrderDFS(agac); + printf("\n"); + + + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_dfs.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_dfs.exe" new file mode 100644 index 0000000..dcc6170 Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_dfs.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_silme.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_silme.cpp" new file mode 100644 index 0000000..8136e90 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_silme.cpp" @@ -0,0 +1,181 @@ +//binary tree silme islemleri + +#include +#include + +struct n{ + int data; + n * sol; + n * sag; +}; + +typedef n node; + +//ekleme - insertion +node *ekle(node *agac, int x) +{ + //agac bos ise node olustur + if(agac==NULL) + { + node *root = (node *)malloc(sizeof(node)); + root->sol = NULL; + root->sag = NULL; + root->data = x; + return root; + } + //agac dolu ise + //agac icin isaretci olsutur ve iter eklenmek istenen degerden kucuk ise + node *iter = agac; + if(iter->data < x) + { + agac->sag = ekle(agac->sag,x); + return agac; + } + agac->sol = ekle(agac->sol,x); + return agac; +} + +//dolasma- traversal +//infix, prefix, postfix + +//infix - kucukten buyuge siralama - LNR +void dolas(node *agac) +{ + if(agac==NULL) + { + return; + } + printf("%d - ", agac->data); + dolas(agac->sol); + + dolas(agac->sag); +} + +//buyukten kucuge siralama - RNL +void dolas_bk(node *agac) +{ + if(agac==NULL) + { + return; + } + printf("%d - ", agac->data); + dolas_bk(agac->sag); + + dolas_bk(agac->sol); +} + +//arama - search +int bul(node * agac, int aranan) +{ + if(agac == NULL) + { + return -1; + } + if(agac->data==aranan) + { + return 1; + } + if(bul(agac->sag,aranan)==1) + { + return 1; + } + if(bul(agac->sol,aranan)==1) + { + return 1; + } + return -1; +} + + +//min ve max bulma +int max(node *agac) +{ + while(agac->sag!=NULL) + { + agac=agac->sag; + } + return agac->data; +} + +int min(node *agac) +{ + while(agac->sol!=NULL) + { + agac=agac->sol; + } + return agac->data; +} + + +//eleman silme +node *sil(node *agac, int x){ + if(agac==NULL) + { + return NULL; + } + if(agac->data == x) + { + if(agac->sol == NULL && agac->sag == NULL) + { + return NULL; + } + if(agac->sag!=NULL) + { + agac->data = min(agac->sag); + agac->sag = sil(agac->sag, min(agac->sag)); + return agac; + } + agac->data = max(agac->sol); + agac->sol = sil(agac->sol, max(agac->sol)); + return agac; + + //sil(agac(min(agac->sag))); + + } + if(agac->datasag = sil(agac->sag,x); + return agac; + } + agac->sol = sil(agac->sol,x); + return agac; +} + +int main() +{ + node *agac = NULL; + agac = ekle(agac,56); + agac = ekle(agac,200); + agac = ekle(agac,26); + agac = ekle(agac,190); + agac = ekle(agac,213); + agac = ekle(agac,18); + agac = ekle(agac,28); + agac = ekle(agac,12); + agac = ekle(agac,24); + agac = ekle(agac,27); + + //kucukten buyuge siralama - LNR + dolas(agac); + printf("\n"); + //buyukten kucuge siralama RNL + dolas_bk(agac); + printf("\n"); + //arama + printf("Arama sonucu : %d",bul(agac,100)); + printf("\n"); + printf("Arama sonucu : %d",bul(agac,24)); + printf("\n"); + //min ve max bulma + printf("max = %d min %d",max(agac),min(agac)); + printf("\n"); + //silme islemi + + agac = sil(agac,56); + printf("Yeni agac : "); + dolas_bk(agac); + printf("\n"); + + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_silme.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_silme.exe" new file mode 100644 index 0000000..9a63700 Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/binary tree/binary_tree_silme.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_ikili_arama.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_ikili_arama.cpp" new file mode 100644 index 0000000..711a0ff --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_ikili_arama.cpp" @@ -0,0 +1,135 @@ +//dairesel yonlu bagli liste +//doubly list + +#include +#include + +struct n{ + int x; + n *next; +}; + +typedef n node; + +void bastir(node *r) +{ + while(r!=NULL) + { + printf("%d - ",r->x); + r = r->next; + } + printf("\n"); +} + +void ekle(node *r, int x) +{ + while(r->next!=NULL) + { + r = r->next; + } + r->next = (node *)malloc(sizeof(node)); + r->next->x = x; + r->next->next = NULL; +} + +node *ekleSirali(node *r, int x) +{ + if(r==NULL) + { + //liste bos ise + r = (node *)malloc(sizeof(node)); + r->next = NULL; + r->x = x; + return r; + } + + if(r->x > x) + { + //ilk elemandan kucuk olma durumu + //rooot degisiyor + node *temp = (node *)malloc(sizeof(node)); + temp->x = x; + temp->next = r; + return temp; + } + + node *iter = r; + while(iter->next!=NULL && iter->next->x < x) + { + iter = iter->next; + } + node *temp = (node *)malloc(sizeof(node)); + temp->next = iter->next; + iter->next = temp; + temp->x = x; + return r; +} + +node *sil(node *r, int x) +{ + node *temp; + node *iter = r; + if(r->x = x) + { + temp= r; + r=r->next; + free(temp); + return r; + } + while(iter->next!=NULL && iter->next->x != x) + { + iter = iter->next; + } + if(iter->next == NULL) + { + printf("sayi bulunamadi"); + return r; + } + temp = iter->next; + iter->next = iter->next->next; + free(temp); + return r; +} + +//ikili arama +node *ikiliArama(node *r, int x) { + if (r == NULL) { + printf("Liste bos.\n"); + return NULL; + } + + node *bas = r; + node *son = r->prev; + + while (bas != son && bas->prev != son) { + if (bas->x == x) + return bas; + if (son->x == x) + return son; + + bas = bas->next; + son = son->prev; + } + + if (bas == son && bas->x == x) + return bas; + + printf("Eleman bulunamadi.\n"); + return NULL; +} + +int main() +{ + node * root; + root = NULL; + root = ekleSirali(root,400); + root = ekleSirali(root,40); + root = ekleSirali(root,4); + root = ekleSirali(root,450); + root = ekleSirali(root,50); + bastir(root); + + root = ikiliArama(root,50); + + +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_konuma_ekle_sil.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_konuma_ekle_sil.cpp" new file mode 100644 index 0000000..e5ec503 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_konuma_ekle_sil.cpp" @@ -0,0 +1,204 @@ +//dairesel yonlu bagli liste +//doubly list + +#include +#include + +struct n{ + int x; + n *next; +}; + +typedef n node; + +void bastir(node *r) +{ + while(r!=NULL) + { + printf("%d - ",r->x); + r = r->next; + } + printf("\n"); +} + +void ekle(node *r, int x) +{ + while(r->next!=NULL) + { + r = r->next; + } + r->next = (node *)malloc(sizeof(node)); + r->next->x = x; + r->next->next = NULL; +} + +node *ekleSirali(node *r, int x) +{ + if(r==NULL) + { + //liste bos ise + r = (node *)malloc(sizeof(node)); + r->next = NULL; + r->x = x; + return r; + } + + if(r->x > x) + { + //ilk elemandan kucuk olma durumu + //rooot degisiyor + node *temp = (node *)malloc(sizeof(node)); + temp->x = x; + temp->next = r; + return temp; + } + + node *iter = r; + while(iter->next!=NULL && iter->next->x < x) + { + iter = iter->next; + } + node *temp = (node *)malloc(sizeof(node)); + temp->next = iter->next; + iter->next = temp; + temp->x = x; + return r; +} + +node *sil(node *r, int x) +{ + node *temp; + node *iter = r; + if(r->x = x) + { + temp= r; + r=r->next; + free(temp); + return r; + } + while(iter->next!=NULL && iter->next->x != x) + { + iter = iter->next; + } + if(iter->next == NULL) + { + printf("sayi bulunamadi"); + return r; + } + temp = iter->next; + iter->next = iter->next->next; + free(temp); + return r; +} + + +//// Listeye yeni bir düğüm ekleyen fonksiyon +node *insertAtPosition(node *start, int data, int position) { + node *newNode, *ptr; + int i; + + newNode = (node *)malloc(sizeof(node)); + newNode->x = data; + + if (start == NULL) { // Liste boşsa, yeni düğümü başa ekle + newNode->next = newNode; + start = newNode; + } else if (position == 0) { // Başa ekleme + newNode->next = start; + ptr = start; + + while (ptr->next != start) + ptr = ptr->next; + + ptr->next = newNode; + start = newNode; + } else { // Araya veya sona ekleme + ptr = start; + for (i = 0; i < position - 1; i++) { + ptr = ptr->next; + if (ptr == start) { + printf("Geçersiz konum.\n"); + return start; + } + } + + newNode->next = ptr->next; + ptr->next = newNode; + } + + return start; +} + +// Belirtilen konumdaki düğümü listeden silen fonksiyon +node *deleteAtPosition(node *start, int position) { + node *currentNode, *previousNode; + int i; + + if (start == NULL) { + printf("Liste boş.\n"); + return start; + } + + currentNode = start; + if (position == 0) { // Başlangıç düğümünü silme + while (currentNode->next != start) + currentNode = currentNode->next; + + currentNode->next = start->next; + free(start); + start = currentNode->next; + } else { // Diğer düğümleri silme + for (i = 0; i < position; i++) { + previousNode = currentNode; + currentNode = currentNode->next; + + if (currentNode == start) { + printf("Geçersiz konum.\n"); + return start; + } + } + + previousNode->next = currentNode->next; + free(currentNode); + } + + return start; +} + + +// Listeyi baştan sona doğru yazdıran fonksiyon +void display(node *start) { + node *ptr = start; + + if (start == NULL) { + printf("Liste boş.\n"); + return; + } + + printf("Liste: "); + do { + printf("%d ", ptr->x); + ptr = ptr->next; + } while (ptr != start); + + printf("\n"); +} + + +int main() +{ + + node *start = NULL; + + start = insertAtPosition(start, 10, 0); + start = insertAtPosition(start, 20, 0); + start = insertAtPosition(start, 30, 1); + start = insertAtPosition(start, 40, 3); + + display(start); // Liste: 20 30 10 40 + + start = deleteAtPosition(start, 2); + + display(start); // Liste: + +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_konuma_ekle_sil.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_konuma_ekle_sil.exe" new file mode 100644 index 0000000..29a8aa9 Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_konuma_ekle_sil.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list.cpp" new file mode 100644 index 0000000..3bd3fda --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list.cpp" @@ -0,0 +1,111 @@ +//dairesel yonlu bagli liste +//doubly list + +#include +#include + +struct n{ + int x; + n *next; +}; + +typedef n node; + +void bastir(node *r) +{ + while(r!=NULL) + { + printf("%d - ",r->x); + r = r->next; + } + printf("\n"); +} + +void ekle(node *r, int x) +{ + while(r->next!=NULL) + { + r = r->next; + } + r->next = (node *)malloc(sizeof(node)); + r->next->x = x; + r->next->next = NULL; +} + +node *ekleSirali(node *r, int x) +{ + if(r==NULL) + { + //liste bos ise + r = (node *)malloc(sizeof(node)); + r->next = NULL; + r->x = x; + return r; + } + + if(r->x > x) + { + //ilk elemandan kucuk olma durumu + //rooot degisiyor + node *temp = (node *)malloc(sizeof(node)); + temp->x = x; + temp->next = r; + return temp; + } + + node *iter = r; + while(iter->next!=NULL && iter->next->x < x) + { + iter = iter->next; + } + node *temp = (node *)malloc(sizeof(node)); + temp->next = iter->next; + iter->next = temp; + temp->x = x; + return r; +} + +node *sil(node *r, int x) +{ + node *temp; + node *iter = r; + if(r->x = x) + { + temp= r; + r=r->next; + free(temp); + return r; + } + while(iter->next!=NULL && iter->next->x != x) + { + iter = iter->next; + } + if(iter->next == NULL) + { + printf("sayi bulunamadi"); + return r; + } + temp = iter->next; + iter->next = iter->next->next; + free(temp); + return r; +} + +int main() +{ + node * root; + root = NULL; + root = ekleSirali(root,400); + root = ekleSirali(root,40); + root = ekleSirali(root,4); + root = ekleSirali(root,450); + root = ekleSirali(root,50); + bastir(root); + root = sil(root,50); + bastir(root); + root = sil(root,999); + bastir(root); + root = sil(root,450); + bastir(root); + +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list.exe" new file mode 100644 index 0000000..9a93feb Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_bubble.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_bubble.cpp" new file mode 100644 index 0000000..ea8bcc1 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_bubble.cpp" @@ -0,0 +1,141 @@ +//dairesel yonlu bagli liste +//doubly list + +#include +#include + +struct n{ + int x; + n *next; +}; + +typedef n node; + +void bastir(node *r) +{ + while(r!=NULL) + { + printf("%d - ",r->x); + r = r->next; + } + printf("\n"); +} + +void ekle(node *r, int x) +{ + while(r->next!=NULL) + { + r = r->next; + } + r->next = (node *)malloc(sizeof(node)); + r->next->x = x; + r->next->next = NULL; +} + +node *ekleSirali(node *r, int x) +{ + if(r==NULL) + { + //liste bos ise + r = (node *)malloc(sizeof(node)); + r->next = NULL; + r->x = x; + return r; + } + + if(r->x > x) + { + //ilk elemandan kucuk olma durumu + //rooot degisiyor + node *temp = (node *)malloc(sizeof(node)); + temp->x = x; + temp->next = r; + return temp; + } + + node *iter = r; + while(iter->next!=NULL && iter->next->x < x) + { + iter = iter->next; + } + node *temp = (node *)malloc(sizeof(node)); + temp->next = iter->next; + iter->next = temp; + temp->x = x; + return r; +} + +node *sil(node *r, int x) +{ + node *temp; + node *iter = r; + if(r->x = x) + { + temp= r; + r=r->next; + free(temp); + return r; + } + while(iter->next!=NULL && iter->next->x != x) + { + iter = iter->next; + } + if(iter->next == NULL) + { + printf("sayi bulunamadi"); + return r; + } + temp = iter->next; + iter->next = iter->next->next; + free(temp); + return r; +} + +//bubble sort +node* bubbleSort(node* r) +{ + if (r == NULL || r->next == NULL) + return r; + + int swapped; + node *ptr1; + node *lptr = NULL; + + do { + swapped = 0; + ptr1 = r; + + while (ptr1->next != lptr) { + if (ptr1->x > ptr1->next->x) { + int temp = ptr1->x; + ptr1->x = ptr1->next->x; + ptr1->next->x = temp; + swapped = 1; + } + ptr1 = ptr1->next; + } + lptr = ptr1; + } while (swapped); + + return r; +} + + + +int main() +{ + node * root; + root = NULL; + root = ekleSirali(root,400); + root = ekleSirali(root,40); + root = ekleSirali(root,4); + root = ekleSirali(root,450); + root = ekleSirali(root,50); + bastir(root); + + //bubble sort + root = bubbleSort(root); + bastir(root); + + +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_bubble.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_bubble.exe" new file mode 100644 index 0000000..849a2f2 Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_bubble.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_eklemeli_siralama.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_eklemeli_siralama.cpp" new file mode 100644 index 0000000..1e04649 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_eklemeli_siralama.cpp" @@ -0,0 +1,172 @@ +//dairesel yonlu bagli liste +//doubly list + +#include +#include + +struct n{ + int x; + n *next; +}; + +typedef n node; + +void bastir(node *r) +{ + while(r!=NULL) + { + printf("%d - ",r->x); + r = r->next; + } + printf("\n"); +} + +void ekle(node *r, int x) +{ + while(r->next!=NULL) + { + r = r->next; + } + r->next = (node *)malloc(sizeof(node)); + r->next->x = x; + r->next->next = NULL; +} + +node *ekleSirali(node *r, int x) +{ + if(r==NULL) + { + //liste bos ise + r = (node *)malloc(sizeof(node)); + r->next = NULL; + r->x = x; + return r; + } + + if(r->x > x) + { + //ilk elemandan kucuk olma durumu + //rooot degisiyor + node *temp = (node *)malloc(sizeof(node)); + temp->x = x; + temp->next = r; + return temp; + } + + node *iter = r; + while(iter->next!=NULL && iter->next->x < x) + { + iter = iter->next; + } + node *temp = (node *)malloc(sizeof(node)); + temp->next = iter->next; + iter->next = temp; + temp->x = x; + return r; +} + +node *sil(node *r, int x) +{ + node *temp; + node *iter = r; + if(r->x = x) + { + temp= r; + r=r->next; + free(temp); + return r; + } + while(iter->next!=NULL && iter->next->x != x) + { + iter = iter->next; + } + if(iter->next == NULL) + { + printf("sayi bulunamadi"); + return r; + } + temp = iter->next; + iter->next = iter->next->next; + free(temp); + return r; +} + +//eklemeli siralama +node* createNode(int data) { + node* newNode = (node*)malloc(sizeof(node)); + newNode->data = data; + newNode->next = NULL; + newNode->prev = NULL; + + return newNode; +} + +node* insertSorted(node* root, int data) { + node* newNode = createNode(data); + + if (root == NULL) { + newNode->next = newNode; + newNode->prev = newNode; + return newNode; + } + + node* iter = root; + + if (data <= iter->data) { + newNode->next = iter; + newNode->prev = iter->prev; + + iter->prev->next = newNode; + iter->prev = newNode; + + return newNode; + } + + while (iter->next != root && data > iter->next->data) { + iter = iter->next; + } + + newNode->next = iter->next; + newNode->prev = iter; + + iter->next->prev = newNode; + iter->next = newNode; + + return root; +} + +node* insertionSort(node* root) { + if (root == NULL || root->next == root) { + return root; + } + + node* sorted = NULL; + node* iter = root; + + do { + sorted = insertSorted(sorted, iter->data); + iter = iter->next; + } while (iter != root); + + return sorted; +} + + +int main() +{ + node * root; + root = NULL; + root = ekleSirali(root,400); + root = ekleSirali(root,40); + root = ekleSirali(root,4); + root = ekleSirali(root,450); + root = ekleSirali(root,50); + bastir(root); + + //eklemeli siralama + node* sorted = insertionSort(root); + bastir(sorted); + + + +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_lineer_arama.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_lineer_arama.cpp" new file mode 100644 index 0000000..e7af5e0 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_lineer_arama.cpp" @@ -0,0 +1,131 @@ +//dairesel yonlu bagli liste +//doubly list + +#include +#include + +struct n{ + int x; + n *next; +}; + +typedef n node; + +void bastir(node *r) +{ + while(r!=NULL) + { + printf("%d - ",r->x); + r = r->next; + } + printf("\n"); +} + +void ekle(node *r, int x) +{ + while(r->next!=NULL) + { + r = r->next; + } + r->next = (node *)malloc(sizeof(node)); + r->next->x = x; + r->next->next = NULL; +} + +node *ekleSirali(node *r, int x) +{ + if(r==NULL) + { + //liste bos ise + r = (node *)malloc(sizeof(node)); + r->next = NULL; + r->x = x; + return r; + } + + if(r->x > x) + { + //ilk elemandan kucuk olma durumu + //rooot degisiyor + node *temp = (node *)malloc(sizeof(node)); + temp->x = x; + temp->next = r; + return temp; + } + + node *iter = r; + while(iter->next!=NULL && iter->next->x < x) + { + iter = iter->next; + } + node *temp = (node *)malloc(sizeof(node)); + temp->next = iter->next; + iter->next = temp; + temp->x = x; + return r; +} + +node *sil(node *r, int x) +{ + node *temp; + node *iter = r; + if(r->x = x) + { + temp= r; + r=r->next; + free(temp); + return r; + } + while(iter->next!=NULL && iter->next->x != x) + { + iter = iter->next; + } + if(iter->next == NULL) + { + printf("sayi bulunamadi"); + return r; + } + temp = iter->next; + iter->next = iter->next->next; + free(temp); + return r; +} + +//lineer arama +void lineerArama(node *r, int aranan) +{ + int index = 0; // aranan elemanın varsa indeksi + int counter = 0; // döngüde kaçıncı elemanda olduğumuzu tutmak için kullanıyoruz + node *iter = r; + while(iter->next != NULL && iter->x != aranan) + { + iter = iter->next; + counter++; + } + + if(iter->x == aranan) + { + printf("%d elemanı %d indexinde bulundu.\n", aranan, counter); + } + else + { + printf("Eleman bulunamadı.\n"); + } +} + +int main() +{ + node * root; + root = NULL; + root = ekleSirali(root,400); + root = ekleSirali(root,40); + root = ekleSirali(root,4); + root = ekleSirali(root,450); + root = ekleSirali(root,50); + bastir(root); + + lineerArama(root,50); + + + +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_lineer_arama.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_lineer_arama.exe" new file mode 100644 index 0000000..0a3e89f Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_lineer_arama.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_secmeli.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_secmeli.cpp" new file mode 100644 index 0000000..7132af0 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_secmeli.cpp" @@ -0,0 +1,136 @@ +//dairesel yonlu bagli liste +//doubly list + +#include +#include + +struct n{ + int x; + n *next; +}; + +typedef n node; + +void bastir(node *r) +{ + while(r!=NULL) + { + printf("%d - ",r->x); + r = r->next; + } + printf("\n"); +} + +void ekle(node *r, int x) +{ + while(r->next!=NULL) + { + r = r->next; + } + r->next = (node *)malloc(sizeof(node)); + r->next->x = x; + r->next->next = NULL; +} + +node *ekleSirali(node *r, int x) +{ + if(r==NULL) + { + //liste bos ise + r = (node *)malloc(sizeof(node)); + r->next = NULL; + r->x = x; + return r; + } + + if(r->x > x) + { + //ilk elemandan kucuk olma durumu + //rooot degisiyor + node *temp = (node *)malloc(sizeof(node)); + temp->x = x; + temp->next = r; + return temp; + } + + node *iter = r; + while(iter->next!=NULL && iter->next->x < x) + { + iter = iter->next; + } + node *temp = (node *)malloc(sizeof(node)); + temp->next = iter->next; + iter->next = temp; + temp->x = x; + return r; +} + +node *sil(node *r, int x) +{ + node *temp; + node *iter = r; + if(r->x = x) + { + temp= r; + r=r->next; + free(temp); + return r; + } + while(iter->next!=NULL && iter->next->x != x) + { + iter = iter->next; + } + if(iter->next == NULL) + { + printf("sayi bulunamadi"); + return r; + } + temp = iter->next; + iter->next = iter->next->next; + free(temp); + return r; +} + +//seçmeli - selection siralama +void selectionSort(node *r) +{ + node *i, *j, *min; + int temp; + + for (i = r; i != NULL; i = i->next) + { + min = i; + for (j = i->next; j != NULL; j = j->next) + { + if (j->x < min->x) + { + min = j; + } + } + if (min != i) + { + temp = i->x; + i->x = min->x; + min->x = temp; + } + } +} + +int main() +{ + node * root; + root = NULL; + root = ekleSirali(root,400); + root = ekleSirali(root,40); + root = ekleSirali(root,4); + root = ekleSirali(root,450); + root = ekleSirali(root,50); + bastir(root); + + printf("Sıralanmış liste: "); + selectionSort(root); + bastir(root); + + + +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_secmeli.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_secmeli.exe" new file mode 100644 index 0000000..38355d2 Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_linked_list_secmeli.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_liste_basi_ekleme_silme.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_liste_basi_ekleme_silme.cpp" new file mode 100644 index 0000000..230ee6c --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_liste_basi_ekleme_silme.cpp" @@ -0,0 +1,265 @@ +//dairesel yonlu bagli liste +//doubly list + +#include +#include + +struct n{ + int x; + n *next; +}; + +typedef n node; + +void bastir(node *r) +{ + while(r!=NULL) + { + printf("%d - ",r->x); + r = r->next; + } + printf("\n"); +} + +void ekle(node *r, int x) +{ + while(r->next!=NULL) + { + r = r->next; + } + r->next = (node *)malloc(sizeof(node)); + r->next->x = x; + r->next->next = NULL; +} + +node *ekleSirali(node *r, int x) +{ + if(r==NULL) + { + //liste bos ise + r = (node *)malloc(sizeof(node)); + r->next = NULL; + r->x = x; + return r; + } + + if(r->x > x) + { + //ilk elemandan kucuk olma durumu + //rooot degisiyor + node *temp = (node *)malloc(sizeof(node)); + temp->x = x; + temp->next = r; + return temp; + } + + node *iter = r; + while(iter->next!=NULL && iter->next->x < x) + { + iter = iter->next; + } + node *temp = (node *)malloc(sizeof(node)); + temp->next = iter->next; + iter->next = temp; + temp->x = x; + return r; +} + +node *sil(node *r, int x) +{ + node *temp; + node *iter = r; + if(r->x = x) + { + temp= r; + r=r->next; + free(temp); + return r; + } + while(iter->next!=NULL && iter->next->x != x) + { + iter = iter->next; + } + if(iter->next == NULL) + { + printf("sayi bulunamadi"); + return r; + } + temp = iter->next; + iter->next = iter->next->next; + free(temp); + return r; +} + + +//// Listeye yeni bir düğüm ekleyen fonksiyon +node *insertAtPosition(node *start, int data, int position) { + node *newNode, *ptr; + int i; + + newNode = (node *)malloc(sizeof(node)); + newNode->x = data; + + if (start == NULL) { // Liste boşsa, yeni düğümü başa ekle + newNode->next = newNode; + start = newNode; + } else if (position == 0) { // Başa ekleme + newNode->next = start; + ptr = start; + + while (ptr->next != start) + ptr = ptr->next; + + ptr->next = newNode; + start = newNode; + } else { // Araya veya sona ekleme + ptr = start; + for (i = 0; i < position - 1; i++) { + ptr = ptr->next; + if (ptr == start) { + printf("Geçersiz konum.\n"); + return start; + } + } + + newNode->next = ptr->next; + ptr->next = newNode; + } + + return start; +} + +// Belirtilen konumdaki düğümü listeden silen fonksiyon +node *deleteAtPosition(node *start, int position) { + node *currentNode, *previousNode; + int i; + + if (start == NULL) { + printf("Liste boş.\n"); + return start; + } + + currentNode = start; + if (position == 0) { // Başlangıç düğümünü silme + while (currentNode->next != start) + currentNode = currentNode->next; + + currentNode->next = start->next; + free(start); + start = currentNode->next; + } else { // Diğer düğümleri silme + for (i = 0; i < position; i++) { + previousNode = currentNode; + currentNode = currentNode->next; + + if (currentNode == start) { + printf("Geçersiz konum.\n"); + return start; + } + } + + previousNode->next = currentNode->next; + free(currentNode); + } + + return start; +} + + +// Listeyi baştan sona doğru yazdıran fonksiyon +void display(node *start) { + node *ptr = start; + + if (start == NULL) { + printf("Liste boş.\n"); + return; + } + + printf("Liste: "); + do { + printf("%d ", ptr->x); + ptr = ptr->next; + } while (ptr != start); + + printf("\n"); +} + + +// Listenin başına yeni bir düğüm ekleyen fonksiyon +node *insertAtBeginning(node *start, int data) { + node *newNode, *ptr; + + newNode = (node *)malloc(sizeof(node)); + newNode->x = data; + + if (start == NULL) { // Liste boşsa, yeni düğümü tek düğüm olarak ekler + newNode->next = newNode; + start = newNode; + } else { // Yeni düğümü listenin başına ekler + ptr = start; + + while (ptr->next != start) + ptr = ptr->next; + + ptr->next = newNode; + newNode->next = start; + start = newNode; + } + + return start; +} + +// Listenin başındaki düğümü silen fonksiyon +node *deleteAtBeginning(node *start) { + node *ptr, *temp; + + if (start == NULL) { + printf("Liste boş.\n"); + return start; + } + + if (start->next == start) { // Tek düğüm varsa, listeden çıkar ve serbest bırakır + free(start); + start = NULL; + } else { // İlk düğümü siler ve bağlantıları günceller + ptr = start; + while (ptr->next != start) + ptr = ptr->next; + + temp = start; + start = start->next; + ptr->next = start; + free(temp); + } + + return start; +} + +int main() +{ + + node *start = NULL; + + start = insertAtPosition(start, 10, 0); + start = insertAtPosition(start, 20, 0); + start = insertAtPosition(start, 30, 1); + start = insertAtPosition(start, 40, 3); + + display(start); // Liste: 20 30 10 40 + + start = deleteAtPosition(start, 2); + + display(start); // Liste: + + printf("\n"); + start = insertAtBeginning(start, 111111); + start = insertAtBeginning(start, 22222); + start = insertAtBeginning(start, 333333); + + display(start); + + start = deleteAtBeginning(start); + + display(start); + +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_liste_basi_ekleme_silme.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_liste_basi_ekleme_silme.exe" new file mode 100644 index 0000000..e523cce Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/dairesel linked list/dairesel_liste_basi_ekleme_silme.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/doubly linked list/cift_yonlu_liste_konuma_ekle_konumdan_sli.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/doubly linked list/cift_yonlu_liste_konuma_ekle_konumdan_sli.cpp" new file mode 100644 index 0000000..d4d8da3 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/doubly linked list/cift_yonlu_liste_konuma_ekle_konumdan_sli.cpp" @@ -0,0 +1,236 @@ +//cift yonlu bagli liste +//doubly list + +#include +#include + +struct n{ + int x; + n *next; + n *prev;// +}; + +typedef n node; + +void bastir(node *r) +{ + while(r!=NULL) + { + printf("%d - ",r->x); + r = r->next; + } + printf("\n"); +} +/* +void ekle(node *r, int x) +{ + while(r->next!=NULL) + { + r = r->next; + } + r->next (node *)malloc(sizeof(node)); + r->next->x = x; + r->next->next = NULL; +} +*/ +node *ekleSirali(node *r, int x) +{ + if(r==NULL) + { + //liste bos ise + r = (node *)malloc(sizeof(node)); + r->next = NULL; + r->prev = NULL;// + r->x = x; + return r; + } + + if(r->x > x) + { + //ilk elemandan kucuk olma durumu + //rooot degisiyor + node *temp = (node *)malloc(sizeof(node)); + temp->x = x; + temp->next = r; + return temp; + } + + node *iter = r; + while(iter->next!=NULL && iter->next->x < x) + { + iter = iter->next; + } + node *temp = (node *)malloc(sizeof(node)); + temp->next = iter->next; + iter->next = temp; + temp->prev = iter; + + if(temp->next!=NULL) + temp->next->prev = temp; + temp->x = x; + return r; +} + +node *sil(node *r, int x) +{ + node *temp; + node *iter = r; + if(r->x = x) + { + temp= r; + r=r->next; + free(temp); + return r; + } + while(iter->next!=NULL && iter->next->x != x) + { + iter = iter->next; + } + if(iter->next == NULL) + { + printf("sayi bulunamadi"); + return r; + } + temp = iter->next; + iter->next = iter->next->next; + free(temp); + if(iter->next!=NULL)// + iter->next->prev = iter;// + return r; +} + + +//ters goster +void tersGoster(node *r) +{ + if (r == NULL) { + printf("Liste bos\n"); + return; + } + //ilk deger + int ilk = r->x; + + // Son düğüme kadar ileriye doğru iterasyonla ilerle + while (r->next != NULL) { + r = r->next; + } + + printf("Ters Gosterim: "); + + // Son düğümden başlayarak geriye doğru ilerle ve verileri yazdır + while (r != NULL) { + printf("%d - ", r->x); + r = r->prev; + } + printf("%d",ilk); + printf("\n"); +} + + +//konumdan silme kodu +node* createNode(int data) { + node* newNode = (node*)malloc(sizeof(node)); + if (newNode == NULL) { + printf("Bellek hatasi!\n"); + exit(1); + } + newNode->x = data; + newNode->prev = NULL; + newNode->next = NULL; + return newNode; +} + +void insertAtPosition(node** head, int data, int position) { + node* newNode = createNode(data); + if (*head == NULL) { + *head = newNode; + return; + } + if (position == 1) { + newNode->next = *head; + (*head)->prev = newNode; + *head = newNode; + return; + } + node* current = *head; + int count = 1; + while (count < position - 1 && current->next != NULL) { + current = current->next; + count++; + } + if (count != position - 1) { + printf("Belirtilen konum bulunamadi.\n"); + free(newNode); + return; + } + newNode->prev = current; + newNode->next = current->next; + if (current->next != NULL) { + current->next->prev = newNode; + } + current->next = newNode; +} + +void deleteAtPosition(node** head, int position) { + if (*head == NULL) { + printf("Liste bos.\n"); + return; + } + if (position == 1) { + node* temp = *head; + *head = (*head)->next; + if (*head != NULL) { + (*head)->prev = NULL; + } + free(temp); + return; + } + node* current = *head; + int count = 1; + while (count < position && current != NULL) { + current = current->next; + count++; + } + if (current == NULL) { + printf("Belirtilen konum bulunamadi.\n"); + return; + } + current->prev->next = current->next; + if (current->next != NULL) { + current->next->prev = current->prev; + } + free(current); +} + +void printList(node* head) { + node* current = head; + while (current != NULL) { + printf("%d ", current->x); + current = current->next; + } + printf("\n"); +} + + +int main() +{ + node* head = NULL; + + insertAtPosition(&head, 10, 1); // 10 + insertAtPosition(&head, 20, 2); // 10 20 + insertAtPosition(&head, 30, 3); // 10 20 30 + insertAtPosition(&head, 40, 4); // 10 20 30 40 + insertAtPosition(&head, 50, 5); // 10 20 30 40 50 + + printf("Liste: "); + printList(head); + + deleteAtPosition(&head, 3); // 10 20 40 50 + deleteAtPosition(&head, 1); // 20 40 50 + deleteAtPosition(&head, 4); // 20 40 50 + + printf("Liste: "); + printList(head); + + +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/doubly linked list/cift_yonlu_liste_konuma_ekle_konumdan_sli.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/doubly linked list/cift_yonlu_liste_konuma_ekle_konumdan_sli.exe" new file mode 100644 index 0000000..57b0e98 Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/doubly linked list/cift_yonlu_liste_konuma_ekle_konumdan_sli.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/doubly linked list/doubly_linked_list.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/doubly linked list/doubly_linked_list.cpp" new file mode 100644 index 0000000..db480a6 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/doubly linked list/doubly_linked_list.cpp" @@ -0,0 +1,154 @@ +//cift yonlu bagli liste +//doubly list + +#include +#include + +struct n{ + int x; + n *next; + n *prev;// +}; + +typedef n node; + +void bastir(node *r) +{ + while(r!=NULL) + { + printf("%d - ",r->x); + r = r->next; + } + printf("\n"); +} +/* +void ekle(node *r, int x) +{ + while(r->next!=NULL) + { + r = r->next; + } + r->next (node *)malloc(sizeof(node)); + r->next->x = x; + r->next->next = NULL; +} +*/ +node *ekleSirali(node *r, int x) +{ + if(r==NULL) + { + //liste bos ise + r = (node *)malloc(sizeof(node)); + r->next = NULL; + r->prev = NULL;// + r->x = x; + return r; + } + + if(r->x > x) + { + //ilk elemandan kucuk olma durumu + //rooot degisiyor + node *temp = (node *)malloc(sizeof(node)); + temp->x = x; + temp->next = r; + return temp; + } + + node *iter = r; + while(iter->next!=NULL && iter->next->x < x) + { + iter = iter->next; + } + node *temp = (node *)malloc(sizeof(node)); + temp->next = iter->next; + iter->next = temp; + temp->prev = iter; + + if(temp->next!=NULL) + temp->next->prev = temp; + temp->x = x; + return r; +} + +node *sil(node *r, int x) +{ + node *temp; + node *iter = r; + if(r->x = x) + { + temp= r; + r=r->next; + free(temp); + return r; + } + while(iter->next!=NULL && iter->next->x != x) + { + iter = iter->next; + } + if(iter->next == NULL) + { + printf("sayi bulunamadi"); + return r; + } + temp = iter->next; + iter->next = iter->next->next; + free(temp); + if(iter->next!=NULL)// + iter->next->prev = iter;// + return r; +} + + +//ters goster +void tersGoster(node *r) +{ + if (r == NULL) { + printf("Liste bos\n"); + return; + } + //ilk deger + int ilk = r->x; + + // Son düğüme kadar ileriye doğru iterasyonla ilerle + while (r->next != NULL) { + r = r->next; + } + + printf("Ters Gosterim: "); + + // Son düğümden başlayarak geriye doğru ilerle ve verileri yazdır + while (r != NULL) { + printf("%d - ", r->x); + r = r->prev; + } + printf("%d",ilk); + printf("\n"); +} + + + + +int main() +{ + node * root; + root = NULL; + root = ekleSirali(root,400); + root = ekleSirali(root,40); + root = ekleSirali(root,4); + root = ekleSirali(root,450); + root = ekleSirali(root,50); + + //ters goster + bastir(root); + tersGoster(root); + + bastir(root); + root = sil(root,50); + bastir(root); + root = sil(root,999); + bastir(root); + root = sil(root,450); + bastir(root); + +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/doubly linked list/doubly_linked_list.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/doubly linked list/doubly_linked_list.exe" new file mode 100644 index 0000000..43d45a6 Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/doubly linked list/doubly_linked_list.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/linked list/linked_list.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/linked list/linked_list.cpp" new file mode 100644 index 0000000..dc8dc58 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/linked list/linked_list.cpp" @@ -0,0 +1,299 @@ +//bagli liste +//dinamik boyutludur +//her eleman veri ve sonraki elemani gosteren bir pointer'a sahiptir. + +//dizilerin boyutlari sahiptir ama linked list boyutu dinamiktir. +//diziler tanimlanirken boyutluari belirtilmelidir. linked list icin yoktur. +//dizi elemanlari bellekte art arda siralidir ama linked list icin olmayabilir + +//dizilerde rastgele erisim var ama linked list icin sirali erisim var +//dizilerde eleman silme veya kaydirilma islemi zordur ama linked list icin kolay +//dizile ayni tur verileri saklar ama linked list farkli turleri saklayabilir + +//linked list ozellikleri +//liste basini head ve sonunu tail isimli pointerlar gosterir. +//eleman yok ise head ve tail NULL +//listede tek eleman var ise o elemani +//birden fazla eleman var ise birbirine baglidir ve head liste basi ve tail ise liste sonunu gosterir. + + +#include +#include + +//linked list +struct node{ + int data; + struct node *next; +}; + +//head ve tail +struct node *head = NULL; +struct node *tail = NULL; + +//addnode +int addNode(int data) +{ + //linked list bos ise, yeni bir node olustur + if(head==NULL) + { + struct node *neww = (struct node *)malloc(sizeof(struct node)); + neww->data = data; + neww->next = NULL; + + //listenin basi ve sonu yeni elemani goster + //head ve tail guncelle + head = tail= neww; + } + //linked list dolu ise + else{ + //yeni node olustur, veriyi al ve next NULL yap + struct node *neww = (struct node *)malloc(sizeof(struct node)); + neww->data = data; + neww->next = NULL; + + //tail guncelle + tail->next = neww; + tail = neww; + } + return 1; +} + +//Listenin basina eleman ekleme +//liste bos ise elemani ekle ve head ile tail guncelle +int addNodeHead(int data){ + if(head==NULL){ + struct node *neww = (struct node *)malloc(sizeof(struct node)); + neww->data = data; + neww->next = NULL; + } + //liste dolu ise + else{ + //node olustur + struct node *neww = (struct node*)malloc(sizeof(struct node)); + neww->data = data; + neww->next = head; + + //head guncelle + head = neww; + } +} + +//listeyi yazdirma +//index adinda bir degisken olustur ve head'in gosterdigi ilk degeri gostersin +//sirasi ile diger elemani ve o elemanin isaret ettigi diger elemana giderel goster +//NULL degeri gelirse yazdirma durdur + +int print() +{ + printf("\n"); + printf("Linked list yazildi : \n"); + struct node *index = head; + while(index!=NULL) + { + printf("%d - ",index->data); + //sonraki elemana git, index yeni degeri index->next olmalidir + index = index->next; + } + printf("\n"); +} + + +//eleman silme +//liste bosmu veya dolumu +//head ise head guncelle +//tail ise tail guncelle +//listede ilgili eleman yok ise +//eger listede var ise onceki ve sonraki elemani birbirine bagla +//onceki eleman prev olarak kullanildi +//index ise gezen yapi +int silme(int data){ + struct node *prev = NULL; + struct node *index = head; + + printf("\n"); + printf("%d silinmis liste",data); + //linked list bos ise + if(head==NULL) + { + printf("\nLinked list bos\n"); + return 1; + } + + //silinecek eleman head ise + if(head->data == data) + { + struct node *t = head; + //head yeni degeri gostersin, guncelle + head = head->next; + //elemani sil + free(t); + return 1; + } + + //listede arama yap, prev kullanilacak, index NULl veya silinmek istenen veriye esit degilse + while(index!=NULL && index->data!=data) + { + prev = index; // onceki eleman, aslinda mevcut eleman + index = index->next; // index yeni eleman oldu + } + + //index NULL ise + if(index==NULL){ + printf("\nIstenen deger bulunamadi"); + } + + //aranan deger bulunmus ise prev next icin index next'e bagla + prev->next = index->next; + + //silinen eleman tail ise, onceki eleman tail olur ve tail guncelle + if(tail->data == data){ + tail = prev; + } + + //index sil + free(index); + + + return 1; +} + +//uzunluk +int uzunluk() +{ + int count = 0; + struct node *index = head; + + while(index != NULL) + { + count++; + index = index->next; + } + + return count; +} + +//ekleme sirali +int eklesirali(int data) +{ + struct node* new_node = (struct node*)malloc(sizeof(struct node)); + new_node->data = data; + new_node->next = NULL; + + if (head == NULL) + { + // Liste boş ise yeni düğümü başa ekle + head = new_node; + tail = new_node; + return 1; + } + + if (data < head->data) + { + // Yeni veri, listenin başından küçükse yeni düğümü başa ekle + new_node->next = head; + head = new_node; + return 1; + } + + if (data > tail->data) + { + // Yeni veri, listenin sonundan büyükse yeni düğümü sona ekle + tail->next = new_node; + tail = new_node; + return 1; + } + + struct node* current = head; + struct node* previous = NULL; + + while (current != NULL && data > current->data) + { + previous = current; + current = current->next; + } + + // Yeni düğümü doğru konuma eklemek için bağlantıları güncelle + previous->next = new_node; + new_node->next = current; + + return 1; +} + + + + +int main() +{ + eklesirali(4); + eklesirali(5); + eklesirali(12); + eklesirali(8); + eklesirali(9); + print(); + + //eleman ekleme + addNode(10); + addNode(11); + addNode(12); + addNode(13); + + //listenin basina eleman ekleme + addNodeHead(9); + addNodeHead(8); + + addNode(14); + addNode(15); + addNode(16); + + addNodeHead(7); + addNodeHead(6); + + print(); + + //liste basi silme + silme(6); + print(); + + + //liste icinden eleman silme + silme(11); + print(); + silme(13); + print(); + + + //hepsini sil + silme(8); + print(); + silme(9); + print(); + silme(10); + print(); + silme(12); + print(); + silme(7); + print(); + silme(14); + print(); + silme(15); + print(); + silme(16); + print(); + + + //listede olmayan eleman silme + silme(15); + print(); + + addNode(16); + print(); + addNodeHead(7); + print(); + addNode(17); + print(); + + int length = uzunluk(); + printf("\nLinked list uzunlugu: %d\n", length); + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/linked list/linked_list.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/linked list/linked_list.exe" new file mode 100644 index 0000000..882cb4a Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/linked list/linked_list.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/queue/queue.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/queue/queue.cpp" new file mode 100644 index 0000000..9a58964 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/queue/queue.cpp" @@ -0,0 +1,163 @@ +//linear yyapidadir +//ilk gelen eleman ilk cikar, son giren son cikar +//fifo - first in first out +//fifo icin linked list kullanilabilir + +//pipe, disk , swtich, router ve elektronik devrelerde kullanilir + +//array ile queue kullanimi------------- +//ilk yere deger ekle +//diger elemanlar sirasi ile ilk bos indexe yerlestir +//5 +//5-8 +//5-8-6 +//cikarma ise +//ilk elemandar sirasi ile cikar +//5-8-6 +//8-6 +//6 + + +//linked list icin ise queue--------------------------------------- +//basini ve sonunu gosterern isaretci kullanilir ve ekleme ile cikarma ile guncellenir +//front bas, rear ise sonu gosterir +//ekleme icin rear, cikarma islemi icin front guncelle +//kuyruk bos iken front ve rear NULL, tek eleman var ise o elemani gosterir +//birden fazla eleman var ise, front en basi, rear ise en sonu gosterir. + + +#include +#include + + +//queue +struct node{ + int data; + struct node *next; +}; + +//front ve rear +struct node *front = NULL; +struct node *rear = NULL; + + +//eleman ekleme - enqueue +int enqueue(int data){ + //kuyruk bos ise + //yeni node olustur ve deger eklemesi yap + //front ve rear guncelle + if(front==NULL){ + struct node *neww = (struct node *)malloc(sizeof(struct node)); + neww->data = data; + neww->next = NULL; + + front = rear = neww; + } + //kuyruk bos degil ise + else{ + //eleman olustur + struct node *neww = (struct node *)malloc(sizeof(struct node)); + neww->data = data; + neww->next = NULL; + + //sonu guncelle + rear->next = neww; + rear = neww; + } + + return 1; +} + +//display queue - kuyruk yazdirma +//front'un isaret ettigi degeri index'e al ve sirasi ile gez +int display(){ + + struct node *index = front; + //kuyruk bosmu? + if(front==NULL){ + printf("\nKuyruk Bos \n"); + return 1; + } + + printf("\nKuyruk yazildi : \n"); + //bos degil ise, index NULL olana kadar yazdir + while(index!=NULL) + { + printf("%d - ", index->data); + index = index->next; + } + + + return 1; +} + + +//eleman cikarma - dequeue +int dequeue() +{ + //kuyruk bosmu + if(front == NULL) + { + printf("\nKuyruk bos\n"); + } + //eleman var ise + //front diger elemani gostersin + //suanki elemani yedekle temp ile + struct node *temp = front; + + front = front->next; + //elemani sil + free(temp); + + return 1; +} + +//main +int main() +{ + //eleman ekleme + enqueue(5); + enqueue(6); + enqueue(8); + //yazdirma + display(); + enqueue(9); + enqueue(10); + + //yazdirma + display(); + + //dequeue + dequeue(); + //yazdirma + display(); + //dequeue + dequeue(); + //yazdirma + display(); + //dequeue + dequeue(); + //yazdirma + display(); + //dequeue + dequeue(); + //yazdirma + display(); + //dequeue + dequeue(); + //yazdirma + display(); + //dequeue + dequeue(); + //yazdirma + display(); + + + enqueue(5); + enqueue(6); + //yazdirma + display(); + + return 1; +} + diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/queue/queue.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/queue/queue.exe" new file mode 100644 index 0000000..784ab34 Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/queue/queue.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/stack/stack.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/stack/stack.cpp" new file mode 100644 index 0000000..b574d53 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/stack/stack.cpp" @@ -0,0 +1,133 @@ +//stack +//linear yapidadir +//lifo - son giren ilk cikar +//last in first out - linked list ile kullanilabilir ve array ile kullanilabilir +//bellek yonetimi, swap, geri al butonu, web tarayici geri ve ileri + +//array ile stack yapimi-------------------- +//ilk eleman ilk index'e yerlestir. +//sonraki elemanlar ise ilk index'e yerlesi ve indexler kaydirilir +//cikarma ise en basindan yapilir +//ekleme : 15 +//ekleme : 8-15 +//ekleme : 6-8-15 +//cikarma : 8-15 +//cikarma : 15 + +//linked list ile stack---------------------- +//top listenin basini gosterir ve listenin basi son giren elemandir. +//listeye son giren elemani gosteren isaretci kullanilir ve ekleme ile cikarma islemi ile bu isaretci guncellenir : bu isaretci : top +//stack bos iken top = NULL eger eleman var ise tek olan elemani top isaret eder +//birden fazla eleman var ise top degiskeni en bastaki elemani gosterir. + +#include +#include + + + +//stack +struct node{ + int data; + struct node *next; +}; + +//top icin +struct node *top = NULL; + +//eleman ekleme - push +int push(int data) +{ + //bos ise yeni elemann olustur ve top = neww olacak + if(top==NULL) + { + struct node *neww = (struct node *)malloc(sizeof(struct node)); + neww->data = data; + neww->next = NULL; + + top = neww; + } + //dolu ise + else{ + //eleman olsutur ve basa ekle ve top guncelle + struct node *neww = (struct node *)malloc(sizeof(struct node)); + neww->data = data; + neww->next = top; + + top = neww; + } +} + +//yazdirma - display +int display() +{ + //ilk degerden basla ve sona git, index = top olmalidir ve sirasi ile gez + //sonda ise NULL gelirse listeyi yazdirmayi durdur. + printf("\n"); + + //bos mu dolu mu + if(top==NULL) + { + printf("Stack bostur \n"); + return 1; + } + + //dolu ise + struct node *index = top; + while(index!=NULL) + { + printf("%d - ", index->data); + index = index->next; + } + printf("\n"); + + return 1; +} + +//eleman cikarma - pop +int pop() +{ + //bos mu dolu mu + if(top==NULL) + { + printf("\nStack bos \n"); + return 1; + } + + //dolu ise + struct node *temp = top; + top = top->next; + free(temp); + + return 1; +} + + +//main +int main() +{ + //ekleme + push(1); + push(2); + push(3); + push(4); + + //yazdir + display(); + + //cikarma + pop(); + display(); + pop(); + display(); + pop(); + display(); + pop(); + display(); + + push(4); + display(); + + + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/stack/stack.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/stack/stack.exe" new file mode 100644 index 0000000..9762db2 Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/stack/stack.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct1.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct1.cpp" new file mode 100644 index 0000000..5f442b3 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct1.cpp" @@ -0,0 +1,55 @@ +#include +#include +#include + +//1 +struct kitap{ + char kitapAdi[30]; + float fiyat; + int sayfa; +}; + +//2, typedef kullanırsan int main içinde struct kullanmana gerek yoktur +typedef struct yazar{//eski + char adSoyad[30]; + int yas; +}yazar;//yeni, bunu yazmasanda olur + + +int main() +{ + //1 icin direct + struct kitap kitap1; + strcpy(kitap1.kitapAdi,"Turklerin Tarihi"); + kitap1.fiyat = 17.50; + kitap1.sayfa = 350; + + printf("Bilgiler : %s %f %d\n",kitap1.kitapAdi,kitap1.fiyat,kitap1.sayfa); + + + //1 icin undirect - pointer ile + struct kitap *kitap2 = (struct kitap *)malloc(sizeof(struct kitap)); + strcpy(kitap2->kitapAdi,"Fabrika Ayari"); + kitap2->fiyat = 16.50; + kitap2->sayfa = 3000; + + printf("Bilgiler : %s %f %d\n", kitap2->kitapAdi,kitap2->fiyat,kitap2->sayfa); + + + //typedef - direct + yazar yazar1; + strcpy(yazar1.adSoyad,"İlber Ortayli"); + yazar1.yas = 74; + + //typedef - undirect + yazar *yazar2 = (yazar *)malloc(sizeof(yazar)); + strcpy(yazar2->adSoyad, "Hayati Inanc"); + yazar2->yas = 60; + + printf("Yazar 1: %s %d\n", yazar1.adSoyad, yazar1.yas); + printf("Yazar 2: %s %d\n", yazar2->adSoyad, yazar2->yas); + + + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct1.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct1.exe" new file mode 100644 index 0000000..a746e1a Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct1.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct2.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct2.cpp" new file mode 100644 index 0000000..fcb988b --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct2.cpp" @@ -0,0 +1,30 @@ +#include +#include +#include + +//struct icinde struct kullanma ve deger atama + +typedef struct{ + char takimAdi[30]; + int kurulus; +}takim; + +typedef struct{ + char adSoyad[30]; + int yas; + takim takim;//ilk struct yapisi, ikinci degisken ismi +}futbolcu; + + +int main(){ + + futbolcu ft; + strcpy(ft.adSoyad,"Nurullaj Aslan"); + ft.yas = 20; + strcpy(ft.takim.takimAdi,"Samsunspor"); + ft.takim.kurulus = 1965; + + printf("Bilgiler: %s %d", ft.takim.takimAdi, ft.takim.kurulus); + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct2.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct2.exe" new file mode 100644 index 0000000..7c23225 Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct2.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct3.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct3.cpp" new file mode 100644 index 0000000..a58d018 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct3.cpp" @@ -0,0 +1,35 @@ +#include +#include +#include + +//struct icinde struct kullanma ve deger atama + +typedef struct{ + char takimAdi[30]; + int kurulus; +}takim; + +typedef struct{ + char adSoyad[30]; + int yas; + takim takim;//ilk struct yapisi, ikinci degisken ismi +}futbolcu; + + +int main() +{ + //farkli kullanim + takim tk; + strcpy(tk.takimAdi,"Samsunspor"); + tk.kurulus = 1965; + + + futbolcu ft; + strcpy(ft.adSoyad,"Burak Calik"); + ft.yas = 30; + ft.takim = tk; + + printf("Bilgiler : %s %d",ft.takim.takimAdi,ft.takim.kurulus); + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct3.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct3.exe" new file mode 100644 index 0000000..e0f6544 Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct3.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct4.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct4.cpp" new file mode 100644 index 0000000..1686d71 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct4.cpp" @@ -0,0 +1,32 @@ +#include +#include +#include + +//pointer ile +//struct icinde struct kullanma ve deger atama + +typedef struct{ + char takimAdi[30]; + int kurulus; +}takim; + +typedef struct{ + char adSoyad[30]; + int yas; + takim *takim; +}futbolcu; + +int main() +{ + takim *tk = (takim *)malloc(sizeof(takim)); + strcpy(tk->takimAdi,"Samsunspor"); + tk->kurulus = 1965; + futbolcu ft; + strcpy(ft.adSoyad,"Ilyas Kubilay Yavruz"); + ft.yas = 26; + ft.takim = tk; + + printf("Bilgiler: %s %d", ft.takim->takimAdi,ft.takim->kurulus); + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct4.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct4.exe" new file mode 100644 index 0000000..6b03e10 Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/struct/struct4.exe" differ diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/tree/tree.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/tree/tree.cpp" new file mode 100644 index 0000000..024c318 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/tree/tree.cpp" @@ -0,0 +1,22 @@ +//tree - agac yapisi +//non - linear +//veriler bir sanal olarak baglanmasidir +//hiyerasik saklama imkani verir. alt- ust veya parent-child iliskisi vardir. +//node ve edge ile olusur ve nodelar ise edgeler ile birbirine baglidir. +//node her elemana verilen dugumdur : A,B,C vb. +//root ise agacin ilk elemanidir ve agaci baslatir +//edge iki elemani baglayan yapidir : A-C, A-B, C-B +//child ise bir ust node'a bagli node'dur +//parent ise alt nodelari olan node'dur, aile olarak bilinebilir veya ebeveyn olarak bilinebilir +//leaf ise en sonda kalan ve devami olmayan node'lar, childlari yoktur. +//sibling ise ayni parent'e bagli kardeslerdir. +//depth ise bir node icin root'a olan uzakliktir. + +//kullanim alanlari ise isletim sistemi icin file system'lerde +//document object model - dom yapisi - ornek olarak html icin elementlerdeki yapilar, bu ayrica programlama dilleri icinde ayni olabilir, +//ag yuonlendirme- routing + +//kullanim alanlari +//oyunlarda +//json ve yaml'de kullanilir + diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/union/union.cpp" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/union/union.cpp" new file mode 100644 index 0000000..3d6df33 --- /dev/null +++ "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/union/union.cpp" @@ -0,0 +1,52 @@ +//birden fazla değiskeni tek bir yerden tanimlama imkani saglar +//union icinde ilgili alan olusturur ve en buyuk degiksenin alani kullanilir +//union icindeki degiskenler ortak kullanim alani olusturur. +//birden fazla alan ortak kullanilmaz, kullanmak icin overwrite kullan + +#include +#include + +//1 +union ogrenci +{ + char isim[20]; + int no; + float ort; +}; + +//2 +typedef union +{ + char isim[20]; + int yas; +}ogretmen; + + +int main() +{ + printf("Boyut %ld Byte \n",sizeof(union ogrenci)); + + //1 + union ogrenci o; + strcpy(o.isim, "Yucel"); + printf("Isim : %s\n",o.isim); + + o.no = 148; + printf("No : %d \n",o.no); + + printf("Isim : %s \n",o.isim); + + o.ort = 85.5; + printf("Ortalama : %f\n", o.ort); + + + //typedef ilen kullanim + ogretmen ogrt; + strcpy(ogrt.isim,"Ismail\n"); + printf("Ogretmen adi: %s\n",ogrt.isim); + + ogrt.yas = 45; + printf("Ogretmen yas : %d",ogrt.yas); + + return 1; +} diff --git "a/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/union/union.exe" "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/union/union.exe" new file mode 100644 index 0000000..fa72bc6 Binary files /dev/null and "b/Veri Yap\304\261lar\304\261 Ders Notlar\304\261/union/union.exe" differ