Saturday, 8 November 2014

Parallel Distributed Processing (PDP)

Assalam and Hi to everyone, today i would like to share about Parallel Distributed Processing(PDP)
so, the drawing picture will tell you some of information about the PDP. :) 

sourse :

Wednesday, 5 November 2014


Hye and Assalamualaikum. Today i am going to post about sorting
One of the sorting i will share here is insertion sort and buble sorting

insertion sort

-it is efficient for small number of data
-its is simple implementation and stable


for x=1 to n-1
 while i>=0 and A[i]>key
      A[i+1] = A[i]

bubble sorting

-bubble sorting is famous and frequently used.
-start comparing with first two array and swapping it.
-and same to others. it will continue swapping until it is arranged and sort

for i from x downto 1 {
for y from 1 to i-1{
       if (A[j]>A[j+1])

Bubble Sort 
Java vs Python

Last semester, we are taken subject data structure with Dr. Mokhairi. We are already learn how to run bubble sort in java by using NetBeans. Since, we are learn new language Python. Let's try running bubble sort in Python Shell and making a comparison. 

Run bubble sort in Java by enter number 43,21,12,80,3,2,35:

Run bubble sort in Python by enter number 43,21,12,80,3,2,35:

Output in Java:

Output in Pyhton:

From the result above we can see clearly the differences between Java and Python. Python is more simple than Java.But it execute the same output.

Tuesday, 4 November 2014

Berkeley Software Distribution

Assalamualaikum and Good Day to all. 

Berkeley Software Distribution (BSD) was a Unix operating system derivative developed and distributed by the Computer Systems Research Group (CSRG) of the University of California, Berkeley, from 1977 to 1995. Today the term "BSD" is often used non-specifically to refer to any of the BSD descendants which together form a branch of the family of Unix-like operating systems. Operating systems derived from the original BSD code remain actively developed and widely used.

The released year of BSD
1.     First Berkeley Software Distribution (1BSD), which was released on March 9, 1978.
2.     The Second Berkeley Software Distribution (2BSD), released in May, 1979.
3.     The Third Berkeley Software Distribution (3BSD), at the end of 1979.
4.     Fourth Berkeley Software Distribution (4BSD) was released in November 1980 and offered a number of enhancements over 3BSD.

What is PC-BSD?
PC-BSD® is a user friendly desktop Operating System based on FreeBSD.
Known widely for its stability and security in server environments, FreeBSD provides an excellent base on which to build a desktop operating system.
PC-BSD uses a host of popular open source window managers and uses a custom-tailored application installer that puts popular applications in easy reach of users.

Figure1 : The current stable version of the PC-BSD operating system.

A Beginner’s Guide to Big O Notation

Big O notation is used in Computer Science to describe the performance or complexity of an algorithm. Big O specifically describes the worst-case scenario, and can be used to describe the execution time required or the space used (e.g. in memory or on disk) by an algorithm.
Anyone who’s read Programming Pearls or any other Computer Science books and doesn’t have a grounding in Mathematics will have hit a wall when they reached chapters that mention O(N log N) or other seemingly crazy syntax. Hopefully this article will help you gain an understanding of the basics of Big O and Logarithms.
As a programmer first and a mathematician second (or maybe third or fourth) I found the best way to understand Big O thoroughly was to produce some examples in code. So, below are some common orders of growth along with descriptions and examples where possible.


O(1) describes an algorithm that will always execute in the same time (or space) regardless of the size of the input data set.
bool IsFirstElementNull(String[] strings)
 if(strings[0] == null)
  return true;
 return false;


O(N) describes an algorithm whose performance will grow linearly and in direct proportion to the size of the input data set. The example below also demonstrates how Big O favours the worst-case performance scenario; a matching string could be found during any iteration of the for loop and the function would return early, but Big O notation will always assume the upper limit where the algorithm will perform the maximum number of iterations.
bool ContainsValue(String[] strings, String value)
 for(int i = 0; i < strings.Length; i++)
  if(strings[i] == value)
   return true;
 return false;


O(N2) represents an algorithm whose performance is directly proportional to the square of the size of the input data set. This is common with algorithms that involve nested iterations over the data set. Deeper nested iterations will result in O(N3), O(N4) etc.
bool ContainsDuplicates(String[] strings)
 for(int i = 0; i < strings.Length; i++)
  for(int j = 0; j < strings.Length; j++)
   if(i == j) // Don't compare with self

   if(strings[i] == strings[j])
    return true;
 return false;


O(2N) denotes an algorithm whose growth will double with each additional element in the input data set. The execution time of an O(2N) function will quickly become very large.


Logarithms are slightly trickier to explain so I’ll use a common example:
Binary search is a technique used to search sorted data sets. It works by selecting the middle element of the data set, essentially the median, and compares it against a target value. If the values match it will return success. If the target value is higher than the value of the probe element it will take the upper half of the data set and perform the same operation against it. Likewise, if the target value is lower than the value of the probe element it will perform the operation against the lower half. It will continue to halve the data set with each iteration until the value has been found or until it can no longer split the data set.
This type of algorithm is described as O(log N). The iterative halving of data sets described in the binary search example produces a growth curve that peaks at the beginning and slowly flattens out as the size of the data sets increase e.g. an input data set containing 10 items takes one second to complete, a data set containing 100 items takes two seconds, and a data set containing 1000 items will take three seconds. Doubling the size of the input data set has little effect on its growth as after a single iteration of the algorithm the data set will be halved and therefore on a par with an input data set half the size. This makes algorithms like binary search extremely efficient when dealing with large data sets.

5 differences between BSD and Linux

There are many differences between Berkeley Software Distribution (BSD) and Linux.But here, i list 5 differences show as below:

The BSD license does not require that you make sure the next person who uses (or modifies your code) makes that code available.

Linux operating system is licensed under The GPL gives you the right to use the software any way you want, but you MUST ensure the source code is available to the next person who uses it (or your variation of it).

The BSD code is not "controlled" by any one user

Linux kernel is mostly controlled by Linus Torvalds (the creator of Linux),

the BSDs are much more similar to UNIX because they are, in fact, direct derivatives of traditional UNIX.

Linux, on the other hand, was a newly created OS loosely based on a UNIX derivative (Minix, to be exact).

Kernel vs OS
The BSD project maintains the entire operating system.

The Linux project focuses primarily on the kernel alone.

Upgrade your entire base system to the most recent release by issuing a single command. Or you can download the sources to whatever build you want, unpack them, and build them as you would any application.

upgrade a system by using the built-in package management system. The former updates only the base system; the latter will upgrade the entire installation.

Types of Sorting Algorithm and Example.

Bucket Sort

  • Suppose we need to sort an array of positive integers {3,11,2,9,1,5}. A bucket sort works as follows: create an array of size 11. Then, go through the input array and place integer 3 into a second array at index 3, integer 11 at index 11 and so on. We will end up with a sorted list in the second array.
  • We immediately see two drawbacks to this sorting algorithm. Firstly, we must know how to handle duplicates. Secondly, we must know the maximum value in the unsorted array. Thirdly, we must have enough memory - it may be impossible to declare an array large enough on some systems.
  • The first problem is solved by using linked lists, attached to each array index. All duplicates for that bucket will be stored in the list. Another possible solution is to have a counter. As an example let us sort 3, 2, 4, 2, 3, 5. We start with an array of 5 counters set to zero.

  0    1    2    3    4    5  
 0 0 0 0 0 0
  • Moving through the array we increment counters:
  0    1    2    3    4    5  
 0 0 2 2 1 1
  • Next,we simply read off the number of each occurrence: 2 2 3 3 4 5.

Bubble Sort

  • The algorithm works by comparing each item in the list with the item next to it, and swapping them if required. The algorithm will be repeats the process until it makes a pass all the way through the list without swapping any items.

void bubbleSort(int ar[])
for (int i = (ar.length - 1); i >= 0; i--)
{ for (int j = 1; j ≤ i; j++) {
int temp = ar[j-1];
if (ar[j-1] > ar[j]) { ar[j-1] = ar[j];
} } } }
ar[j] = temp;

  • Here is one step of the algorithm. The largest element - 7 - is bubbled to the top:

7, 5, 2, 4, 3, 9
5, 7, 2, 4, 3, 9
5, 2, 7, 4, 3, 9
5, 2, 4, 7, 3, 9
5, 2, 4, 3, 7, 9
5, 2, 4, 3, 7, 9

Selection Sort

  • The algorithm works by selecting the smallest unsorted item and then swapping it with the item in the next position to be filled.
  • The selection sort works as follows: you look through the entire array for the smallest element, once you find it you swap it (the smallest element) with the first element of the array. Then you look for the smallest element in the remaining array (an array without the first element) and swap it with the second element. Then you look for the smallest element in the remaining array (an array without first and second elements) and swap it with the third element, and so on. 
void selectionSort(int[] ar){
for (int i = 0; i ‹ ar.length-1; i++)
{ int min = i;
for (int j = i+1; j ‹ ar.length; j++)
if (ar[j] ‹ ar[min]) min = j; int temp = ar[i];
} }
ar[i] = ar[min];
ar[min] = temp;
29, 64, 73, 34, 20
20, 64, 73, 34, 29
20, 29, 7334, 64 
20, 29, 34, 7364 
20, 29, 34, 64, 73 

Insertion Sort

  • To sort ordered list of elements, we remove its entries one at a time and then insert each of them into a sorted part (initially empty):
void insertionSort(int[] ar)
for (int i=1; i ‹ ar.length; i++)
while (j > 0 && ar[j-1] > index)
int index = ar[i]; int j = i;
{ ar[j] = ar[j-1]; }
} }
ar[j] = index;
  • The color a sorted part in green, and an unsorted part in black. Here is an insertion sort step by step. We take an element from unsorted part and compare it with elements in sorted part, moving form right to left.
29, 20, 73, 34, 64 
29, 20, 73, 34, 64 
20, 29, 73, 34, 64 
20, 29, 73, 34, 64 
20, 29, 34, 73, 64 
20, 29, 34, 64, 73 

Merge sort

  • Merge-sort is based on the divide-and-conquer paradigm. It involves the following three steps:
    1. Divide the array into two (or more) subarrays
    2. Sort each subarray (Conquer)
    3. Merge them into one (in a smart way!)
Consider the following array of numbers
    27  10  12  25  34  16  15  31
    divide it into two parts
    27  10  12  25            34  16  15  31
    divide each part into two parts
    27  10            12  25            34  16            15  31
    divide each part into two parts
    27       10       12       25       34       16       15       31

    merge (cleverly-!) parts
    10  27            12  25            16  34            15  31
    merge parts
    10  12  25  27                 15  16  31  34
    merge parts into one
    10  12  15  16  25  27  31  34
How do we merge two sorted subarrays? We define three references at the front of each array.
We keep picking the smallest element and move it to a temporary array, incrementing the corresponding indices.