Selasa, 18 Desember 2018

Function dan recursive

Recursive adalah proses pemanggilan dirinya sendiri (fungsi atau prosedur). Fungsi maupun prosedur yang memanggil dirinya disebut fungsi atau prosedur rekursif. Fungsi antuk suatu bagian program yang mengembalikan (menghasilkan) hanya satu nilai. Sebuah function call adalah suatu ekspresi jadi ia memberikan satu nilai.Procedure adalah suatu bagian program yang melakukan aksi/fungsi khusus, biasanya berdasarkan sekumpulan parameter. Sebuah procedure call adalah suatu statemen, jadi ia melakukan aksi. Banyak obyek dalam matematika didefinisikan dengan menampilkan suatu proses untuk  menghasilkan obyek-obyek tsb.


F        Function dan Recursive:
-Modular Programming
-Function
-Identifier Scoping
-Passing Parameter
-Recursion Definition
-Recursive Function
-Iterative vs. Recursive
 
CONTOH FUNCTION SEDERHANA:
#include<stdio.h>
void tambah(){
sum=0;
scanf("%d",&input);
sum=sum+input; 
printf("%d",sum)
}
int main(){
tambah();
return 0;
}

Structure

Structure is a data type to store group of data with various of data type
Structure component called member/field/element.
Heterogeneous (various element data type)
Structure in other programming language also called record
Contoh struct simpel untuk mahasiswa:
struck mahasiswa {
        char nim[11];
        char nama[25];
        int usia;
        int semester;
};

 

File Processing

       Text file saved in a text format or ASCII File:
      –Storage size depends on its data: 10000 needs 5 byte
      –Can be open using standard text editor application
      –or c:>TYPE file_name
       A binary file is a file whose content must be interpreted by a program or a hardware processor that       
       understands in advance exactly how it is formatted. That is, the file is not in any externally 
       identifiable format so that any program that wanted to could look for certain data at a certain 
p     place within the file. A progam (or hardware processor) has to know exactly how the data inside the 
       file is laid out to make use of the file.
       Possible mode value :
       Mode        Description
        “r”  opening a file to be read.
       “w”  creating a file to be written.
       “a”  opening a File for data append.
       “r+”  opening a File for read/write.  
       “w+”  creating file for read/write.
       “a+”  opening a File for read/append
      “rb”    opening a File (binary) to be read.
      “wb”  creating a file (binary) for write operation.


Sorting and Searching


-Sorting type:
Ascending
Descending
-Simple sort:
  Bubble sort
  Selection sort
  Insertion sort
-Intermediate sort: 
  Merge Sort
           –  Quick Sort


  Contoh bubble sort:
void Bubble(int *DataArr, int n)
{
    int i, j;
    for(i=1; i<n; i++)
    for(j=n-1; j>=i; j--)
    if(DataArr[j-1] > DataArr[j])
               Swap(&DataArr[j-1],&DataArr[j]);

}
Contoh selection sort :
for(i=0; i<N-1; i++){      /* N=number of data */
  Set idx_smallest equal to i
  for(j=i+1; j<N; j++){
  If array[ j ] < array [ idx_smallest ] then idx_smallest = j
    }
  Swap array[ i ] with array[ idx_smallest ]
}
Contoh insertion sort :
for(i=1; i<n; i++) {
     x = A[i], insert x to its suitable place between A[0] and A[i-1].
}
MERGE SORT 
Merge Sort is a sorting algorithm based on the divide-and-conquer algorithm
Divide-and-conquer is a general algorithm design paradigm
Divide: divide the input data in two disjoint subsets
Recur: solve the sub problems associated with subsets
Conquer: combine the solutions for each subset into a solution
SEARCHING 
Searching is an action to retrieve information based on particular key from some saved information
Key is used to do record searching which is desired from a set of data list
Key must be unique, means there must not be any same key in the data
Example:
  Student data consists of name, nim, gender, address, place and date of birth
  nim is used as key from the data, as it is unique.
 
Contoh quick sort :
void QuickSort(int left, int right)
{
      if(left < right){
            //arrange elements  R[left],...,R[right] that
            //producing new sequence:
            R[left],...,R[A-1] < R[A] and R[A+1],...,R[right] > R[A].
            QuickSort(left, A-1);
            QuickSort(A+1, right);
       }
}

Selasa, 11 Desember 2018

Best University in the world

Best University In The World*:

1.Lele University
2.Binus University
3.MIT
4.Harvard
5.Stanford



*syarat dan ketentuan berlaku

Rabu, 17 Oktober 2018

Selection And Repetition

1.SELECTION
Selection adalah metode sorting dimana elemen-elemen diperbandingkan satu persatu sampai pada elemen terakhir dan disusun berdasarkan ketentuan ketentuan berlaku

Jenis-jenis selection:
-IF
-IF THEN ELSE 
-SWITCH-CASE 

2.REPETITION
Repetition disebut juga sebagai perulangan atau looping berfungsi untuk melakukan perulangan eksekusi intruksi pada suatu baris kode sebanyak n kali atau selama kondisi tertentu.Jika kondisi tidak dipenuhi maka proses pengulangan akan dihentikan.

Jenis-jenis repetition :
-While
-Do-While
-For


Sebagai penutup berikut adalah looping sederhana untuk perkalian:

#include<stdio.h>
int main(){
 int a,b,c,i;
            printf("Masukkan looping inputan:",a);
            scanf("%d",&a);
             for(i=1;i<=a;i++){
             printf("Masukkan bilangan yang ingin dikali 2:",b);
             scanf("%d",&b);
             c=b*2;
             printf("Hasil bilangan yang dikali 2 adalah: %d\n\n",c);
}

 return 0;
}



2201796926
kevin.alexander002@binus.ac.id
skyconnectiva.com
Kevin Alexander