This file contains 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 Sort { | |
public static void sort(Integer[] array) { | |
quickSort(array, 0, array.length); | |
} | |
private static void quickSort(Integer[] array, int begin, int end) { | |
if (begin < end) { | |
int p = partition(array, begin, end); | |
quickSort(array, begin, p); | |
quickSort(array, p, end); |
This file contains 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 Array { | |
public static void sort(int[] array) { | |
quickSort(array, 0, array.length - 1); | |
} | |
private static void quickSort(int[] array, int begin, int end) { | |
if (begin < end) { | |
int p = partition(array, begin, end); | |
quickSort(array, begin, p - 1); | |
quickSort(array, p + 1, end); |
This file contains 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.io.File; | |
import java.io.FileWriter; | |
import java.io.IOException; | |
import java.util.Random; | |
public class InputGenerator { | |
public static void main(String[] args) throws IOException { | |
Random random = new Random(); |
This file contains 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.io.File; | |
import java.io.FileWriter; | |
import java.io.IOException; | |
import java.util.Arrays; | |
import java.util.Random; | |
public class InputGenerator { | |
public static void main(String[] args) throws IOException { | |
Random random = new Random(); |
This file contains 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; | |
public class ArrayListAlgorithm { | |
private static long iterations; | |
public static long sort(ArrayList<Integer> array) { | |
iterations = 0; | |
quickSort(array, 0, array.size() - 1); | |
return iterations; |
This file contains 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 ArrayAlgorithm { | |
private static long iterations; | |
public static long sort(int[] array) { | |
iterations = 0; | |
quickSort(array, 0, array.length - 1); | |
return iterations; | |
} |
This file contains 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
package datastructures; | |
import java.util.Comparator; | |
public class BinomailHeap<K extends Comparable> { | |
private Node<K> head; | |
private int size; | |
private Comparator<K> comparator; |
This file contains 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
""" | |
предполагаем что в последовательности нечётное число элементов для простоты | |
предполагаем что число элементов делится на 5 для простоты | |
""" | |
def pick_pivot(l): | |
""" | |
Выбираем хорошй pivot в списке чисел l | |
Этот алгоритм выполняется за время O(n). |
This file contains 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.LinkedList; | |
import java.util.List; | |
public class AbstractFactorySample { | |
public static void main(String[] args) { | |
String uname = System.getProperty("os.name").toLowerCase(); | |
Application application; | |
if (uname.contains("windows")) { |
This file contains 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
# encoding: utf-8 | |
# посчитать количество слов в предложении | |
# входные данные: str | |
# выходные данные: int | |
SPECIAL_CHARS = ['-'] | |
def is_alphabetic(char: str) -> bool: | |
return char.isalpha() or char in SPECIAL_CHARS |