Bubble Algorithm Essay

966 Words2 Pages

Course: ALGORITHM.
Assignment#1.1
Q- Discuss the Complexity of Bubble Sort algorithm
COMPLEXITY OF BUBBLE_SORTS ALGORITHM:
If we talk about the complexity of Bubble sort.
Then for bubble sort our pseudo code is,
Procedure Bubble sort (a1, a2 . . . an)
This is an arithmetic series. for i=1 to n-1 for j=1 to n-1 if aj>aj+1 then interchange aj and aj+1
Let, we have the following list,
{ 1 –11 50 6 8 –1} Using Bubble Sort in increasing order
After first pass
{-11 1 6 8 –1 50} (In this step, we take 5 comparisons)
After Second Pass
{-11 1 6 -1 8 50} (In this step, we take 4 comparisons)
After Third Pass
{-11 1 -1 6 8 50} (In this step, we take 3 comparisons)
After Fourth Pass
{-11 -1 1 6 8 50} (In this step, we take 2 comparisons)
After Fifth Pass
{-11 -1 1 6 8 50} (In this step, we take 1 comparison)
Done

According to the above list, we have 6 elements and there are 5 + 4 + 3 + 2 + 1 comparisons.

In general, if we have list of n elements, we will have the following list,
(n-1) + (n-2) …. + 2 +1 = (n-1) n / 2 comparisons.
The complexity here based on quadratically(degree 2) in n.
For Best Case:
The time complexity of the best case scenario is O(n).
For Worst Case:
The time complexity of the best case scenario is O(n2).
Note:
The Bubble sort is not efficient, there are other sorting algorithms that are much faster.

Assignment#1.2:
Q- Discuss the Complexity of searching algorithms.
Complexity of Algorithms:
There are a lot of searching algorithms, from which Linear Search Algorithm is one of the simple and easy algorithm, but it also have complexity, which we discuss here,
Let we determine, if the number 3 is present in the following lists
A= { 1 4 8 -1 3}
B= ...

... middle of paper ...

...ent of Defense develops TCP/IP (Transmission Control Protocol/Internet Protocol).
• TCP/IP is standard communications protocol, widely used in communications between different WANS and LANs.
• Because its use is wide, it has Security problems, growing sharing of information passed over vulnerable communications lines.
1980s
• This Decade is of personal computers and workstations (machines for special purpose use).
• Personal computers got popularity in ease of use.
• Its Graphical user interfaces (GUI) is a key to success.
• Information sharing between different computers via networks became more efficient and practical
• Wide spread use of Client/server computing model.
• Clients request various services and servers perform requested services.
• Multiple threads of instructions that could execute independently.
• Greater consideration in programming languages.

Open Document