Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[3.139.72.78] |
|
Сообщ.
#1
,
|
|
|
Задачи на Алгоритмы. Решение. Покритикуйте
Цитата Problem 1. Given array a of N elements transpose it as follows {a[N-1], a[N-2],…, a[0]} Memory consumption (not including the space for array) – O(1) Running time – O(N) Problem 2. Given sorted arrays a of n elements and b of m elements produce sorted array c of n+m elements that consists of all elements from arrays a and b. Program reads and stores the arrays in files a, b and c one number per line. Memory consumption – O(1) Running time – O(n+m) Problem 3. The following function double rand() returns a random floating point number evenly distributed over interval [0;1). Write an expression (or a function) that returns a) a random integer N so that 7 <= N <= 23 b) a random number N from set {3.5, 4.5, 5.5, …, 13.5} c) a random string from set { “asdf”, “a”, “jkl;”, “cc”, “zaxd” } Problem 4. Given array a of N (N > 1) elements and integer K (0 < K <= N-1) transpose the array as follows {a[K], …, a[N-1], a[0],…, a[K-1]} Memory consumption (not including the space for array) – O(1) Running time – O(N). What data structure(s) can be used to implement the mini-framework for this problem effectively? Problem 5. Write a program that prints all permutations (in any order) of sequence {1, 2, 3, …, N}. Hint: there are N! permutations. Problem 6. Write a program that takes a string as a parameter and prints out all substrings of the following format: <tag>some text</tag>. Here ‘tag’ can be any alphanumeric character string. The input string is assumed not to have nested tags. Hint: regular expressions should be used for string matching What updates will be required in your program in case of nested tags? Код решения наиболее последней версии тут: AlgorithmsSolver - класс алгоритмов AlgorithmsStarter - класс для запуска Скачать дополнительно: a.txt – используется в Problem 2, предполагается нахождение в корне C:\ b.txt – используется в Problem 2, предполагается нахождение в корне C:\ combinatoricslib-2.0.jar – используется в Problem 5 commons-io-2.4.jar – используется в Problem 6 nested_tags.html – используется в Problem 6, предполагается нахождение в корне C:\ |