Data Stucture 9

Prim’s , Kruskal’s and Dijkstra Algorithm

Case::
1

Prim’s Algorithm :
1. Buat 1 Array (Ex: T)
2. Pilih Vertex Awal
3. Edge yg berhubungan dengan vertex akan di tandai Active
4. Bandingan nilai edge yg active lalu temukan  nilai terkecil dari semuanya
5. Tambahkan node dangan nilai edge active tekecil ke array
6. Lakukan step 3 – 5 sampai node T lebih kecil dari total yg ada

Solution::
1

Kruskal’s Algorithm::
1. Buat 1 Array( Ex: T)
2. Urutkan nilai edge dengan priority queue
3. Ambil nilai terkecil
4. Apaabila terjadi loop, lanjutkan ke edge berikut
5. Jika tidak, tambahkan Edge ke dalam array
6. Ulangi 3-5 sampai semua vertex di visit

Solution::
2

Dijkstra’s Algorithm::
1. Tunjuk 1 vertex awal
2. Deskripsikan N sbagai set kosong
3. Vertex awal di label 0, masukkan dalam N
4. Tiap vertex yang tidak di N dan terhubungan dengan vertex yg baru dimasukkan ke N di pertimbangkan
5. (a) jika vertex tidak ada di N diberikan label maka berilah label vertex yg baru di insert + nilai panjang edge
(b) Kalau tidak, Vetex di NN sudah ad labal berilah label baru dengan minimum label insert+panjang edge
6. Pilih Vertex yang tidak di N yang meiliki label terkecil
7. Ulangi Step 4-6.

Solution::
3

Data Structure 8

Heap , Hashing , & Tries

Heap
Heap ialah binary tree berstruktur data yg memiliki elemen:
1. Min Heap = Data terkecil dari Heap, Dimana Setiap elemen node lebih kecil daripada children.
2. Max Heap = Data terbesar dari Heap, dimana setiap Elemen Node lebih besar daripada children.

Heap Memiliki 2 metode:
1. Selection’s Algorithm
2. Djikstra’s Algorithm
3. Prim’s Algorithm

 

Insertion dalam Min-Max Heap
1. Kalau node parent lebih kecil, tukar uphead max dari parent
2. Kalau node parent lebih besar, tukar dgn uphead min dari parentnya.
3. Upheadmin adalah membandingkan nilai node yang sekarang dengan granparent jika lebih kecil lanjutkan upheadmin node grandparent
4. Upheadmax adalah membandingkan nilai node yang sekarang dengan grand parent dimana jika lebih besar maka di lanjutkan upheadmax node grandparent

Tries
Tries merupakan struktur data tree yang tersusun digunakan untuk menyetor array.
Contoh:

ex

Hashing
Hashing merupakan transformasi karakter string ke nilai yg lebih pendek. Ada hash table yang berntuh tabel array dimana data asli string tersimpan. Index dari hash tableh dinamakan Hashed key
Contoh: exx

Beberapa fungsi dari Hash:
1. Mid Square. Mengkotakkan string kemudia gunakan angka bit yg tepat untuk mendapatkan Hash key
2. Division. Membagi string menggunakan operator modulus.
3. Folding. Membagi rata string menjadi bagian bagian untuk mendapatkan hash key.

Data Structure 7

Red Black BST

Ciri – Ciri:
1. Setiap node memiliki 1 warna
2. Root selalu hitam
3. If node merah, anak selalu hitam

Insertion on Red Black BST
Node Insert selalu merah dan tidak boleh ada 2 merah
Contoh Jika uncle merah

1

Contoh Jika Uncle Hitam
2

 

Delete dalam Red Black BST
1. Jika double black node, rotasi sibling red
Ex:3
2. Jika double black dan sibling black, ganti jadi merah
Ex:4
3. Jika double black sibling black , anak black
Ex:5

