Tenth Lessons of Algorithm

Today, we reviewed all of the materials for quiz. We studied from the codes of a clothes shop. The source is from this blog.

Through the codes, we learned about struct. Struct is used to make a new data type, containing several data/variables.

We also learned about file processing, which includes read and write inside a file.

We learned to make “menu” and table by using function.

We also need to use switch-case for the menu.

We also learned to use sorting and searching.

Last but not least, we have to learn about the logic so that we could do the quiz.

Wish us luck. Cheers!

Ninth Lesson of Algorithm

Today we learn about sorting and searching algorithm. There are some sorting method algorithm which is divided into two, basic (simple) and intermediate.

Simple sorting method includes bubble sort, selection sort, and insertion sort. Simple sorting has a n^2 of complexity. So, simple sorting is not very effective for large amount of data.

Bubble sort works by comparing two index and move the one with smaller value to the front.

Selection sort works by comparing an index with all other indexes then get the smallest value from all other index then put it on the first index and so on.

Insertion sort works by putting the value of an index to a temporary variable then puts it into the right place, left or right side of the previous indexes.

Intermediate sorting method includes quick sort and merge sort. Intermediate sorting method is better for large amount of data because it has better complexity.

Quick sort uses four different variable to determine the right location for the value of the index then move it there.

Merge sort is based on divide-recur-conquer algorithm. Merge sort works by dividing the data into pairs, then makes the correct order of value by comparing each index on each pairs, then combine the pairs into bigger groups on the correct order and so on.

Searching methods includes linear search, binary search, and interpolation search.

Linear search works by comparing the data with the keyword we’re searching from the first index until the last index. Linear search is not very effective for large amount of data, but can still be used for unsorted data.

Binary search only works if the data is sorted. Binary search works by comparing the middle point of the data ((left + right)/2), then moves the left or right point to produce a new middle point based on the comparison of the middle point’s value and the search keyword. Then repeat the process until the middle point value is the same as the search keyword or until the left point exceed the right point (left > right).

Interpolation search works like binary search but uses different equation for producing the middle point.

Eighth Lesson of Algorithm

Today we learn about File Processing.

File consists of Record (baris) and Field (kolom).

There are also two different measurement of file: Byte and bit. 1 Byte = 8 bit.

File in C programming language can be made into text file (.txt) or binary file (.dat)

Here are some syntax we learn today:

FILE = to create a pointer that assign the file

fscanf = to read the file

fprintf = to print something to the file

fclose = to close the opened file

fopen = to open the file

Seventh Lesson of Algorithm

Today, we learned about function and recursion. Function actually consist of built-in function or library function and user defined function or function that was made by the programmer.

Program is actually made of several modules. These modules can be implemented to functions. So, function is a group of statements to do a specific job. The advantages of using modules are easier to debug, easier to be modified, and can be done by several programmers.

Function syntax:

return_value_type  function_name(parameter)

{

statements;

return_value;

}

return_value_type is the data type of the returned value. If there are no value returned then use “void” data type.

parameter is the value sent to the function by user. Parameter is optional.

Function is written above the main program.

 

Recursion is a function that calls itself and repeats itself until there is a value achieved. Recursion is consist of base case,which contains a constant value, and reduction step which is a sequence of the repetition. For example recursion of factorial. However, recursion is not very effective and uses a lot of time and memory. So, it is only recommended to use recursion when it is to hard to make the iteration.

 

Today, we also learned about encryption and web security from the CEO of Dewaweb.com, Edy Budiman. We also learned about SSL certificate and how important it is to be aware of the internet’s security. That’s all for today. Thanks.

Sixth Lesson of Algorithm

This time we have a small review before the quiz.

Programming is basically the process to make input become output. This can be done with several ways like selection, repetition, and storage.

In selection, we use if condition, if-else condition including nested if, and switch-case. In repetition, we use for, while, and do-while.

After that, we also do some practice like making square and diamond shape using C language.