Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f547309

Browse files
authored
Merge pull request #89 from AlreadyBored/refactor/remove-ds
Remove DS tasks
2 parents f109533 + 8255b9a commit f547309

14 files changed

+4
-617
lines changed

README.md

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -276,53 +276,6 @@ Write your code in `src/vigenere-cipher.js`.
276276

277277
---
278278

279-
### **Binary search tree**
280-
281-
![Binary search tree](https://www.tutorialspoint.com/data_structures_algorithms/images/binary_search_tree.jpg)
282-
A **binary tree** is a hierarchical **data structure** in which each **node** has a **value** (in this case, it is also a key) and **links** to the **left** and **right** **children**. The **node** that is at the topmost level (which is not someone else's child) is called the **root**. **Nodes** that have no children are called **leaves**.
283-
284-
A **binary search tree** is a **binary tree** with additional properties: the value of the **left** child is **less** than the value of the parent, and the value of the **right** child is **greater** than the value of the parent for each tree **node**. That is, the data in the binary search tree is stored sorted. Each time you **add** a new or **remove** an existing node, the sorted order of the tree is preserved. When **searching** for an element, the search value is compared with the root. If the desired is **greater** than the root, then the search continues in the **right** child of the root, if **less**, then in the **left**, if **equal**, then the value is **found** and the search stops.
285-
286-
Your task is to implement the class `BinarySearchTree`.
287-
Each instance of `BinarySearchTree` must have following methods:
288-
* `root` — return **root node** of the tree
289-
* `add(data)` — add **node** with `data` to the tree
290-
* `has(data)` — returns `true` if **node** with the `data` exists in the tree and `false` otherwise
291-
* `find(data)` — returns **node** with the `data` if **node** with the `data` exists in the tree and `null` otherwise
292-
* `remove(data)` — removes **node** with the `data` from the tree if **node** with the `data` exists
293-
* `min` — returns **minimal** **value** stored in the tree (or `null` if tree has no **nodes**)
294-
* `max` — returns **maximal** **value** stored in the tree (or `null` if tree has no **nodes**)
295-
296-
For example:
297-
298-
`const tree = new BinarySearchTree();`
299-
300-
`tree.add(1);`
301-
302-
`tree.add(2);`
303-
304-
`tree.add(3);`
305-
306-
`tree.add(4);`
307-
308-
`tree.add(5);`
309-
310-
`tree.root().data` => `1;`
311-
312-
`tree.min()` => `1`
313-
314-
`tree.max()` => `5`
315-
316-
`tree.remove(5);`
317-
318-
`tree.has(5)` => `false`
319-
320-
`tree.max()` => `4`
321-
322-
Write your code in `src/binary-search-tree.js`.
323-
324-
---
325-
326279
### **(ST) Common character count**
327280
Your task is to implement function that accepts two **strings** (`s1` and `s2`) and returns **number** of common characters between them.
328281

@@ -446,25 +399,6 @@ Write your code in `src/st-mine-sweeper.js`.
446399

447400
---
448401

449-
### **(ST) Remove from list**
450-
Given a **singly linked list** of integers `l` and an integer `k`, remove all elements from list `l` that have a value equal to `k`.
451-
452-
For example, for `l` = `[3, 1, 2, 3, 4, 5]` and `k` = `3`,
453-
the output should be `[1, 2, 4, 5]`
454-
455-
**Singly linked lists** are already defined with this interface
456-
457-
```js
458-
function ListNode(x) {
459-
this.value = x;
460-
this.next = null;
461-
}
462-
```
463-
464-
Write your code in `src/st-remove-from-list.js`.
465-
466-
---
467-
468402
### **(ST) Sort by height**
469403
Given an array with heights, sort them except if the value is `-1`.
470404
Your task is to implement function that accepts **array** (`arr`) and returns it **sorted**
@@ -477,24 +411,6 @@ Write your code in `src/st-sort-by-height.js`.
477411

478412
---
479413

480-
### **(ST) Stack**
481-
Implement the **Stack** with a given interface via **array**.
482-
483-
For example:
484-
485-
```js
486-
const stack = new Stack();
487-
488-
stack.push(1); // adds the element to the stack
489-
stack.peek(); // returns the peek, but doesn't delete it, returns 1
490-
stack.pop(); // returns the top element from stack and deletes it, returns 1
491-
stack.pop(); // undefined
492-
```
493-
494-
Write your code in `src/st-stack.js`.
495-
496-
---
497-
498414
### **(ST) Sum digits**
499415
Your task is to implement function that accepts a **number** (`n`) and returns the **sum of its digits** until we get to a **one digit number**.
500416

@@ -509,29 +425,6 @@ Write your code in `src/st-sum-digits.js`.
509425

510426
---
511427

512-
### **(ST) Queue**
513-
Implement the **Queue** with a given interface via **linked list** (use `ListNode` extension).
514-
Each instance of queue must have 3 methods:
515-
* `enqueue(value)` — puts the `value` at the end of the **queue**
516-
* `deque` — retrieves a value from the head of the **queue** and deletes it
517-
* `getUnderlyingList` - returns underlying **linked list**
518-
519-
For example:
520-
521-
```js
522-
const queue = new Queue();
523-
524-
queue.enqueue(1); // adds the element to the queue
525-
queue.enqueue(3); // adds the element to the queue
526-
queue.dequeue(); // returns the top element from queue and deletes it, returns 1
527-
queue.getUnderlyingList() // returns { value: 3, next: null }
528-
529-
```
530-
531-
Write your code in `src/st-queue.js`.
532-
533-
---
534-
535428
#### Prerequisites
536429
1. Install [Node.js](https://nodejs.org/en/download/)
537430
2. Fork this repository: https://github.com/AlreadyBored/basic-js

README_RU.md

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -275,54 +275,6 @@ NB! Имя члена команды может содержать **пробе
275275

276276
---
277277

278-
### **Бинарное дерево поиска**
279-
280-
![Binary search tree](https://www.tutorialspoint.com/data_structures_algorithms/images/binary_search_tree.jpg)
281-
**Бинарное дерево** — это иерархическая **структура данных**, в которой каждый **узел** имеет **значение** (оно же является в данном случае и ключом) и **ссылки** на **левого** и **правого** **потомка**. **Узел**, находящийся на самом верхнем уровне (не являющийся чьим либо потомком) называется **корнем**. **Узлы**, не имеющие потомков, называются **листьями**.
282-
283-
284-
**Бинарное дерево поиска** — это **бинарное дерево**, обладающее дополнительными свойствами: значение **левого** потомка **меньше** значения родителя, а значение **правого** потомка **больше** значения родителя для каждого **узла** дерева. То есть, данные в бинарном дереве поиска хранятся в отсортированном виде. При каждой операции **вставки** нового или **удаления** существующего узла отсортированный порядок дерева сохраняется. При **поиске** элемента сравнивается искомое значение с корнем. Если искомое **больше** корня, то поиск продолжается в **правом** потомке корня, если **меньше**, то в **левом**, если **равно**, то значение **найдено** и поиск прекращается.
285-
286-
Ваша задача — реализовать класс `BinarySearchTree`.
287-
Каждый экземпляр `BinarySearchTree` должен обладать следующими методами:
288-
* `root` — возвращает **корневой узел** дерева
289-
* `add(data)` — добавляет **узел** с `data` к дереву
290-
* `has(data)` — возвращает `true`, если **узел** с `data` имеется в дереве и `false`, если нет
291-
* `find(data)` — возвращает **узел** с `data`, если **узел** с `data` имеется в дереве и `null`, если нет
292-
* `remove(data)` — удаляет **узел** с `data` из дерева, если **узел** с `data` имеется в дереве
293-
* `min` — возвращает **минимальное** **значение**, хранящееся в дереве (или `null`, если у дерева нет **узлов**)
294-
* `max` — возвращает **максимальное** **значение**, хранящееся в дереве (или `null`, если у дерева нет **узлов**)
295-
296-
Например:
297-
298-
`const tree = new BinarySearchTree();`
299-
300-
`tree.add(1);`
301-
302-
`tree.add(2);`
303-
304-
`tree.add(3);`
305-
306-
`tree.add(4);`
307-
308-
`tree.add(5);`
309-
310-
`tree.root().data` => `1;`
311-
312-
`tree.min()` => `1`
313-
314-
`tree.max()` => `5`
315-
316-
`tree.remove(5);`
317-
318-
`tree.has(5)` => `false`
319-
320-
`tree.max()` => `4`
321-
322-
Напишите свой код в `src/binary-search-tree.js`.
323-
324-
---
325-
326278
### **(ST) Сосчитать общие символы**
327279
Ваша задача — реализовать функцию, которая принимает 2 **строки** (`s1` и `s2`) и возвращает **число** их общих символов.
328280

@@ -446,25 +398,6 @@ minesweeper(matrix) => [
446398

447399
---
448400

449-
### **(ST) Удалить из списка**
450-
Дан **односвязный связный список** целых чисел (`l`) и целое число (`k`), удалите все элементы из списка `l`, содержащие значение `k`.
451-
452-
Например, для `l` = `[3, 1, 2, 3, 4, 5]` и `k` = `3`,
453-
результат будет `[1, 2, 4, 5]`
454-
455-
Узлы односвязного связного списка определяются интерфейсом:
456-
457-
```js
458-
function ListNode(x) {
459-
this.value = x;
460-
this.next = null;
461-
}
462-
```
463-
464-
Напишите свой код в `src/st-remove-from-list.js`.
465-
466-
---
467-
468401
### **(ST) Отссортировать по высоте**
469402
Дан массив с высотами, отсортируйте его, за исключением значений `-1`.
470403
Ваша задача — реализовать функцию, которая принимает **массив** (`arr`) и возвращает его **отсортированным**.
@@ -477,24 +410,6 @@ function ListNode(x) {
477410

478411
---
479412

480-
### **(ST) Стек**
481-
Реализуйте **стек** с заданным интерфейсом на основе **массива**.
482-
483-
Например:
484-
485-
```js
486-
const stack = new Stack();
487-
488-
stack.push(1); // добавляет элемент в стек
489-
stack.peek(); // возвращает верхний элемент, но не удаляет его, возвращает 1
490-
stack.pop(); // возвращает верхний элемент и удаляет его, возвращает 1
491-
stack.pop(); // undefined
492-
```
493-
494-
Напишите свой код в `src/st-stack.js`.
495-
496-
---
497-
498413
### **(ST) Сумма цифр**
499414
Ваша задача — реализовать функцию, которая принимает **число** (`n`) и возвращает **сумму его цифр**, пока не получится **число из одной цифры**.
500415

@@ -509,24 +424,6 @@ stack.pop(); // undefined
509424

510425
---
511426

512-
### **(ST) Очередь**
513-
Реализуйте **очередь** с заданным интерфейсом на основе **связного списка** (используйте `ListNode`, расположенный в папке `extensions`).
514-
Каждый экземпляр очереди должен иметь 3 метода:
515-
* `enqueue(value)` — помещает `value` в конец **очереди**
516-
* `deque` — извлекает значение с начала **очереди** и удаляет его
517-
* `getUnderlyingList` - возвращает **связный список**, лежащий в основе данной **очереди**
518-
519-
Например:
520-
521-
```js
522-
const queue = new Queue();
523-
524-
queue.enqueue(1); // добавляет элемент в очередь
525-
queue.enqueue(3); // добавляет элемент в очередь
526-
queue.dequeue(); // возвращает элемент из начала очереди и удаляет его, возвращает 1
527-
queue.getUnderlyingList() // возвращает { value: 3, next: null }
528-
```
529-
530427
Напишите свой код в `src/st-queue.js`.
531428

532429
---

extensions/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import { checkForThrowingErrors, checkForNotThrowingErrors } from './check-error
22
import { CONSTANTS } from './constants.js';
33
import { testOptional } from './it-optional.js';
44
import { NotImplementedError } from './not-implemented-error.js';
5-
import { ListNode } from './list-node.js';
65

76
export {
87
checkForThrowingErrors,
98
checkForNotThrowingErrors,
109
CONSTANTS,
1110
testOptional,
1211
NotImplementedError,
13-
ListNode
1412
};

extensions/list-node.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

extensions/list-tree.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/binary-search-tree.js

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/st-queue.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)