Skip to main content

Posts

Showing posts from April, 2020

AVL Tree

Pertemuan ke-(?),  AVL Tree  Materi : - Konsep AVL TREE - Konsep-konsep Search, Insertion dan Deletion AVL TREE AVL Tree adalah sebuah "Binary Search Tree tahap berikut", dengan kata lain, AVL Tree adalah pematangan  dari konsep Binary Search Tree. AVL Tree dalam penempatan datanya akan terlihat persis sama seperti Binary Tree, namun pada saat penempatan data, AVL Tree melakukan langkah merapikan pohon, yang tidak dilakukan pada Binary Tree, sehingga data lebih efisien di AVL Tree. AVL Tree memiliki perbedaan tinggi maksimal 1 antara subtree kiri dan subtree kanan, bila perbedaan tinggi melewati 1, artinya sudah tidak seimbang dan akan dilakukan penyeimbangan. Hal ini dilakukan untuk mencegah sebuah situasi yang tidak baik yang bisa terjadi pada Binary Tree yaitu Skewed Tree.   AVL TREE : INSERTION Insertion pada AVL Tree sama seperti Binary Tree (Apabila lebih besar ke kanan, lebih kecil ke kiri) kecuali A...
//RAND()SUPERMARKET #include<stdio.h> #include<string.h> #include<stdlib.h> #include<time.h> #include<conio.h> #include<windows.h> void clear(){ system("cls"); } void delay(int second){ int milsec = 1000 * second; clock_t startTime = clock(); while(clock() < (startTime + milsec)); } struct item{ char name[31]; int qty; int price; struct item *next,*prev; }*head,*tail,*curr,*curr2; struct item *news(char name[],int qty){ struct item *temp=(struct item*)malloc(sizeof(struct item)); temp->qty=qty; temp->price=rand()%100000+1; strcpy(temp->name,name); return temp; } int countlist(){ curr=head; int flag=0; while(curr!=NULL){ flag++; curr=curr->next; } return flag; } void drop(int x){ if(x<=countlist()){ if(head==tail){ head=tail=curr=NULL; } else if(x==1){ curr=head->next; free(head); head=curr; head->prev=NULL; } else if(...

HALF SEMESTER SUMMARY

Data Structures Summary Dear reader, due to the recent outbreak of the COVID-19 pandemic, we've all been forced to study at home. It is a challenge to keep track of the subject matter, so in this blog, I will be putting all my summary about what I've learned in this half semester from Data Structures. I've been thinking about the final project of making a pacman game using linked list... I can make a pacman game with 2d arrays, but a Linked List as a map ? It still leaves me in confusion ... For now I'll be studying more too be closer on approaching the final project Linked List II,  a linear data structure where each element is a separate object. Materials : - Circular Linked List - Circular Single Linked List - Doubly Linked List - Circular Doubly Linked List Circular Linked List Circular Single Linked List is a variation of linked list which its first element points to the last element and the last element points to the first element. In this list, there is...