2-3 Trees
Ciri – Ciri:
1. Setiap node 1 data
2. Kiri < Parent
3. Kanan > Parent
4. Nilai Tengah diantara 2 parent

Insertion
1. Apa bila leaf 2 node maka insert sehingga menjadi 3 node
2. Apa bila leaf 3 node , push middle diantara A dan B hingga split menjadi 2 node, repeat until node sisa 2

Balanced Binary Search Tree and AVL

Balanced Binary Search Tree
Binary yang balance dalam penataannya agar pengunaan memory lebih sedikit saat pengalokasian

AVL (Adelson-Veleski dan Landis)
Sebuah Metode untuk membalance sebuah BST1

Diatas adalah Contoh Balanced

2

Angka merah lebih dari 1 mendadakan diabukan lah AVL

Cara Merebalance AVL Tree
1. Case LL : T-left-left
2. Case RR : T-right-right
3. Case RL : T-right-left
4. Case LR : T-left-right

3

LL Rotation Example

4

RR Rotation Example

5
RL Rotation Example

 

Deletion on AVL Tree Operation
Example:
11121413

 

Keefektifan Data Struktur1111

Pertemuan 5 Data Structure

Binary Search Tree
1. Has2 child like binary tree
2. Left child < parent
3. Right child > parent
4. No same value in

Binary Search Tree Operation
1. Insert : Input a data to a tree, if the data inputted is bigger than the parent, it will be put in the right else , left
2. Delete : Deleting a data from tree with condition:
1.If the deleted data don’t have a child, immediately deleted.
2.If the deleted data has 1 child, the previous data will be connected to other child , then deleted
3.If the deleted data has 2 child, then either one of the child will change the position of the deleted data
3.Searching : Searching a data from a tree. Because Binary Search Tree put the small data in left and big in right, searching in Binary Search Tree is more efficient. If the data searched is bigger, then go to the right, else to the left.
If the data wasn’t found in left or right, then the search result in failure, this operation is done repeatedly until it found a result.

 

Pertemuan 4

Tree
Tree is formed by one or many nodes.

Part of Tree:
1. Degree, Level of a particular node on a tree
2. Height, the height of a tree
3. Parent, parent of a node.
4. Children, child of a node.
5. Sibling, node that come from a same parent.
6. Ancestor, nodes in top of node that connected by edges.
7. Descendant, nodes in the bottom of node that connected by edges.
8. Root, node in the most top of a tree.
9. Edge, a line that connect a node to another.
10. Leaf, node which dont have child.

 

Binary Tree
Binary Tree is a tree which its each node has child and max 2 child.

There are many types of Binary Tree
1. Perfect Binary Tree
A tree which each level has the same height
2. Complete Binary Tree
An almost perfect binary tree,
3. Skewed Binary Tree
a tree which each node has maximum of 1 child
4. Balance Binary Tree
a tree which each side (left and right) has the same nodes
Representing Binary Tree with Array
1. 0 index is the root
2. the left child index is 2p+1 while the right child index is 2p+2

Representing Binary Tree with Linked List
struct node {
int data;
struct node *left;
struct node *right;
struct node *parent;
};struct node *root = NULL;

 

Expression Tree Concept
1. Prefix
Output is coming from the top to bottom, left to right.
2. Infix
Output is coming from bottom left to the right and going to the root.
3. Postfix
Output is coming from bottom to top, left to right.

Linked List Implementation II

Stack
Stack is an important data structure which stores its elements  in an ordered manner

Analogy
You must have seen a stack of book. When you need to remove a bottom book, you first need to remove the topmost book. Thats how stack works.

Stack Concept1. Stack  is a linear data structure which can be used  by either using array or linked list
2. Element added and removed is called TOP

Array Representation
Stack has two variables
1. TOP is used to store the address of the topmost element of stack
2. MAX which use to store the maximum number that stack can hold

Stack Operations
1. push(x) = add an item x to the top of stack
2. pop() = remove an item from the top of stack
3. top() = reveal/ return the top item from the stack

