#include <iostream>
Using namespace std;
Void bubbleSort(int arr[], int size) {
For (int I = 0; I < size – 1; ++i) {
For (int j = 0; j < size – I – 1; ++j) {
If (arr[j] > arr[j + 1]) {
Swap(arr[j], arr[j + 1]);
Int main() {
Int arr[] = {64, 34, 25, 12, 22, 11, 90};
Int size = sizeof(arr) / sizeof(arr[0]);
bubbleSort(arr, size);
cout << “Sorted array: “;
for (int I = 0; I < size; ++i) {
cout << arr[i] << “ “;
Return 0;
public class BubbleSort {
public static void bubbleSort(int arr[]) {
int n = [Link];
for (int i = 0; i < n - 1; ++i) {
for (int j = 0; j < n - i - 1; ++j) {
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
public static void main(String args[]) {
int arr[] = {64, 34, 25, 12, 22, 11, 90};
int n = [Link];
bubbleSort(arr);
[Link]("Sorted array: ");
for (int i = 0; i < n; ++i) {
[Link](arr[i] + " ");
#include <iostream>
Using namespace std;
Int binarySearch(int arr[], int size, int target) {
Int left = 0, right = size – 1;
While (left <= right) {
Int mid = left + (right – left) / 2;
If (arr[mid] == target) {
Return mid;
If (arr[mid] < target) {
Left = mid + 1;
} else {
Right = mid – 1;
Return -1; // Target not found
Int main() {
Int arr[] = {11, 12, 22, 25, 34, 64, 90};
Int size = sizeof(arr) / sizeof(arr[0]);
Int target = 34;
Int index = binarySearch(arr, size, target);
If (index != -1) {
Cout << “Element found at index “ << index;
} else {
Cout << “Element not found”;
Return 0;
public class BinarySearch {
public static int binarySearch(int arr[], int target) {
int left = 0, right = [Link] - 1;
while (left <= right) {
int mid = left + (right - left) / 2;
if (arr[mid] == target) {
return mid;
if (arr[mid] < target) {
left = mid + 1;
} else {
right = mid - 1;
return -1; // Target not found
public static void main(String args[]) {
int arr[] = {11, 12, 22, 25, 34, 64, 90};
int target = 34;
int index = binarySearch(arr, target);
if (index != -1) {
[Link]("Element found at index " + index);
} else {
[Link]("Element not found");
}
Public class SequentialSearch {
Public static int sequentialSearch(int arr[], int target) {
For (int I = 0; I < [Link]; ++i) {
If (arr[i] == target) {
Return I;
Return -1; // Target not found
Public static void main(String args[]) {
Int arr[] = {11, 12, 22, 25, 34, 64, 90};
Int target = 34;
Int index = sequentialSearch(arr, target);
If (index != -1) {
[Link](“Element found at index “ + index);
} else {
[Link](“Element not found”);