{"id":364261,"date":"2024-05-21T02:13:26","date_gmt":"2024-05-21T02:13:26","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=364261"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=364261","title":{"rendered":"<span>\u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u0423\u0441\u043b\u043e\u0432\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438<\/h3>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b <code>numberArray<\/code> \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430. \u0415\u0441\u043b\u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d, \u0442\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f <code>-1<\/code>.<\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u0443\u0434\u0435\u043b\u044e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0434\u043b\u0438\u043d\u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u043e\u0439. \u041c\u0430\u0441\u0441\u0438\u0432 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u043b\u044e\u0431\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0438 \u0438\u0441\u043a\u043e\u043c\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u044b\u043c.<\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b \u043e\u0442 1 \u0434\u043e 100:<\/p>\n<pre><code class=\"javascript\">const numberArray [    1,  2,  3,   4,  5,  6,  7,  8,  9, 10, 11, 12,   13, 14, 15,  16, 17, 18, 19, 20, 21, 22, 23, 24,   25, 26, 27,  28, 29, 30, 31, 32, 33, 34, 35, 36,   37, 38, 39,  40, 41, 42, 43, 44, 45, 46, 47, 48,   49, 50, 51,  52, 53, 54, 55, 56, 57, 58, 59, 60,   61, 62, 63,  64, 65, 66, 67, 68, 69, 70, 71, 72,   73, 74, 75,  76, 77, 78, 79, 80, 81, 82, 83, 84,   85, 86, 87,  88, 89, 90, 91, 92, 93, 94, 95, 96,   97, 98, 99, 100 ]<\/code><\/pre>\n<h3>\u041b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p><strong>\u041b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a<\/strong> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0441 \u0446\u0435\u043b\u0435\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c. \u041e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0439\u0434\u0435\u043d \u0438\u0441\u043a\u043e\u043c\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u043b\u0438 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u0441\u044f \u0432\u0435\u0441\u044c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438:<\/p>\n<pre><code class=\"javascript\">const linearSearch = (numbersArray, targetNumber) => {   for (let i = 0; i &lt; numbersArray.length; i++) {     if (numbersArray[i] === targetNumber) {       return i \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430\u0439\u0434\u0435\u043d     }   }      return -1; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d } <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 <code>targetNumber<\/code> \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c <code>1<\/code>, \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u0446\u0438\u043a\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0447\u0438\u0441\u043b\u043e.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 <code>targetNumber<\/code> \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c <code>100<\/code>, \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f 100 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0446\u0438\u043a\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0447\u0438\u0441\u043b\u043e.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c <strong>O(n)<\/strong>. \u0422\u0430\u043a\u0443\u044e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0442\u0430\u043a \u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0438\u0441\u043a \u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h3>\u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a<\/h3>\n<p><strong>\u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a<\/strong> \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441 <strong>\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u043c<\/strong>.<\/p>\n<p>\u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0438\u0434\u0435\u0435 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u044b \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u043e\u0438\u0441\u043a\u0435 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c.<\/p>\n<h4>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430<\/h4>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u0447\u0438\u0441\u0435\u043b \u043e\u0442 1 \u0434\u043e 100 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e 87.<\/p>\n<p><strong>\u041f\u0435\u0440\u0432\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0420\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u043d\u0430\u0448 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u043f\u043e\u043b\u0430\u043c. \u0423 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c 2 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>one<\/code> \u0438 <code>two<\/code>. \u0412 <code>one<\/code> \u0447\u0438\u0441\u043b\u0430 \u043e\u0442 1 \u0434\u043e 50, \u0430 \u0432 <code>two<\/code> \u0441 51 \u0434\u043e 100.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"javascript\">const one = [   1,  2,  3,   4,  5,  6,  7,  8,  9, 10,    11, 12, 13, 14, 15,  16, 17, 18, 19, 20,    21, 22, 23, 24, 25, 26, 27,  28, 29, 30,   31, 32, 33, 34, 35, 36, 37, 38, 39,  40,    41, 42, 43, 44, 45, 46, 47, 48, 50 ]  const two = [   51,  52, 53, 54, 55, 56, 57, 58, 59, 60,   61, 62, 63,  64, 65, 66, 67, 68, 69, 70,   71, 72, 73, 74, 75,  76, 77, 78, 79, 80,   81, 82, 83, 84, 85, 86, 87,  88, 89, 90,   91, 92, 93, 94, 95, 96, 97, 98, 99, 100 ]<\/code><\/pre>\n<ul>\n<li>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>one<\/code>. 49 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 87? \u041d\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>two<\/code>. 100 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 87? \u0414\u0430, \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0431\u0443\u0434\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 <code>two<\/code>. \u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u043c\u044b \u0443\u0436\u0435 \u043e\u0442\u0441\u0435\u043a\u043b\u0438 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u0442\u043e\u0440\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041c\u0430\u0441\u0441\u0438\u0432 <code>two<\/code> \u0441\u043d\u043e\u0432\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0438 \u043d\u0430 \u0434\u0432\u0430. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 <code>three<\/code>  c \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043e\u0442 50 \u0434\u043e 75 \u0438 <code>four<\/code> \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043e\u0442 76 \u0434\u043e 100.<\/p>\n<pre><code class=\"javascript\">const three = [   50, 51,  52, 53, 54, 55, 56, 57, 58, 59, 60,   61, 62, 63,  64, 65, 66, 67, 68, 69, 70, 71,   72, 73, 74, 75  ]  const four = [   76, 77, 78, 79, 80, 81, 82, 83, 84, 95, 85,   86, 87,  88, 89, 90, 91, 92, 93, 94, 96, 97,   98, 99, 100 ]<\/code><\/pre>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>three<\/code>. 75 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 87? \u041d\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>four<\/code>. 100 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 87? \u0414\u0430, \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0431\u0443\u0434\u0435\u0442 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 <code>four<\/code>. \u041f\u0440\u0438 \u0432\u0442\u043e\u0440\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u043c\u044b \u043e\u0442\u0441\u0435\u043a\u043b\u0438 \u0435\u0449\u0435 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0422\u0440\u0435\u0442\u044c\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041c\u0430\u0441\u0441\u0438\u0432 <code>four<\/code> \u0441\u043d\u043e\u0432\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0438 \u043d\u0430 \u0434\u0432\u0430. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 <code>five<\/code> \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043e\u0442 76 \u0434\u043e 87 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432 <code>six<\/code> \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043e\u0442 88 \u0434\u043e 100.<\/p>\n<pre><code class=\"javascript\">const five = [   76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,  ]  const six = [   88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100 ]<\/code><\/pre>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>five<\/code>.<\/p>\n<\/li>\n<li>\n<p>87 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 87? \u041d\u0435\u0442. \u041e\u043d\u0438 \u0440\u0430\u0432\u043d\u044b. <strong>\u041c\u044b \u043d\u0430\u0448\u043b\u0438 \u043d\u0430\u0448\u0435 \u0447\u0438\u0441\u043b\u043e \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438.<\/strong><\/p>\n<\/li>\n<\/ul>\n<h4>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430<\/h4>\n<p><strong>\u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d!<\/strong><\/p>\n<p>\u041f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438 \u0443 \u043d\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u0430\u044f \u0434\u043b\u0438\u043d\u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438 \u043b\u044e\u0431\u044b\u0435 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430.<\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b.<\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>getRandomNumber<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435:<\/p>\n<pre><code class=\"javascript\">const getRandomNumber = (min, max) => {   \/\/ \u041c\u0435\u0442\u043e\u0434 Math.ceil() - \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0435 \u0432\u0432\u0435\u0440\u0445. \u041e\u043a\u0440\u0443\u0433\u043b\u044f\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e.   min = Math.ceil(min);   \/\/ \u041c\u0435\u0442\u043e\u0434 Math.floor() - \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0435 \u0432\u043d\u0438\u0437. \u041e\u043a\u0440\u0443\u0433\u043b\u044f\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e.   max = Math.floor(max);    \/\/ \u041c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f, \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f   return Math.floor(Math.random() * (max - min) + min); }<\/code><\/pre>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>createRandomNumberArray<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u043d\u044b \u0441 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438.<\/p>\n<pre><code class=\"javascript\">const createRandomNumberArray = (arrayLength, firstNumber) => {   return Array.from({ length: arrayLength }, (_, index) => index + firstNumber); }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>binarySearch<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c (\u0438\u043b\u0438 -1) \u0438 \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0446\u0438\u043a\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u0440\u043e\u0448\u043b\u0438.<\/p>\n<pre><code class=\"javascript\">const binarySearch = (numbersArray, targetNumber) => {   let left = 0;   let right = numbersArray.length - 1;   let foundIndex = -1   let operations = 0      while (left &lt;= right) {     const mid = Math.floor((left + right) \/ 2);          if (numbersArray[mid] === targetNumber) {       foundIndex = mid; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430\u0439\u0434\u0435\u043d       break;     } else if (numbersArray[mid] &amp;lt; targetNumber) {       left = mid + 1; \/\/ \u0418\u0449\u0435\u043c \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435     } else {       right = mid - 1; \/\/ \u0418\u0449\u0435\u043c \u0432 \u043b\u0435\u0432\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435     }        operations += 1   }      return { foundIndex, operations } }<\/code><\/pre>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>linearSearch<\/code> c \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u0438\u043b\u0438 -1 \u0438 \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0446\u0438\u043a\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u0440\u043e\u0448\u043b\u0438.<\/p>\n<pre><code class=\"javascript\">const linearSearch = (numbersArray, targetNumber) => {   let foundIndex = -1   let operations = 0    for (let i = 0; i &lt; numbersArray.length; i++) {     if (numbersArray[i] === targetNumber) {       foundIndex = i       return { foundIndex, operations }; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430\u0439\u0434\u0435\u043d     }          operations += 1   }    return { foundIndex, operations }; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d }<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 const arrayLength = getRandomNumber(1000, 2000) \/\/ \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0448\u0438 \u0447\u0438\u0441\u043b\u0430. const firstNumber = getRandomNumber(1, 1000) \/\/ \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c const targetNumber = getRandomNumber(firstNumber, 1000)<\/code><\/pre>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0430\u043c \u043c\u0430\u0441\u0441\u0438\u0432:<\/p>\n<pre><code class=\"javascript\">\/\/ \u041c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b const numbersArray = createRandomNumberArray(arrayLength, firstNumber)<\/code><\/pre>\n<p>\u0418 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u0434 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0446\u0438\u043a\u043b\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"javascript\">const binaryResult = binarySearch(numbersArray, targetNumber) const linearResult = linearSearch(numbersArray, targetNumber)  console.log('arrayLength', arrayLength) console.log('firstNumber', firstNumber) console.log('targetNumber', targetNumber) console.log('binaryResult', binaryResult) console.log('linearResult', linearResult)<\/code><\/pre>\n<p><strong>\u041f\u043e\u043b\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043a\u043e\u0434\u0430:<\/strong><\/p>\n<pre><code class=\"javascript\">const getRandomNumber = (min, max) => {   \/\/ \u041c\u0435\u0442\u043e\u0434 Math.ceil() - \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0435 \u0432\u0432\u0435\u0440\u0445. \u041e\u043a\u0440\u0443\u0433\u043b\u044f\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e.   min = Math.ceil(min);   \/\/ \u041c\u0435\u0442\u043e\u0434 Math.floor() - \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0435 \u0432\u043d\u0438\u0437. \u041e\u043a\u0440\u0443\u0433\u043b\u044f\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e.   max = Math.floor(max);    \/\/ \u041c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f, \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f   return Math.floor(Math.random() * (max - min) + min); }  const createRandomNumberArray = (arrayLength, firstNumber) => {   return Array.from({ length: arrayLength }, (_, index) => index + firstNumber); }  const binarySearch = (numbersArray, targetNumber) => {   let left = 0;   let right = numbersArray.length - 1;   let foundIndex = -1   let operations = 0      while (left &lt;= right) {     const mid = Math.floor((left + right) \/ 2);          if (numbersArray[mid] === targetNumber) {       foundIndex = mid; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430\u0439\u0434\u0435\u043d       break;     } else if (numbersArray[mid] &amp;lt; targetNumber) {       left = mid + 1; \/\/ \u0418\u0449\u0435\u043c \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435     } else {       right = mid - 1; \/\/ \u0418\u0449\u0435\u043c \u0432 \u043b\u0435\u0432\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435     }        operations += 1   }      return { foundIndex, operations } }  const linearSearch = (numbersArray, targetNumber) => {   let foundIndex = -1   let operations = 0    for (let i = 0; i &lt; numbersArray.length; i++) {     if (numbersArray[i] === targetNumber) {       foundIndex = i       return { foundIndex, operations }; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430\u0439\u0434\u0435\u043d     }          operations += 1   }    return { foundIndex, operations }; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d }  \/\/ \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 const arrayLength = getRandomNumber(1000, 2000) \/\/ \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0448\u0438 \u0447\u0438\u0441\u043b\u0430. const firstNumber = getRandomNumber(1, 1000) \/\/ \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c const targetNumber = getRandomNumber(firstNumber, 1000)  \/\/ \u041c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b const numbersArray = createRandomNumberArray(arrayLength, firstNumber)  const binarySearch = (numbersArray, targetNumber) => {   let left = 0;   let right = numbersArray.length - 1;   let foundIndex = -1   let operations = 0      while (left &lt;= right) {     const mid = Math.floor((left + right) \/ 2);          if (numbersArray[mid] === targetNumber) {       foundIndex = mid; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430\u0439\u0434\u0435\u043d       break;     } else if (numbersArray[mid] &amp;lt; targetNumber) {       left = mid + 1; \/\/ \u0418\u0449\u0435\u043c \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435     } else {       right = mid - 1; \/\/ \u0418\u0449\u0435\u043c \u0432 \u043b\u0435\u0432\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435     }        operations += 1   }      return { foundIndex, operations } }  const binaryResult = binarySearch(numbersArray, targetNumber) const linearResult = linearSearch(numbersArray, targetNumber)  console.log('arrayLength', arrayLength) console.log('firstNumber', firstNumber) console.log('targetNumber', targetNumber) console.log('binaryResult', binaryResult) console.log('linearResult', linearResult)<\/code><\/pre>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code>arrayLength 1376 firstNumber 499 targetNumber 995 binaryResult { foundIndex: 496, operations: 9 } linearResult { foundIndex: 496, operations: 496 }<\/code><\/pre>\n<pre><code>arrayLength 1158 firstNumber 785 targetNumber 817 binaryResult { foundIndex: 32, operations: 8 } linearResult { foundIndex: 32, operations: 32 }<\/code><\/pre>\n<pre><code>arrayLength 1002 firstNumber 671 targetNumber 822 binaryResult { foundIndex: 151, operations: 7 } linearResult { foundIndex: 151, operations: 151 }<\/code><\/pre>\n<pre><code>arrayLength 1235 firstNumber 951 targetNumber 970 binaryResult { foundIndex: 19, operations: 9 } linearResult { foundIndex: 19, operations: 19 }<\/code><\/pre>\n<pre><code>arrayLength 1599 firstNumber 649 targetNumber 940 binaryResult { foundIndex: 291, operations: 10 } linearResult { foundIndex: 291, operations: 291 }<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u0438\u0445 \u043f\u044f\u0442\u0438 \u0441\u043b\u0443\u0447\u0430\u044f\u0445:<\/p>\n<ul>\n<li>\n<p>\u0414\u043b\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043e\u0442 7 \u0434\u043e 10 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0446\u0438\u043a\u043b\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043e\u0442 19 \u0434\u043e 496 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0446\u0438\u043a\u043b\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0430. <\/p>\n<p>\u0421 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u0434\u0435\u043b\u043e \u043e\u0431\u0441\u0442\u043e\u0438\u0442 \u0438\u043d\u0430\u0447\u0435. \u0415\u0441\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 100 \u044d\u043b\u0435\u00ad\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 7 \u043f\u043e\u043f\u044b\u0442\u043e\u043a. \u0414\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0437 4 \u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434\u043e\u0432 \u044d\u043b\u0435\u00ad\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 32 \u043f\u043e\u043f\u044b\u0442\u043e\u043a. \u0412\u043f\u0435\u0447\u0430\u0442\u043b\u044f\u0435\u0442, \u0432\u0435\u0440\u043d\u043e?<\/p>\n<p>\u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0438 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c <strong>O(log n)<\/strong>.<\/p>\n<h4>\u041b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u044b<\/h4>\n<p><strong>\u041b\u043e\u0433\u0430\u0440\u0438\u0444\u043c<\/strong> &#8212; \u044d\u0442\u043e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043d\u0443\u0436\u043d\u043e \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e (\u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0430) \u043d\u0430 \u0441\u0430\u043c\u043e \u0441\u0435\u0431\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0435 \u0447\u0438\u0441\u043b\u043e.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0447\u0438\u0441\u043b\u043e 1000. \u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c \u0447\u0438\u0441\u043b\u0430 1000 \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044e 10, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 3. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e 10 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u043d\u043e\u0435 \u043d\u0430 \u0441\u0435\u0431\u044f \u0442\u0440\u0438 \u0440\u0430\u0437\u0430 (10 * 10 * 10) \u0440\u0430\u0432\u043d\u043e 1000.<\/p>\n<p><strong>\u041b\u043e\u0433\u0430\u0440\u0438\u0444\u043c \u2212 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044e \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c.<\/strong><\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <strong>log \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 log \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044e 2.<\/strong><\/p>\n<p>\u0414\u043b\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 <strong>log n<\/strong> \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a.<\/p>\n<p>\u0414\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0437 8 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 log 8 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 3 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e 2^3 = 8.<\/p>\n<p>\u0414\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0437 1024 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 log 1024 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 10 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e 2^10 = 1024.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/articles\/783848\/\"> https:\/\/habr.com\/ru\/articles\/783848\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u0423\u0441\u043b\u043e\u0432\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438<\/h3>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b <code>numberArray<\/code> \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430. \u0415\u0441\u043b\u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d, \u0442\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f <code>-1<\/code>.<\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u0443\u0434\u0435\u043b\u044e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0434\u043b\u0438\u043d\u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u043e\u0439. \u041c\u0430\u0441\u0441\u0438\u0432 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u043b\u044e\u0431\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0438 \u0438\u0441\u043a\u043e\u043c\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u044b\u043c.<\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b \u043e\u0442 1 \u0434\u043e 100:<\/p>\n<pre><code class=\"javascript\">const numberArray [    1,  2,  3,   4,  5,  6,  7,  8,  9, 10, 11, 12,   13, 14, 15,  16, 17, 18, 19, 20, 21, 22, 23, 24,   25, 26, 27,  28, 29, 30, 31, 32, 33, 34, 35, 36,   37, 38, 39,  40, 41, 42, 43, 44, 45, 46, 47, 48,   49, 50, 51,  52, 53, 54, 55, 56, 57, 58, 59, 60,   61, 62, 63,  64, 65, 66, 67, 68, 69, 70, 71, 72,   73, 74, 75,  76, 77, 78, 79, 80, 81, 82, 83, 84,   85, 86, 87,  88, 89, 90, 91, 92, 93, 94, 95, 96,   97, 98, 99, 100 ]<\/code><\/pre>\n<h3>\u041b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p><strong>\u041b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a<\/strong> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0441 \u0446\u0435\u043b\u0435\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c. \u041e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0439\u0434\u0435\u043d \u0438\u0441\u043a\u043e\u043c\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u043b\u0438 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u0441\u044f \u0432\u0435\u0441\u044c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438:<\/p>\n<pre><code class=\"javascript\">const linearSearch = (numbersArray, targetNumber) => {   for (let i = 0; i &lt; numbersArray.length; i++) {     if (numbersArray[i] === targetNumber) {       return i \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430\u0439\u0434\u0435\u043d     }   }      return -1; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d } <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 <code>targetNumber<\/code> \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c <code>1<\/code>, \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u0446\u0438\u043a\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0447\u0438\u0441\u043b\u043e.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 <code>targetNumber<\/code> \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c <code>100<\/code>, \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f 100 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0446\u0438\u043a\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0447\u0438\u0441\u043b\u043e.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c <strong>O(n)<\/strong>. \u0422\u0430\u043a\u0443\u044e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0442\u0430\u043a \u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0438\u0441\u043a \u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h3>\u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a<\/h3>\n<p><strong>\u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a<\/strong> \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441 <strong>\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u043c<\/strong>.<\/p>\n<p>\u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0438\u0434\u0435\u0435 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u044b \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u043e\u0438\u0441\u043a\u0435 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c.<\/p>\n<h4>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430<\/h4>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u0447\u0438\u0441\u0435\u043b \u043e\u0442 1 \u0434\u043e 100 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e 87.<\/p>\n<p><strong>\u041f\u0435\u0440\u0432\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0420\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u043d\u0430\u0448 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u043f\u043e\u043b\u0430\u043c. \u0423 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c 2 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>one<\/code> \u0438 <code>two<\/code>. \u0412 <code>one<\/code> \u0447\u0438\u0441\u043b\u0430 \u043e\u0442 1 \u0434\u043e 50, \u0430 \u0432 <code>two<\/code> \u0441 51 \u0434\u043e 100.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"javascript\">const one = [   1,  2,  3,   4,  5,  6,  7,  8,  9, 10,    11, 12, 13, 14, 15,  16, 17, 18, 19, 20,    21, 22, 23, 24, 25, 26, 27,  28, 29, 30,   31, 32, 33, 34, 35, 36, 37, 38, 39,  40,    41, 42, 43, 44, 45, 46, 47, 48, 50 ]  const two = [   51,  52, 53, 54, 55, 56, 57, 58, 59, 60,   61, 62, 63,  64, 65, 66, 67, 68, 69, 70,   71, 72, 73, 74, 75,  76, 77, 78, 79, 80,   81, 82, 83, 84, 85, 86, 87,  88, 89, 90,   91, 92, 93, 94, 95, 96, 97, 98, 99, 100 ]<\/code><\/pre>\n<ul>\n<li>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>one<\/code>. 49 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 87? \u041d\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>two<\/code>. 100 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 87? \u0414\u0430, \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0431\u0443\u0434\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 <code>two<\/code>. \u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u043c\u044b \u0443\u0436\u0435 \u043e\u0442\u0441\u0435\u043a\u043b\u0438 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u0442\u043e\u0440\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041c\u0430\u0441\u0441\u0438\u0432 <code>two<\/code> \u0441\u043d\u043e\u0432\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0438 \u043d\u0430 \u0434\u0432\u0430. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 <code>three<\/code>  c \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043e\u0442 50 \u0434\u043e 75 \u0438 <code>four<\/code> \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043e\u0442 76 \u0434\u043e 100.<\/p>\n<pre><code class=\"javascript\">const three = [   50, 51,  52, 53, 54, 55, 56, 57, 58, 59, 60,   61, 62, 63,  64, 65, 66, 67, 68, 69, 70, 71,   72, 73, 74, 75  ]  const four = [   76, 77, 78, 79, 80, 81, 82, 83, 84, 95, 85,   86, 87,  88, 89, 90, 91, 92, 93, 94, 96, 97,   98, 99, 100 ]<\/code><\/pre>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>three<\/code>. 75 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 87? \u041d\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>four<\/code>. 100 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 87? \u0414\u0430, \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0431\u0443\u0434\u0435\u0442 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 <code>four<\/code>. \u041f\u0440\u0438 \u0432\u0442\u043e\u0440\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u043c\u044b \u043e\u0442\u0441\u0435\u043a\u043b\u0438 \u0435\u0449\u0435 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0422\u0440\u0435\u0442\u044c\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041c\u0430\u0441\u0441\u0438\u0432 <code>four<\/code> \u0441\u043d\u043e\u0432\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0438 \u043d\u0430 \u0434\u0432\u0430. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 <code>five<\/code> \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043e\u0442 76 \u0434\u043e 87 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432 <code>six<\/code> \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043e\u0442 88 \u0434\u043e 100.<\/p>\n<pre><code class=\"javascript\">const five = [   76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,  ]  const six = [   88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100 ]<\/code><\/pre>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>five<\/code>.<\/p>\n<\/li>\n<li>\n<p>87 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 87? \u041d\u0435\u0442. \u041e\u043d\u0438 \u0440\u0430\u0432\u043d\u044b. <strong>\u041c\u044b \u043d\u0430\u0448\u043b\u0438 \u043d\u0430\u0448\u0435 \u0447\u0438\u0441\u043b\u043e \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438.<\/strong><\/p>\n<\/li>\n<\/ul>\n<h4>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430<\/h4>\n<p><strong>\u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d!<\/strong><\/p>\n<p>\u041f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438 \u0443 \u043d\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u0430\u044f \u0434\u043b\u0438\u043d\u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438 \u043b\u044e\u0431\u044b\u0435 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430.<\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b.<\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>getRandomNumber<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435:<\/p>\n<pre><code class=\"javascript\">const getRandomNumber = (min, max) => {   \/\/ \u041c\u0435\u0442\u043e\u0434 Math.ceil() - \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0435 \u0432\u0432\u0435\u0440\u0445. \u041e\u043a\u0440\u0443\u0433\u043b\u044f\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e.   min = Math.ceil(min);   \/\/ \u041c\u0435\u0442\u043e\u0434 Math.floor() - \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0435 \u0432\u043d\u0438\u0437. \u041e\u043a\u0440\u0443\u0433\u043b\u044f\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e.   max = Math.floor(max);    \/\/ \u041c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f, \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f   return Math.floor(Math.random() * (max - min) + min); }<\/code><\/pre>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>createRandomNumberArray<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u043d\u044b \u0441 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438.<\/p>\n<pre><code class=\"javascript\">const createRandomNumberArray = (arrayLength, firstNumber) => {   return Array.from({ length: arrayLength }, (_, index) => index + firstNumber); }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>binarySearch<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c (\u0438\u043b\u0438 -1) \u0438 \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0446\u0438\u043a\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u0440\u043e\u0448\u043b\u0438.<\/p>\n<pre><code class=\"javascript\">const binarySearch = (numbersArray, targetNumber) => {   let left = 0;   let right = numbersArray.length - 1;   let foundIndex = -1   let operations = 0      while (left &lt;= right) {     const mid = Math.floor((left + right) \/ 2);          if (numbersArray[mid] === targetNumber) {       foundIndex = mid; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430\u0439\u0434\u0435\u043d       break;     } else if (numbersArray[mid] &amp;lt; targetNumber) {       left = mid + 1; \/\/ \u0418\u0449\u0435\u043c \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435     } else {       right = mid - 1; \/\/ \u0418\u0449\u0435\u043c \u0432 \u043b\u0435\u0432\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435     }        operations += 1   }      return { foundIndex, operations } }<\/code><\/pre>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>linearSearch<\/code> c \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u0438\u043b\u0438 -1 \u0438 \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0446\u0438\u043a\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u0440\u043e\u0448\u043b\u0438.<\/p>\n<pre><code class=\"javascript\">const linearSearch = (numbersArray, targetNumber) => {   let foundIndex = -1   let operations = 0    for (let i = 0; i &lt; numbersArray.length; i++) {     if (numbersArray[i] === targetNumber) {       foundIndex = i       return { foundIndex, operations }; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430\u0439\u0434\u0435\u043d     }          operations += 1   }    return { foundIndex, operations }; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d }<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 const arrayLength = getRandomNumber(1000, 2000) \/\/ \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0448\u0438 \u0447\u0438\u0441\u043b\u0430. const firstNumber = getRandomNumber(1, 1000) \/\/ \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c const targetNumber = getRandomNumber(firstNumber, 1000)<\/code><\/pre>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0430\u043c \u043c\u0430\u0441\u0441\u0438\u0432:<\/p>\n<pre><code class=\"javascript\">\/\/ \u041c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b const numbersArray = createRandomNumberArray(arrayLength, firstNumber)<\/code><\/pre>\n<p>\u0418 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u0434 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0446\u0438\u043a\u043b\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"javascript\">const binaryResult = binarySearch(numbersArray, targetNumber) const linearResult = linearSearch(numbersArray, targetNumber)  console.log('arrayLength', arrayLength) console.log('firstNumber', firstNumber) console.log('targetNumber', targetNumber) console.log('binaryResult', binaryResult) console.log('linearResult', linearResult)<\/code><\/pre>\n<p><strong>\u041f\u043e\u043b\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043a\u043e\u0434\u0430:<\/strong><\/p>\n<pre><code class=\"javascript\">const getRandomNumber = (min, max) => {   \/\/ \u041c\u0435\u0442\u043e\u0434 Math.ceil() - \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0435 \u0432\u0432\u0435\u0440\u0445. \u041e\u043a\u0440\u0443\u0433\u043b\u044f\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e.   min = Math.ceil(min);   \/\/ \u041c\u0435\u0442\u043e\u0434 Math.floor() - \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0435 \u0432\u043d\u0438\u0437. \u041e\u043a\u0440\u0443\u0433\u043b\u044f\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e.   max = Math.floor(max);    \/\/ \u041c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f, \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f   return Math.floor(Math.random() * (max - min) + min); }  const createRandomNumberArray = (arrayLength, firstNumber) => {   return Array.from({ length: arrayLength }, (_, index) => index + firstNumber); }  const binarySearch = (numbersArray, targetNumber) => {   let left = 0;   let right = numbersArray.length - 1;   let foundIndex = -1   let operations = 0      while (left &lt;= right) {     const mid = Math.floor((left + right) \/ 2);          if (numbersArray[mid] === targetNumber) {       foundIndex = mid; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430\u0439\u0434\u0435\u043d       break;     } else if (numbersArray[mid] &amp;lt; targetNumber) {       left = mid + 1; \/\/ \u0418\u0449\u0435\u043c \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435     } else {       right = mid - 1; \/\/ \u0418\u0449\u0435\u043c \u0432 \u043b\u0435\u0432\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435     }        operations += 1   }      return { foundIndex, operations } }  const linearSearch = (numbersArray, targetNumber) => {   let foundIndex = -1   let operations = 0    for (let i = 0; i &lt; numbersArray.length; i++) {     if (numbersArray[i] === targetNumber) {       foundIndex = i       return { foundIndex, operations }; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430\u0439\u0434\u0435\u043d     }          operations += 1   }    return { foundIndex, operations }; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d }  \/\/ \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 const arrayLength = getRandomNumber(1000, 2000) \/\/ \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0448\u0438 \u0447\u0438\u0441\u043b\u0430. const firstNumber = getRandomNumber(1, 1000) \/\/ \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c const targetNumber = getRandomNumber(firstNumber, 1000)  \/\/ \u041c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b const numbersArray = createRandomNumberArray(arrayLength, firstNumber)  const binarySearch = (numbersArray, targetNumber) => {   let left = 0;   let right = numbersArray.length - 1;   let foundIndex = -1   let operations = 0      while (left &lt;= right) {     const mid = Math.floor((left + right) \/ 2);          if (numbersArray[mid] === targetNumber) {       foundIndex = mid; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430\u0439\u0434\u0435\u043d       break;     } else if (numbersArray[mid] &amp;lt; targetNumber) {       left = mid + 1; \/\/ \u0418\u0449\u0435\u043c \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435     } else {       right = mid - 1; \/\/ \u0418\u0449\u0435\u043c \u0432 \u043b\u0435\u0432\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435     }        operations += 1   }      return { foundIndex, operations } }  const binaryResult = binarySearch(numbersArray, targetNumber) const linearResult = linearSearch(numbersArray, targetNumber)  console.log('arrayLength', arrayLength) console.log('firstNumber', firstNumber) console.log('targetNumber', targetNumber) console.log('binaryResult', binaryResult) console.log('linearResult', linearResult)<\/code><\/pre>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code>arrayLength 1376 firstNumber 499<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-364261","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364261","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=364261"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364261\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=364261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=364261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=364261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}