There are several applications using stack data structure that we will discuss
1. Infix evaluation
2. Postfix evaluation
3. Prefix evaluation
4. Infix to Postfix conversion
5. Infix to Prefix conversion
6. Depth First Search

 

Prefix : operator is written before operands
Ex: *4 10  // +5 *3 4 // +4/*6 – 5 2 3
Infix : operator is written between operands
Ex: 4 * 10 // 5 + 3 * 4 // 4 + 6 * (5 – 2) / 3
Postfix : operator is written after operands
Ex: 4 10* // 5 3 4* + // 4 6 5 2 – *3/ +1

Depth First Search = A searching method used by data structure to search data start from the bottom, used in stack.

Breadth First Search = A searching method used by data structure to search data start from the side, this operation is used in Queue.

Data Structure Pertemuan 2

Pertemuan kedua kami diisi dengan kehadiran Bapak Bong Defendy. Beliau adalah alumni Binus. Beliau memiliki pengalaman – pengalaman dalam bidang TI dan start up.

Dalam pertemuan kami dengan Bapak Bong Defendy, Beliau memberitahukan beberapa hal sebagai berikut ini:

1. Big Data
Big data adalah sebuah kumpulan kumpulan data yang memiliki ukuran yang sangat besar sehingga kadang kalanya tidak terstruktur dengan baik.
Salah satu contoh penerapan Big Data dapat kita lihat dari perusahaan Google yang mengumpulkan informasi user dan memberikan user hal hal sesuai dengan kebutuhan mereka

2. Cloud
Cloud adalah semacam penyimpanan(storage) dari data data yang kita miliki di suatu daerah yang bukan milik kita. Cloud berfungsi untuk menyimpan data data yang kita miliki tanpa menggunakan memory kita untuk menyimpan data data tersebut

3. Augmented Reality
Pak Bong Defendy juga menjelaskan bahwa di jaman teknologi ini adanya augmented reality dimana kita bisa melihat sebuah benda secara fisik hanya melalui bantuan lembaran kertas dan smartphone.
Saat ini penggunaan Augmented Reality masilah sebatas membantu dalam membangun bangunan, kedepan kalanya mungkin akan lebih berguna lagi

4. Internet of Things
Menyatakan bahwa kita bisa mengatur segala sesuatu melalui internet misalnya berperantara smartphone. Menurut Pak Bong Defendy, komponen terpenting dalam hal ini adalah sensor, tapi logika juga d perlukan. Apa saja yang dapat dilakukan oleh internet of things ini?
Kita dapat mengakses segala perlengkapan yang ada di dalam rumah kita hanya melalui beberapa tombol di smartphone, ini tentunya akan merevolusionisasi teknologi teknologi yang ada di dunia.

 

Data Structure Rangkuman Pertemuan 1 & 2

Nama : William Wijaya
Nim    : 1901475841

Session 1

Array
1. Collection of Similar data Elements
2. Has same data type
3. Referenced by an Index
4. Index start from Zero

Array Type
1. One Dimensional Array (Ex : array[10])
2. Multi Dimensional Array (Ex : array[100][10][20])

