Topics
Operating System
- Basics of Operating System (OS)
- Basics of Operating System (OS)
- Windows NT
- Introduction to GNU/Linux (GNU Not Unix)
- File Systems and Its Types
- File Operations
- Access Methods in Operating System
- Allocation Methods
- Concepts Related to Process Management
- Concepts Related to Memory Management
- Ubuntu is One of the Most Popular GNU/Linux Distributions
- Access and Security Aspects of O.S.
Data Structures
C++ Programming
- Introduction to C++ Programming
- Idea Behind Object-Oriented Programming
- Object-Oriented Programming Approach
- Object-Oriented Terms and Concepts
- Classes and Objects
- Constructors and Destructors
- Functions in C + +
- Arrays in Data Structure
- Pointers in C++
- References in C++
- Strings in C++
- Inheritance
- Virtual Functions and Polymorphism
- Friends in C++
- Operator Overloading and Type Conversions
- Files and Stream
HyperTex Markup Language (HTML)
- Introduction to HyperText Markup Language (HTML)
- HTML Documentation
- Basics of HTML Tags
- Font Tags in HTML
- Lists in HTML
- Tables in HTML
- Images in HTML
- Links in HTML
- HTML Scripts
Sorting in Data Structure
Sorting : The process of arranging data or items in a specific order, typically in ascending or descending sequence
Bubble Sort : It is a comparison-based algorithm in which each pair of adjacent elements is compared, and the elements are swapped if they are in the wrong order. The largest elements "bubble up" to the end of the list with each pass.
Working of Bubble sort
-
Step 1: Perform n-1 comparisons. The largest element moves to the last position (A[n]).
-
Step 2: Perform n-2 comparisons. The second largest moves to A[n-1].
-
Step 3: Perform n-3 comparisons. The third largest moves to A[n-2].
-
Continue this process...
-
Step n-1: Compare A[1] and A[2]. Now the list is sorted in increasing order.
Algorithm of bubble sort
[Bubble Sort] BUBBLE [DATA, N]
Here DATA is an array with N elements. This algorithm sorts the elements in DATA.
1. Repeat steps 2 and 3 for K = 1 to N-1
2. Set PTR := 1 [?pass pointer PTR.]
3. Repeat while PTR <= N-K. [Executes pass.]
(a) IF DATA [PTR] > DATA [PTR + 1], then:
Interchange DATA [PTR] and DATA [PTR + 1]
[End of IF structure]
(b) Set PTR := PTR + 1
[End of inner loop]
[End of step 1 outer loop]
4. Exit
Complexity of algorithm
f (n) = (n-1) + (n-2) +...... + 2 + 1
= `(n(n - 1))/2`
= `n^2/2 + 0 (n)`
= 0 (n2)
The time required to execute the bubble sort algorithm is proportional to n2 where n is the number of input items.
