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
| public class RadixSort { | |
| public static void radixSort(int[] arr) { | |
| if (arr.length == 0) { | |
| return; | |
| } | |
| // Find the maximum number to know number of digits | |
| int max = getMax(arr); |
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.ArrayList; | |
| import java.util.Collections; | |
| public class BucketSort { | |
| public static void bucketSort(int[] arr) { | |
| if (arr.length == 0) { | |
| return; | |
| } |
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
| public class HeapSort { | |
| public static void heapSort(int[] arr) { | |
| int n = arr.length; | |
| // Build max heap (rearrange array) | |
| for (int i = n / 2 - 1; i >= 0; i--) { | |
| heapify(arr, n, 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
| public class BubbleSort { | |
| public static void bubbleSort(int[] arr) { | |
| int n = arr.length; | |
| boolean swapped; | |
| for (int i = 0; i < n - 1; i++) { | |
| swapped = false; | |
| for (int j = 0; j < n - i - 1; j++) { |
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
| // https://www.youtube.com/watch?v=WYrMGRJ9qFE | |
| public class MergeSort { | |
| // Gộp 2 mảng con đã được sắp xếp | |
| public static void merge(int[] arr, int left, int mid, int right) { | |
| // tính kích thước 2 mảng con | |
| int n1 = mid - left + 1; // Array trái | |
| int n2 = right - mid; // Array phải | |
| // Tạo mảng tạm |
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
| public class MergeSort { | |
| // Gộp 2 mảng con đã được sắp xếp | |
| public static void merge(int[] arr, int left, int mid, int right) { | |
| // tính kích thước 2 mảng con | |
| int n1 = mid - left + 1; // Array trái | |
| int n2 = right - mid; // Array phải | |
| // Tạo mảng tạm | |
| int[] L = new int[n1]; | |
| int[] R = new int[n2]; |
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
| // https://www.youtube.com/watch?v=uf_DyA_Ku7A | |
| public class QuickSort { | |
| // Helper method để hoán đổi hai phần tử | |
| private static void swap(int[] arr, int i, int j) { | |
| int temp = arr[i]; | |
| arr[i] = arr[j]; | |
| arr[j] = temp; | |
| } |
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
| public class InsertionSort { | |
| private static int[] insertionSort(int[] arr) { | |
| int n = arr.length; | |
| for (int i = 1; i < n; i++) { | |
| int key = arr[i]; | |
| int j = i - 1; | |
| while (j >= 0 && arr[j] > key) { | |
| arr[j + 1] = arr[j]; | |
| j--; |
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
| public class SelectionSort{ | |
| public static int[] selectionSort(int[] arr) { | |
| int n = arr.length; | |
| for (int i = 0; i < n - 1; i++) { | |
| int minIndex = i; | |
| for (int j = i + 1; j < n; j++) { | |
| if (arr[j] < arr[minIndex]) { | |
| minIndex = j; | |
| } |
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
| // Comprehensive malware analysis script | |
| const fs = require('fs'); | |
| console.log('=== VIRUS.JS MALWARE ANALYSIS ===\n'); | |
| // Read the file | |
| const code = fs.readFileSync('virus.js', 'utf8'); | |
| // Analysis results | |
| const analysis = { |
NewerOlder