3 Ways to Store Values in Array
1. Initialize the Elements
(Ex : int arr[2] ={1,2,3})
2. Input Values
(Ex : int i,int number[10]
for(i = 0;i<10;i++)
scanf(“%d”,&number[i];)
3. Assigning Values
(Ex : int i,int number[10],int number2[10]
for(i = 0;i<10;i++)
number[i]=number2[i];)

List of Operation available for Array
1. Traversal
2. Insertion3. Searching
4. Deletion
5. Merging
6. Sorting

 

Pointer
Pointer is a data type whose value refer to another value stored elsewhere in computer using its address

Important operator for pointer >>> &(address operator) and *(dereferencing operator)

For Example:
if we have

int x;
int *px; then x act as integer and px act as pointer to integer

 

Data Structure
Data Structure is an arrangement of data,either in computer storage or in the disk storage

Common example for Data Structure
1. Array
2. Linked List3. Queues
4. Stack
5. Binary Tree
6. Hash Tables

Array
1. Collection of similar data elements
2. Data elements have  the  same data type

Linked List
1. A very dynamic data structure in which the elements can be added to  or deleted from anywhere at will2. Each elements is called a node

Queue
1. The elements that was inserted at first is the first one to be taken out
2. The elements in a queue are added on end called rear and removed from front

Stacks
1. Linear Array
2. Every stack has a TOP
3. LIFO/FILO(Last in First Out/ First in Last Out)

Binary Trees
1. A Data Structure which is defined by collection nodes2. Every node contains a left pointer, right pointer and data element

Session 2

Structure
basically a user defined data that can store different data type

Example:

struct data{
int age;
char name[100];
};

where data act as structure name , age and name act as structure member

Creating a variable of structure is similar to create a variable of primitive data type (Ex : data x; datax[100])

You can use operator . (dot) to access member of x
(Ex : x.age;x.name)

You can also use array on struct
(Ex : data x[100];
x[0].age;
x[1].age;
etc.

 

Memory Allocation : Dynamic
If you need to allocate memory dynamically (in runtime), you can
use malloc in C/C++. To de-allocate you can use free.

Linked List
Is a data structure that consist of a sequence  of data  records such that  each record there  is a field that contains a reference  to the next record sequence

Linked List Vs Array

Array
1. Linear Collection of data elements
2. Store value in consecutive memory locations
3. can be random in accesing data

Linked List1. Linear Collection of nodes
2. Doesnt store its nodes in consecutive memory locations
3. can be accessed only in a sequential manner.

Blog Assignment


General Orientation


General Orientation is the very first activity I got in here , Binus University. At the very first day of the General Orientation, I was really nervous, why? Because this is my first time in another country meeting people who I don’t know about. So of course I was being nervous.

But at the General Orientation I met my upperclassmen who take part as buddy coordinator at this university. They were a group of people who gave us information about how and what we should do in this university. They told us about many thing from attending classes and how to take part in mid term and final term exam. And also thanks to our buddy coordinator who is friendly and make us play some games in group, I was able to make some new friends at my General Orientation. Finally and the end of the General Orientation, we had an activity which each batch present their own yell, which I found very amusing. Why? Each batch present their funny yet unique type of yell and dance. The General Orientation was a great experience!


Academic Orientation


Academic Orientation is the phase where we try to adapt to campus life by going to classes and interacting with the lecturer who gave us material of what we were going to learn this year.

The Academic Orientation was actually fun and menacing. The fun part was , I finally learn something new in the university which I, myself fond of the material. While the menacing part is that the university life finally start and here I am wondering how am I going to pass this whole year nice and clean. By the end of the Academic Orientation, we have a small exam which is the AO Exam, which the material is everything we learn during the AO, but unfortunately I was only able to answer 3 out of 5 questions L. But nevertheless, I will study hard to succeed this year!!!!!


HTTP


 

HTTP – Himti Togetherness and Top Performance. An activity held by the HIMTI to welcome the new Student of Computer Science.

In this Event there are many thing held by them. Such as , Band from the SoCS itself, talkshow by sir Laksamana, Visualization , and last but not least the DJ party. I made many new friends at this event, which if probably the main point of entering this event. And at the really end of the event they held a lucky draw but unfortunately I did not win any of the prize which is kinda sad -_-. But overall it’s a really enjoyable event! Thanks HIMTI for the HTTP event XD!


Organizational Skills


 

I joined an organization named BNCC – Bina Nusantara Computer Club. I have just joined recently and on our first meeting, Sir Matius was delivering us a speech about his career journey. He told us how to become a successful person by doing your best. He is one of the good speaker. There are also many organizational skills that I am going to earn here in BNCC. I am looking forward to our next meeting at BNCC! 😀