BUBBLE SORTING
Sorting In Arrays
Sorting Operation
Sorting is the process of arranging a list of elements in a particular order (Ascending or Descending). Sorting is used to arrange data, and sometimes could be used to reduce complexity of other algorithms.
Terminologies
Internal/External Sorting
In internal sorting all the data to sort is stored in memory all the time while sorting is in progress.
In external sorting data is stored outside memory (like on disk) and only loaded into memory in small chunks. External sorting is usually applied in cases when data can't fit into memory entirely.
Stability of Sort
A sorting algorithm is said to be stable if two objects with equal keys appear in the same order in the sorted output as they appear in the unsorted input.
A sorting algorithm is said to be unstable if there are two or more objects with equal keys which donβt appear in same order before and after sorting.
1. Bubble Sort
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order. The pass through the list is repeated until the list is sorted.
Average Time Complexity: O(n ^ 2)
Worst Time Complexity: O(n ^ 2)
Space Complexity: O(1)
Stability: Stable
Sorting In Arrays
Sorting Operation
Sorting is the process of arranging a list of elements in a particular order (Ascending or Descending). Sorting is used to arrange data, and sometimes could be used to reduce complexity of other algorithms.
Terminologies
Internal/External Sorting
In internal sorting all the data to sort is stored in memory all the time while sorting is in progress.
In external sorting data is stored outside memory (like on disk) and only loaded into memory in small chunks. External sorting is usually applied in cases when data can't fit into memory entirely.
Stability of Sort
A sorting algorithm is said to be stable if two objects with equal keys appear in the same order in the sorted output as they appear in the unsorted input.
A sorting algorithm is said to be unstable if there are two or more objects with equal keys which donβt appear in same order before and after sorting.
1. Bubble Sort
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order. The pass through the list is repeated until the list is sorted.
Average Time Complexity: O(n ^ 2)
Worst Time Complexity: O(n ^ 2)
Space Complexity: O(1)
Stability: Stable
π1
int main()
{
int a[20],n,i,j,temp;
printf("Enter the number of elements: ");
scanf("%d",&n);
printf("Enter the elements: ");
for(i=0;i<n;++i)
scanf("%d",&a[i]);
for (i = 1; i < n; i++)
for (j = 0; j < (n - i); j++)
if (a[j] > a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
printf("\nArray after sorting: ");
for(i=0;i<n;++i)
printf("%d ",a[i]);
return 0;
}
{
int a[20],n,i,j,temp;
printf("Enter the number of elements: ");
scanf("%d",&n);
printf("Enter the elements: ");
for(i=0;i<n;++i)
scanf("%d",&a[i]);
for (i = 1; i < n; i++)
for (j = 0; j < (n - i); j++)
if (a[j] > a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
printf("\nArray after sorting: ");
for(i=0;i<n;++i)
printf("%d ",a[i]);
return 0;
}
Comparison Sorting Visualization
https://www.cs.usfca.edu/~galles/visualization/ComparisonSort.html
https://www.cs.usfca.edu/~galles/visualization/ComparisonSort.html
Java Hyd Team
TODAY IS DRIVE SO COME TO INSTITUTE
Not 100% sure about drive π
Forwarded from Aman Raj
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class Billions {
public class PrintBillionNumbers {
public static void main(String[] args) {
List<Integer> list = IntStream.rangeClosed(1, 1000000000).boxed().collect(Collectors.toList());
list.forEach(System.out::println);
}
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class Billions {
public class PrintBillionNumbers {
public static void main(String[] args) {
List<Integer> list = IntStream.rangeClosed(1, 1000000000).boxed().collect(Collectors.toList());
list.forEach(System.out::println);
}
MERN STACK
M= MONGODB is database
E= EXPRESS-JS is framework
R= REACT-JS is frontend
N= NODE-JS is backend
node-js depending on express-js
express-js used to develop rest api
express-js used to do (get, post , put, delete)requests
STEP1- react-js sends request to node-js
STEP2- node-js sends request ri mongodb
STEP3- mongodb sends back request to nodejs
STEP4- node-js sends back request to react-js
M= MONGODB is database
E= EXPRESS-JS is framework
R= REACT-JS is frontend
N= NODE-JS is backend
node-js depending on express-js
express-js used to develop rest api
express-js used to do (get, post , put, delete)requests
STEP1- react-js sends request to node-js
STEP2- node-js sends request ri mongodb
STEP3- mongodb sends back request to nodejs
STEP4- node-js sends back request to react-js
mongodb:-
it is NoSQL database
it supports JSON
it is light-weight database
it follows the mongoDB protocol
it bydefault running on Port no.27017
it is NoSQL database
it supports JSON
it is light-weight database
it follows the mongoDB protocol
it bydefault running on Port no.27017