{"id":301971,"date":"2020-04-16T09:00:51","date_gmt":"2020-04-16T09:00:51","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=301971"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=301971","title":{"rendered":"8 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 JavaScript"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/497476\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/70\/vu\/3k\/70vu3kqru4_v7waezgjqcz-wfem.png\"><\/p>\n<p>  \u0417\u0432\u0443\u0447\u0438\u0442 \u043b\u0438 \u044d\u0442\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u043e: \u00ab\u042f \u043d\u0430\u0447\u0430\u043b \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0432\u0435\u0431 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043a\u0443\u0440\u0441\u043e\u0432\u00bb?<\/p>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0437\u043d\u0430\u043d\u0438\u044f \u043e\u0441\u043d\u043e\u0432 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u043a\u0438 \u0432 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 JS.<\/p>\n<h3>1. \u0421\u0442\u0435\u043a (\u0432\u044b\u0437\u043e\u0432\u043e\u0432) (Stack)<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/et\/lm\/i8\/etlmi8bd7ikmj10ru5sunqry-q8.png\"><\/p>\n<p>  \u0421\u0442\u0435\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 LIFO (Last In First Out \u2014 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0432\u043e\u0448\u0435\u043b, \u043f\u0435\u0440\u0432\u044b\u043c \u0432\u044b\u0448\u0435\u043b). \u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u043b\u043e\u0436\u0438\u043b\u0438 \u043a\u043d\u0438\u0433\u0438 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430, \u0438 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u0438 \u0432\u0437\u044f\u0442\u044c \u0441\u0430\u043c\u0443\u044e \u043d\u0438\u0436\u043d\u044e\u044e \u043a\u043d\u0438\u0433\u0443, \u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043e\u0437\u044c\u043c\u0435\u0442\u0435 \u0432\u0435\u0440\u0445\u043d\u044e\u044e, \u0437\u0430\u0442\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0438 \u0442.\u0434. \u041a\u043d\u043e\u043f\u043a\u0430 \u00ab\u041d\u0430\u0437\u0430\u0434\u00bb \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 (\u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f) \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0421\u0442\u0435\u043a \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<ul>\n<li>push: \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442<\/li>\n<li>pop: \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0435\u0433\u043e<\/li>\n<li>peek: \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442<\/li>\n<li>length: \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u0442\u0435\u043a\u0435<\/li>\n<\/ul>\n<p>  \u041c\u0430\u0441\u0441\u0438\u0432 \u0432 JS \u0438\u043c\u0435\u0435\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0441\u0442\u0435\u043a\u0430, \u043d\u043e \u043c\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0435\u0433\u043e \u0441 \u043d\u0443\u043b\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e function Stack():<\/p>\n<pre><code class=\"javascript\">function Stack() {     this.count = 0     this.storage = {}      this.push = function(value) {         this.storage[this.count] = value         this.count++     }      this.pop = function() {         if (this.count === 0) return undefined         this.count--         let result = this.storage[this.count]         delete this.storage[this.count]         return result     }      this.peek = function() {         return this.storage[this.count - 1]     }      this.size = function() {         return this.count     } } <\/code><\/pre>\n<p>  <\/p>\n<h3>2. \u041e\u0447\u0435\u0440\u0435\u0434\u044c (\u043a\u044c\u044e) (Queue)<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rm\/zr\/q2\/rmzrq2vlgafekeqbytdik-pc86o.png\"><\/p>\n<p>  \u041e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u0441\u0442\u0435\u043a. \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 FIFO (First In First Out \u2014 \u043f\u0435\u0440\u0432\u044b\u043c \u0432\u043e\u0448\u0435\u043b, \u043f\u0435\u0440\u0432\u044b\u043c \u0432\u044b\u0448\u0435\u043b). \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u0442\u043e\u0438\u0442\u0435 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u043f\u0435\u0440\u0432\u044b\u0439 \u0432 \u043d\u0435\u0439 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u043c.<\/p>\n<p>  \u041e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<ul>\n<li>enqueue: \u0432\u043e\u0439\u0442\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043a\u043e\u043d\u0435\u0446<\/li>\n<li>dequeue: \u043f\u043e\u043a\u0438\u043d\u0443\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0435\u0433\u043e<\/li>\n<li>front: \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442<\/li>\n<li>isEmpty: \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043f\u0443\u0441\u0442\u0430 \u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c<\/li>\n<li>size: \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<\/li>\n<\/ul>\n<p>  \u041c\u0430\u0441\u0441\u0438\u0432 \u0432 JS \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"javascript\">function Queue() {     let collection = []      this.print = function() {         console.log(collection)     }      this.enqueue = function(element) {         collection.push(element)     }      this.dequeue = function() {         return collection.shift()     }      this.front = function() {         return collection[0]     }      this.isEmpty = function() {         return collection.length === 0     }      this.size = function() {         return collection.length     } } <\/code><\/pre>\n<p>  <\/p>\n<h4>\u041f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442)<\/h4>\n<p>  \u041e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e. \u041f\u0440\u0438\u0441\u0432\u043e\u0439\u0442\u0435 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442, \u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">function PriorityQueue() {     ...     this.enqueue = function(element) {         if (this.isEmpty()) {             collection.push(element)         } else {             let added = false             for (let i = 0; i &lt; collection.length; i++) {                 if (element[1] &lt; collection[i][1]) {                     collection.splice(i, 0, element)                     added = true                     break;                 }             }             if (!added) {                 collection.push(element)             }         }     } } <\/code><\/pre>\n<p>  \u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c:<\/p>\n<pre><code class=\"javascript\">let pQ = new PriorityQueue() pQ.enqueue([gannicus, 3]) pQ.enqueue([spartacus, 1]) pQ.enqueue([crixus, 2]) pQ.enqueue([oenomaus, 4]) pQ.print() <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"javascript\">[     [spartacus, 1],     [crixus, 2],     [gannicus, 3],     [oenomaus, 4] ] <\/code><\/pre>\n<p>  <\/p>\n<h3>3. \u0421\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a (\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439, \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0437\u043b\u043e\u0432 \u0438 \u0441\u0441\u044b\u043b\u043e\u043a \u0438\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439) (Linked List)<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ng\/o1\/oz\/ngo1ozxdcnboo-74qdqyyos0nim.png\"><\/p>\n<p>  \u0411\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e, \u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u2014 \u044d\u0442\u043e \u0446\u0435\u043f\u043e\u0447\u0435\u0447\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0447\u0430\u0441\u0442\u0435\u0439: \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0437\u043b\u0430 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0443\u0437\u0435\u043b. \u0421\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c. \u041e\u0442\u043b\u0438\u0447\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c:<\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<th>\u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0439<\/th>\n<th>\u041c\u0430\u0441\u0441\u0438\u0432<\/th>\n<th>\u0421\u043f\u0438\u0441\u043e\u043a<\/th>\n<\/tr>\n<tr>\n<td>\u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438<\/td>\n<td>\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 <\/td>\n<td>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 (\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f)<\/td>\n<\/tr>\n<tr>\n<td>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/td>\n<td>\u041f\u043e\u0438\u0441\u043a \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443, \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c<\/td>\n<td>\u041f\u043e\u0438\u0441\u043a \u043f\u043e \u0432\u0441\u0435\u043c \u0443\u0437\u043b\u0430\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043c\u0435\u043d\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0430\u044f<\/td>\n<\/tr>\n<tr>\n<td>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\/\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/td>\n<td>\u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043d\u0438\u0436\u0435<\/td>\n<td>\u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u044b\u0448\u0435<\/td>\n<\/tr>\n<tr>\n<td>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/td>\n<td>\u041e\u0434\u043d\u043e \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0439<\/td>\n<td>\u041e\u0434\u043d\u043e\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439, \u0434\u0432\u0443\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u043b\u0438 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0439<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u041e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<ul>\n<li>size: \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0437\u043b\u043e\u0432<\/li>\n<li>head: \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 (head \u2014 \u0433\u043e\u043b\u043e\u0432\u0430)<\/li>\n<li>add: \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043a\u043e\u043d\u0435\u0446 (tail \u2014 \u0445\u0432\u043e\u0441\u0442)<\/li>\n<li>remove: \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0437\u043b\u043e\u0432<\/li>\n<li>indexOf: \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u0443\u0437\u043b\u0430<\/li>\n<li>elementAt: \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0443\u0437\u0435\u043b \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443<\/li>\n<li>addAt: \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0443\u0437\u0435\u043b \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e (\u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443)<\/li>\n<li>removeAt: \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0443\u0437\u0435\u043b (\u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443)<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u0443\u0437\u0435\u043b function Node(element) {     \/\/ \u0434\u0430\u043d\u043d\u044b\u0435     this.element = element     \/\/ \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0443\u0437\u0435\u043b     this.next = null }  function LinkedList() {     let length = 0     let head = null     this.size = function() {         return length     }      this.head = function() {         return head     }      this.add = function(element) {         let node = new Node(element)         if (head === null) {             head = node         } else {             let currentNode = head             while (currentNode.next) {                 currentNode = currentNode.next             }             currentNode.next = node         }         length++     }      this.remove = function(element) {         let currentNode = head         let previousNode         if (currentNode.element !== element) {             head = currentNode.next         } else {             while (currentNode.element !== element) {                 previousNode = currentNode                 currentNode = currentNode.next             }             previousNode.next = currentNode.next         }         length--     }      this.isEmpty = function() {         return length === 0     }      this.indexOf = function(element) {         let currentNode = head         let index = -1         while (currentNode) {             index++             if (currentNode.element === element) {                 return index             }             currentNode = currentNode.next         }         return -1     }      this.elementAt = function(index) {         let currentNode = head         let count = 0         while (count &lt; index) {             count++             currentNode = currentNode.next         }         return currentNode.element     }      this.addAt = function(index, element) {         let node = new Node(element)         let currentNode = head         let previousNode         let currentIndex = 0         if (index &gt; length) return false         if (index === 0) {             node.next = currentNode             head = node         } else {             while (currentIndex &lt; index) {                 currentIndex++                 previousNode = currentNode                 currentNode = currentNode.next             }             node.next = currentNode             previousNode.next = node         }         length++     }      this.removeAt = function(index) {         let currentNode = head         let previousNode         let currentIndex = 0         if (index &lt; 0 || index &gt;= length) return null         if (index === 0) {             head = currentIndex.next         } else {             while (currentIndex &lt; index) {                 currentIndex++                 previousNode = currentNode                 currentNode = currentNode.next             }             previousNode.next = currentNode.next         }         length--         return currentNode.element     } } <\/code><\/pre>\n<p>  <\/p>\n<h3>4. \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439) (Set)<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/oa\/zs\/gs\/oazsgspwphkxkrd5gbojwee_v_m.png\"><\/p>\n<p>  \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f (\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e) \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0439 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438: \u043d\u0430\u0431\u043e\u0440 \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0438 \u043e\u0431\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. ES6 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u0445\u043e\u0434\u0441\u0442\u0432\u043e \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.<\/p>\n<p>  \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<ul>\n<li>values: \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438<\/li>\n<li>size: \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/li>\n<li>has: \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438<\/li>\n<li>add: \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442<\/li>\n<li>remove: \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442<\/li>\n<li>union: \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439<\/li>\n<li>difference: \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u0438\u044f \u0434\u0432\u0443\u0445 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439<\/li>\n<li>subset: \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043e\u0434\u043d\u0430 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u0434\u0440\u0443\u0433\u043e\u0439<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u043e\u0442 Set \u0432 JS function MySet() {     let collection = []     this.has = function(element) {         return (collection.indexOf(element) !== -1)     }      this.values = function() {         return collection     }      this.size = function() {         return collection.length     }      this.add = function(element) {         if (!this.has(element)) {             collection.push(element)             return true         }         return false     }      this.remove = function(element) {         if (this.has(element)) {             index = collection.indexOf(element)             collection.splice(index, 1)             return true         }         return false     }      this.union = function(otherSet) {         let unionSet = new MySet()         let firstSet = this.values()         let secondSet = otherSet.values()         firstSet.forEach(i =&gt; unionSet.add(i))         secondSet.forEach(i =&gt; unionSet.add(i))     }      this.intersection = function(otherSet) {         let intersectionSet = new MySet()         let firstSet = this.values()         firstSet.forEach(function(e) {             if (otherSet.has(e)) {                 intersectionSet.add(e)             }         })         return intersectionSet     }      this.difference = function(otherSet) {         let differenceSet = new MySet()         let firstSet = this.values()         firstSet.forEach(function(e) {             if (!otherSet.has(e)) {                 differenceSet.add(e)             }         })         return differenceSet     }      this.subset = function(otherSet) {         lat firstSet = this.values()         return firstSet.every(value =&gt; otherSet.has(value))     } } <\/code><\/pre>\n<p>  <\/p>\n<h3>5. \u0425\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 (\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f) (Hash Table)<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/bb\/hg\/og\/bbhgogykaxr4ccp1k5i09ltkmok.png\"><\/p>\n<p>  \u0425\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u2014 \u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0418\u0437-\u0437\u0430 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e \u043a\u043b\u044e\u0447\u0430\u043c, \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u0445, \u043a\u0430\u043a Map, Dictionary \u0438 Object. \u041a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435, \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u043c\u0435\u0435\u0442 hash function, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0449\u0443\u044e \u043a\u043b\u044e\u0447\u0438 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u043e\u043c\u0435\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u0430 (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f) \u043a\u043b\u044e\u0447\u0435\u0439. \u0412\u0440\u0435\u043c\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043b\u044e\u0447\u0443 \u043c\u043e\u0436\u0435\u0442 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0442\u044c O(1). \u041e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u2014 \u0432 \u044d\u0442\u043e\u043c \u0441\u0443\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u0425\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<ul>\n<li>add: \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u0440\u0443 \u043a\u043b\u044e\u0447\/\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/li>\n<li>remove: \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u0430\u0440\u0443<\/li>\n<li>lookup: \u043d\u0430\u0439\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0443<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">function hash(string, max) {     let hash = 0     for (let i = 0; i &lt; string.length; i++) {         hash += string.charCodeAt(i)     }     return hash % max }  function HashTable() {     let storage = []     const storageLimit = 4      this.add = function(key, value) {         let index = hash(key, storageLimit)         if (storage[index] === undefined) {             storage[index] = [                 [key, value]             ]         } else {             let inserted = false             for (let i = 0; i &lt; storage[index].len; i++) {                 if (storage[index][i][0] === key) {                     storage[index][i][1] = value                     inserted = true                 }             }             if (inserted === false) {                 storage[index].push([key, value])             }         }     }      this.remove = function(key) {         let index = hash(key, storageLimit)         if (storage[index].length === 1 &amp;&amp; storage[index][0][0] === key) {             delete storage[index]         } else {             for (let i = 0; i &lt; storage[index]; i++) {                 if (storage[index][i][0] === key) {                     delete storage[index][i]                 }             }         }     }      this.lookup = function(key) {         let index = hash(key, storageLimit)         if (storage[index] === undefined) {             return undefined         } else {             for (let i = 0; i &lt; storage[index].length; i++) {                 if (storage[index][i][0] === key) {                     return storage[index][i][1]                 }             }         }     } } <\/code><\/pre>\n<p>  <\/p>\n<h3>6. \u0414\u0435\u0440\u0435\u0432\u043e (Tree)<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/qm\/q4\/ir\/qmq4ir7grko1aaaluylviil8ssq.png\"><\/p>\n<p>  \u0414\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u2014 \u044d\u0442\u043e \u043c\u043d\u043e\u0433\u043e\u0441\u043b\u043e\u0439\u043d\u0430\u044f (\u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f) \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430. \u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0441\u0442\u0435\u043a\u0430 \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u0438. \u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430 \u0432 \u0447\u0430\u0441\u0442\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0412\u043e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b:<\/p>\n<ul>\n<li>root: \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u00ab\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f\u00bb<\/li>\n<li>parent node: \u043f\u0440\u044f\u043c\u043e\u0439 \u0443\u0437\u0435\u043b \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0441\u043b\u043e\u044f (\u0443\u0440\u043e\u0432\u043d\u044f), \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0438\u043c<\/li>\n<li>child node: \u043f\u0440\u044f\u043c\u043e\u0439 \u0443\u0437\u0435\u043b (\u0443\u0437\u043b\u044b) \u043d\u0438\u0436\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e<\/li>\n<li>siblings: \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0443\u0437\u043b\u0430<\/li>\n<li>leaf: \u0443\u0437\u0435\u043b \u0431\u0435\u0437 \u00ab\u0434\u0435\u0442\u0435\u0439\u00bb<\/li>\n<li>Edge: \u0432\u0435\u0442\u043a\u0430 \u0438\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0430 (\u0441\u0432\u044f\u0437\u044c) \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438<\/li>\n<li>Path: \u043f\u0443\u0442\u044c (\u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0441\u0441\u044b\u043b\u043e\u043a) \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0434\u043e \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/li>\n<li>Height of Tree (\u0432\u044b\u0441\u043e\u0442\u0430 \u0434\u0435\u0440\u0435\u0432\u0430): \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0441\u044b\u043b\u043e\u043a \u0441\u0430\u043c\u043e\u0433\u043e \u0434\u043b\u0438\u043d\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u043e\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0434\u043e \u0443\u0437\u043b\u0430, \u043d\u0435 \u0438\u043c\u0435\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432<\/li>\n<li>Depth of Node (\u0433\u043b\u0443\u0431\u0438\u043d\u0430 \u0443\u0437\u043b\u0430): \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0441\u044b\u043b\u043e\u043a \u043e\u0442 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0434\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/li>\n<li>Degree of Node: \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432<\/li>\n<\/ul>\n<p>  \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u043f\u043e\u0438\u0441\u043a\u0430 (Binary Search Tree, BST). \u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0438\u043c\u0435\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u043e\u0438\u0445 \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432, \u043b\u0435\u0432\u044b\u0439 (\u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439) \u0443\u0437\u0435\u043b \u043c\u0435\u043d\u044c\u0448\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e (\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e), \u043f\u0440\u0430\u0432\u044b\u0439 \u2014 \u0431\u043e\u043b\u044c\u0448\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ut\/rt\/6w\/utrt6wlmsveuy92b400rxfkvrvs.png\"><\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<ul>\n<li>add: \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0443\u0437\u0435\u043b<\/li>\n<li>findMin: \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0443\u0437\u0435\u043b<\/li>\n<li>findMax: \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0443\u0437\u0435\u043b<\/li>\n<li>find: \u043d\u0430\u0439\u0442\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0443\u0437\u0435\u043b<\/li>\n<li>isPresent: \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430<\/li>\n<li>remove: \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0443\u0437\u0435\u043b<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Node {     constructor(data, left = null, right = null) {         this.data = data         this.left = left         this.right = right     } }  class BST {     constructor() {         this.root = null     }      add(data) {         const node = this.root         if (node === null) {             this.root = new Node(data)             return         } else {             const searchTree = function(node) {                 if (data &lt; node.data) {                     if (node.left === null) {                         node.left = new Node(data)                         return                     } else if (node.left !== null) {                         return searchTree(node.left)                     }                 } else if (data &gt; node.data) {                     if (node.right === null) {                         node.right = new Node(data)                         return                     } else if (node.right !== null) {                         return searchTree(node.right)                     }                 } else {                     return null                 }             }             return searchTree(node)         }     }      findMin() {         let current = this.root         while (current.left !== null) {             current = current.left         }         return current.data     }      findMax() {         let current = this.root         while (current.right !== null) {             current = current.right         }         return current.data     }      find(data) {         let current = this.root         while (current.data !== data) {             if (data &lt; current.data) {                 current = current.left             } else {                 current = current.right             }             if (current === null) {                 return null             }         }         return current     }      isPresent(data) {         let current = this.root         while (current) {             if (data === current.data) {                 return true             }             data &lt; current.data ? current = current.left : current = current.right         }         return false     }      remove(data) {         const removeNode = function(node, data) {             if (node === null) return null             if (data === node.data) {                 \/\/ \u043f\u043e\u0442\u043e\u043c\u043a\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442                 if (node.left === null &amp;&amp; node.right === null) return null                 \/\/ \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0435\u0432\u044b\u0439 \u0443\u0437\u0435\u043b                 if (node.left === null) return node.right                 \/\/ \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0440\u0430\u0432\u044b\u0439 \u0443\u0437\u0435\u043b                 if (node.right === null) return node.left                 \/\/ \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0443\u0437\u043b\u0430                 let tempNode = node.right                 while (tempNode.left !== null) {                     tempNode = tempNode.left                 }                 node.data = tempNode.data                 node.right = removeNode(node.right, tempNode.data)                 return node             } else if (data &lt; node.data) {                 node.left = removeNode(node.right, data)                 return node             } else {                 node.right = removeNode(node.right, data)                 return node             }         }         this.root = removeNode(this.root, data)     } } <\/code><\/pre>\n<p>  \u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c:<\/p>\n<pre><code class=\"javascript\">const bst = new BST() bst.add(4) bst.add(2) bst.add(6) bst.add(1) bst.add(3) bst.add(5) bst.add(7) bst.remove(4) console.log(bst.findMin()) console.log(bst.findMax()) bst.remove(7) console.log(bst.findMax()) console.log(bst.isPresent(4)) <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"javascript\">1 7 6 false <\/code><\/pre>\n<p>  <\/p>\n<h3>7. \u041d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0435 (\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u0435) \u0434\u0435\u0440\u0435\u0432\u043e (Trie, \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u00abtry\u00bb)<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/jz\/dk\/ha\/jzdkhahelr1xusezmrqxcryvjni.png\"><\/p>\n<p>  \u041f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u2014 \u044d\u0442\u043e \u0440\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430. \u0414\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e (\u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c) \u2014 \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0434\u0435\u0440\u0435\u0432\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0434\u0438\u043d \u0448\u0430\u0433. \u041f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044f\u0445, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 \u043f\u043e\u0438\u0441\u043a.<\/p>\n<p>  \u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0434\u0435\u0440\u0435\u0432\u0430 \u2014 \u0431\u0443\u043a\u0432\u0430 \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u0432\u0435\u0442\u043a\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0441\u043b\u043e\u0432\u0430. \u041e\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u00ab\u0431\u0443\u043b\u0435\u0432\u044b\u0439 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u00bb \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0443\u0437\u0435\u043b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0431\u0443\u043a\u0432\u043e\u0439.<\/p>\n<p>  \u041f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<ul>\n<li>add: \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u043e\u0432\u043e \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c<\/li>\n<li>isWord: \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u043b\u043e\u0432\u0430<\/li>\n<li>print: \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432\u0441\u0435 \u0441\u043b\u043e\u0432\u0430<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u0443\u0437\u0435\u043b \u0434\u0435\u0440\u0435\u0432\u0430 function Node() {     this.keys = new Map()     this.end = false     this.setEnd = function() {         this.end = true     }     this.isEnd = function() {         return this.end     } }  function Trie() {     this.root = new Node()     this.add = function(input, node = this.root) {         if (input.length === 0) {             node.setEnd()             return         } else if (!node.keys.has(input[0])) {             node.keys.set(input[0], new Node())             return this.add(input.substr(1), node.key.get(input[0]))         } else {             return this.add(input.substr(1), node.keys.get(input[0]))         }     }      this.isWord = function(word) {         let node = this.root         while (word.length &gt; 1) {             if (node.keys.has(word[0])) {                 return false             } else {                 node = node.keys.get(word[0])                 word = word.substr(1)             }         }         return (node.keys.has(word) &amp;&amp; node.keys.get(word).isEnd()) ? true : false     }      this.print = function() {         let words = new Array()         let search = function(node = this.root, string) {             if (node.keys.size !== 0) {                 for (let letter of node.keys.keys()) {                     search(node.keys.get(letter), string.concat(letter))                 }                 if (node.isEnd()) {                     words.push(string)                 }             } else {                 string.length &gt; 0 ? words.push(string) : undefined                 return             }         }         search(this.root, new String())         return words.length &gt; 0 ? words : null     } } <\/code><\/pre>\n<p>  <\/p>\n<h3>8. \u0413\u0440\u0430\u0444 (\u0433\u0440\u0430\u0444\u0438\u043a) (Graph)<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/qg\/zn\/ec\/qgznecp7pxipyq6xffuzk16pgv8.png\"><\/p>\n<p>  \u0413\u0440\u0430\u0444, \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043a\u0430\u043a \u0441\u0435\u0442\u044c (Network), \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0443\u0437\u043b\u043e\u0432. \u0411\u044b\u0432\u0430\u0435\u0442 \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 \u0433\u0440\u0430\u0444\u043e\u0432 \u2014 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438 \u043d\u0435\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0438\u043c\u0435\u044e\u0442 \u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435. \u0413\u0440\u0430\u0444\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u043e\u0432\u0441\u0435\u043c\u0435\u0441\u0442\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0432 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0438\u043b\u0438 \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439 \u0432 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445.<\/p>\n<p>  \u0413\u0440\u0430\u0444\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043b\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u044b.<\/p>\n<h4>\u0421\u043f\u0438\u0441\u043e\u043a<\/h4>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0441\u0435 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0443\u0437\u043b\u044b \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0432\u0430, \u0430 \u0438\u0445 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u043f\u0440\u0430\u0432\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/8s\/tk\/8s\/8stk8sh47rwsx7r7n8-rbbap64a.png\"><\/p>\n<h4>\u041c\u0430\u0442\u0440\u0438\u0446\u0430<\/h4>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0437\u043b\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c, \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438: 0 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0443\u0437\u043b\u044b \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439, 1 \u2014 \u0443\u0437\u043b\u044b \u0441\u0432\u044f\u0437\u0430\u043d\u044b.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/un\/7x\/n8\/un7xn893iqg_vnuilozyscbugfe.jpeg\"><\/p>\n<p>  \u041f\u043e\u0438\u0441\u043a \u043f\u043e \u0433\u0440\u0430\u0444\u0443 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0432\u0443\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u2014 \u043f\u043e\u0438\u0441\u043a \u0432 \u0448\u0438\u0440\u0438\u043d\u0443 (Breath-First-Search, BFS) \u0438 \u043f\u043e\u0438\u0441\u043a \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 (Depth-First-Search, DFS).<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c BFS:<\/p>\n<pre><code class=\"javascript\">function bfs(graph, root) {     let nodesLen = {}     for (let i = 0; i &lt; graph.length; i++) {         nodesLen[i] = Infinity     }     nodesLen[root] = 0     let queue = [root]     let current     while (queue.length !== 0) {         current = queue.shift()          let curConnected = graph[current]         let neighborIdx = []         let idx = curConnected.indexOf(1)         while (idx !== -1) {             neighborIdx.push(idx)             idx = curConnected.indexOf(1, idx + 1)         }         for (let i = 0; i &lt; neighborIdx.length; i++) {             if (nodesLen[neighborIdx[i]] === Infinity) {                 nodesLen[neighborIdx[i]] = nodesLen[current] + 1                 queue.push(neighborIdx[i])             }         }     }     return nodesLen } <\/code><\/pre>\n<p>  \u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c:<\/p>\n<pre><code class=\"javascript\">let graph = [     [0, 1, 1, 1, 0],     [0, 0, 1, 0, 0],     [1, 1, 0, 0, 0],     [0, 0, 0, 1, 0],     [0, 1, 0, 0, 0] ] console.log(bfs(graph, 1)) <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"javascript\">{     0: 2,     1: 0,     2: 1,     3: 3,     4: Infinity } <\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0435. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u043d\u0430\u0448\u043b\u0438 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435. \u0421\u0447\u0430\u0441\u0442\u043b\u0438\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u0438\u043d\u0433\u0430!<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/497476\/\"> https:\/\/habr.com\/ru\/post\/497476\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/497476\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/70\/vu\/3k\/70vu3kqru4_v7waezgjqcz-wfem.png\"><\/p>\n<p>  \u0417\u0432\u0443\u0447\u0438\u0442 \u043b\u0438 \u044d\u0442\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u043e: \u00ab\u042f \u043d\u0430\u0447\u0430\u043b \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0432\u0435\u0431 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043a\u0443\u0440\u0441\u043e\u0432\u00bb?<\/p>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0437\u043d\u0430\u043d\u0438\u044f \u043e\u0441\u043d\u043e\u0432 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u043a\u0438 \u0432 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 JS.<\/p>\n<h3>1. \u0421\u0442\u0435\u043a (\u0432\u044b\u0437\u043e\u0432\u043e\u0432) (Stack)<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/et\/lm\/i8\/etlmi8bd7ikmj10ru5sunqry-q8.png\"><\/p>\n<p>  \u0421\u0442\u0435\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 LIFO (Last In First Out \u2014 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0432\u043e\u0448\u0435\u043b, \u043f\u0435\u0440\u0432\u044b\u043c \u0432\u044b\u0448\u0435\u043b). \u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u043b\u043e\u0436\u0438\u043b\u0438 \u043a\u043d\u0438\u0433\u0438 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430, \u0438 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u0438 \u0432\u0437\u044f\u0442\u044c \u0441\u0430\u043c\u0443\u044e \u043d\u0438\u0436\u043d\u044e\u044e \u043a\u043d\u0438\u0433\u0443, \u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043e\u0437\u044c\u043c\u0435\u0442\u0435 \u0432\u0435\u0440\u0445\u043d\u044e\u044e, \u0437\u0430\u0442\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0438 \u0442.\u0434. \u041a\u043d\u043e\u043f\u043a\u0430 \u00ab\u041d\u0430\u0437\u0430\u0434\u00bb \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 (\u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f) \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-301971","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301971","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=301971"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301971\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=301971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=301971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}