Tuesday, December 18, 2018

Sorting & Searching

Sorting & Searching 

By: Bismo Asyura Widianto
NIM: 2201785595

Searching Algorithms are crucial parts of any program. They often look for a record or entry in a database. However, there are algorithms that goes through virtual space to look for possible chess moves. Although there are a number of algorithms a programmer can use, they tend to select the the one that best matches the size and structure of the database to give the most user-friendly experience. 

Linear Search 
This type of algorithm is the preferred choice for short lists because of its simplicity and minimalist code implementation.  This algorithm looks at the first list of item to see whether you are searching for it. If the algorithm does not find it in the first index, it will then continue to the next item of data. This process is repeated until an item is found. When using this search, we do not need to arrange the data in order. 
Image result for Linear Search pseudocode in c

Binary Search
Binary Search is a fundamental and useful algorithm in Computer Science. It is very popular in large databases with records ordered by their numerical key. 


The algorithm starts at the middle of the database. Then, if the target value is greater than the middle value of the database, the search will continue from the upper-half of the database because the rest of the data is not relevant to our target. If the target value is lower than the middle value of the database, it will continue to search only the values the lower-half of the database. This process is repeated until the target is found. This type of search is more complicated but is much more efficient when dealing with large databases. 

Image result for Linear Search pseudocode in c
Main sections of a binary search:
  1. Pre-Processing
    1. Before searching, we need to sort the collection into order.
  2. Binary Search
    1. Here, we use a loop to divide the search space in half after each comparison of a d
  3. Post Processing
    1. Finally, we determine possible values in the remaining space.

Sorting Algorithms Includes ordering a list of data or information into a certain order that we want. For example, we would want a telephone directory to start according to the alphabet from a to z. There are a number of ways we can sort a data however, the most popular way to sort is through bubble sorting and insertion sorting. 


Bubble Sort
Bubble sort algorithm starts by comparing the first two elements of an array and swapping if necessary, i.e., if you want to sort the elements of array in ascending order and if the first element is greater than second then, you need to swap the elements but, if the first element is smaller than second, you mustn’t swap the element. To sum up, we perform  basic operation such as  interchanging a larger element with a smaller one following it, starting at the beginning of the list, for a full pass to do a bubble sort correctly.
Image result for Bubble sort pseudocode in c

Insertion Sort
This type of sorting is relatively simple because it builds the final sorted array one item at a time. Therefore it is easy to understand and do but will take a very long time if a large list is presented to the algorithm. Furthermore, if elements are sorted in reverse, it will take a longer amount of time because 

Firstly, the insertion sort begins with the second element and compares it with the first element and inserts it before the first element if it does not exceed the first element and after the first element if it exceeds the first element. At this point, the first two elements are in the correct order. This process is then repeated until it reaches the last element of the collection of data. 

Pseudo-code:




Tuesday, December 4, 2018

Cloud Computing & Security Algorithms


Cloud Computing
By: 
Name:   Bismo Asyura Widianto 
NIM:     2201785595
Class:    LK01

Last week's lecture was about the importance of cloud computing in the 21st century. Today, we are running out of space to hold a physical server in a given company. Therefore, major corporations are starting to refer to cloud computing as the future of data processing and storage. There are many benefits to why we need to compute in the cloud. 

Benefits of Cloud Computing:
Reduced IT Cost
Migrating to a cloud computing system will significantly reduce the operation expense of the IT Department. Rather than buying expensive equipments and systems, we can reduce our cost by using cloud computing service providers such as PT. Mitra TeleInformatika Perkasa. 

Flexibility of Work Practices
This method of data processing and storage makes it easier for employees to work even away from the office. They are now able to work at home if and urgent task needs to be completed right away. 


Drawbacks of Cloud Computing:
Security:
Even with the constant security update of cloud service providers, storing data and important files on third-party services always brings its own risk. Using cloud-powered technologies means you need to provide your service provider access to your personal information. This might be troublesome for some because they might be concerned about the policy around the use of the their information. 

Downtime:
Because cloud service providers handle a large amount of customers each day, there will be time where you might not be able to access your data due the overload of information going through the system. Therefore, this can lead to a temporary suspension in a business. 

Cloud Algorithms:
Security Algorithms in a cloud computing system is very crucial because internet applications and networking sites are growing very fast. Therefore, we need to implement a number of cryptography algorithms to secure our customer's data.  On the other hand, strong user authentication is very needed to reduce unauthorized user access of data stored on the cloud. For that reason, we need to ensure the security of the customer's information which is being exchanged between the user and the cloud. 



























Wednesday, October 17, 2018

Program Control: Repetition


ALGORITHM & PROGRAMMING

Program Control: Repetition (Summary)

Nama    :Bismo Asyura Widianto
NIM      :2201785595
bismo.widianto@binus.ac.id

What is Repetition in C?
  • One or more instructions used to repeat for a certain amount of time
  • This instruction automatically repeats itself until .a condition is satisfied.
  • There are 3 of repetition/looping in C programming:
    • For
    • While
    • Do-While

Repetition: For

-Syntax:

    for([initial]  ;  [condition]  ;  [increment or decrement]);

initial and condition can consist of a few expressions separated by a comma.

-Flowchart:

-Example:
(program to print out numbers from 0-100
*************************
#include <stdio.h>   
int main()                 
{                               
int x;                         
for(x=0;x<=100;x++)
printf("%d",&x);     
return=0                   
}                               
*************************



Repetition:  While

-Syntax:

    while (exp)-->  Boolean expression (true or false,|1 or 0)
    {
    statement1;--> Will be executed while the expression is not equal to zero
    statement2;
    ..
    ..
    }


-Flowchart:

-Example:

*************************
#include <stdio.h>         
void main()                     
{                                     
int x=1;                           
while (x<=10                 
{printf ("%d\n",x); x++; }
}                                     
*************************

Repetition: Do-While

-Syntax:

do
{[statements];
}while (exp);--> expression will continue to execute while it is true and will only be done after                                       executing the statement mentioned previously 

-Flowchart
-Example:


*************************
int counter = 0                   
do {                                   
     printf("%d", counter);   
     ++counter;                     
     }                                     
while (counter<=0);           


*************************

Break vs Continue

Break:
  • Forcefully finish the loop




Continue:
  • Skip the previous statement inside a repetition and continue normally to the next loop