Binary Search
Binary Search
Output: -
Element found at index : 3
Bubble Sort
System.out.println("Unsorted array:");
printArray(arr); // Print the original array
System.out.println("Sorted array:");
printArray(arr); // Print the sorted array
}
}
Output:-
Unsorted array:
64 34 25 12 22 11 90
Sorted array:
11 12 22 25 34 64 90
Stack
class Stack {
private int maxSize; // Maximum size of the stack
private int[] stackArray; // Array to hold the stack elements
private int top; // Index of the top element
Output:
When you run the program, the output will be:
10 pushed to stack.
20 pushed to stack.
30 pushed to stack.
Stack elements: 30 20 10
30 popped from stack.
Stack elements: 20 10
40 pushed to stack.
50 pushed to stack.
Stack is full. Cannot push 60
Stack elements: 50 40 20 10