COO
CEO
Prateek Narang
Instructor
Prateek Narang
Instructor
Naman Bhalla Instructor
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.
#include <bits/stdc++.h>
using namespace std;
void swap(int *xp, int *yp)
{
int temp = *xp;
*xp = *yp;
*yp = temp;
}
// A function to implement bubble sort
void bubbleSort(int arr[], int n)
{
int i, j;
for (i = 0; i < n-1; i++)
// Last i elements are already in place
for (j = 0; j < n-i-1; j++)
if (arr[j] > arr[j+1])
swap(&arr[j], &arr[j+1]);
}
/* Function to print an array */
void printArray(int arr[], int size)
{
int i;
for (i = 0; i < size; i++)
cout << arr[i] << " ";
cout << endl;
}
// Driver code
int main()
{
int arr[] = {64, 34, 25, 12, 22, 11, 90};
int n = sizeof(arr)/sizeof(arr[0]);
bubbleSort(arr, n);
cout<<"Sorted array: \n";
printArray(arr, n);
return 0;
}
// This slide uses Auto-Animate to animate between
// two different code blocks
const distanceBetween = ( p1, p2 ) => {
// TODO
}
distanceBetween([10,10], [50,50])
// Measure the distance between two points
const distanceBetween = ( p1, p2 ) => {
const dx = p1[0]-p2[0];
const dy = p1[1]-p2[1];
return Math.sqrt( dx*dx + dy*dy );
}
distanceBetween([10,10], [50,50])
Given an array of size N, reverse the array.
Sample Input
N = 5
arr[] = {1,2,3,4,5}
Sample Output
5,4,3,2,1
Build
During the ideation phase, expect to discuss the project in depth to clearly understand the goals and requirements.
Compile
During the ideation phase, expect to discuss the project in depth to clearly understand the goals and requirements.
Execute
During the ideation phase, expect to discuss the project in depth to clearly understand the goals and requirements.
With built-in \( \LaTeX \) typesetting, you can include math formulas like this:
Our design team has a collective 75 years of experience in crafting digital products.
Our diverse backgrounds offer a thorough mix of points of view.
C++
Java
Python