This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Queue; | |
| import java.util.LinkedList; | |
| class Node{ | |
| int data; | |
| Node left, right; | |
| Node(int data){ | |
| this.data = data; | |
| this.left = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Deque; | |
| import java.util.ArrayDeque; | |
| public class Test{ | |
| public static void main(String[] args){ | |
| Deque<Integer> deque = new ArrayDeque<Integer>(); | |
| /* Adds element normally to the end of the list */ | |
| deque.add(1); | |
| deque.add(2); | |
| deque.add(3); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Queue; | |
| import java.util.LinkedList; | |
| class Node{ | |
| int data; | |
| Node left, right; | |
| Node(int data){ | |
| this.data = data; | |
| this.left = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RadixSort{ | |
| int RANGE = 9; | |
| public int getMax(int[] arr, int n){ | |
| int max = arr[0]; | |
| for(int i = 1; i < n; i++){ | |
| if(arr[i] > max){ | |
| max = arr[i]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| void quicksort(int arr[], int start, int stop){ | |
| if(start < stop){ | |
| int left = start; | |
| int right = stop; | |
| int pivot = arr[start]; | |
| while(arr[left] < pivot){ | |
| left += 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MinHeap{ | |
| int[] heap_array; | |
| int heap_size; | |
| int capacity = 100; | |
| MinHeap(){ | |
| heap_array = new int[capacity]; | |
| heap_size = 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class QuickSort{ | |
| public void quicksort(int[] arr, int start, int stop){ | |
| if(start < stop){ | |
| int left = start; | |
| int right = stop; | |
| int pivot = arr[start]; | |
| while(arr[left] < pivot){ | |
| left += 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #define RANGE 9 | |
| int getMax(int arr[], int n){ | |
| int max = arr[0]; | |
| for(int i = 1; i < n; i++){ | |
| if(arr[i] > max){ | |
| max = arr[i]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class InsertionSort{ | |
| public void insertionsort(int[] arr, int n){ | |
| int j, key; | |
| for(int i = 1; i < n; i++){ | |
| key = arr[i]; | |
| j = i-1; | |
| while(j >= 0 && key < arr[j]){ | |
| arr[j+1] = arr[j]; | |
| j -= 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SelectionSort{ | |
| public void selectionSort(int[] arr, int n){ | |
| int min_index; | |
| for(int i = 0; i < n-1; i++){ | |
| min_index = i; | |
| for(int j = 1+i; j < n; j++){ | |
| if(arr[j] < arr[min_index]){ | |
| min_index = j; | |
| } | |
| } |