{"id":368540,"date":"2024-05-21T03:44:41","date_gmt":"2024-05-21T03:44:41","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=368540"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T03:44:41","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=368540","title":{"rendered":"<span>\u0428\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0430 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0441\u043e\u0431\u0435\u0441\u0430 \u2014 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u0430<\/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<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0422\u0430\u043a \u0443\u0436 \u043f\u043e\u0432\u0435\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043b\u044e\u0431\u043e\u0439 \u0443\u0432\u0430\u0436\u0430\u044e\u0449\u0438\u0439 \u0441\u0435\u0431\u044f \u0440\u0430\u0431\u043e\u0442\u043e\u0434\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u043e\u0432\u044b\u0435<img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"^\u273b\" alt=\"^\u273b\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f01\/a72\/775\/f01a727757f9a2f0e2ff173bffc172e5.svg\" width=\"10\" height=\"22\"\/> \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0438 FAANG \u2014 \u043f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043e \u0432\u0441\u0435\u0445 IT-\u0441\u043e\u0431\u0435\u0441\u0430\u0445 \u0435\u0441\u0442\u044c \u043e\u043d\u0430: <em>\u0441\u0435\u043a\u0446\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432<\/em>. \u041a\u0442\u043e-\u0442\u043e \u0435\u0439 \u0440\u0430\u0434, \u043a\u0442\u043e-\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c, \u043d\u043e \u0441\u0435\u043a\u0446\u0438\u044f \u0435\u0441\u0442\u044c \u0438 \u0443\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043a\u0430\u0442\u0430\u0442\u044c \u0440\u0443\u043a\u0430\u0432\u0430 \u0438 \u0434\u043e\u0441\u0442\u043e\u0439\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u0441\u0443\u0440\u043e\u0432\u0443\u044e \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u041f\u0440\u0438 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0440\u0430\u0441\u0441\u043b\u0430\u0431\u044c\u0442\u0435\u0441\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0439\u0442\u0435 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435, \u0432\u0435\u0434\u044c \u0435\u0441\u0442\u044c \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u0430\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u0432\u043d\u0435 \u0441\u043e\u0431\u0435\u0441\u0430. \u041a\u0442\u043e \u0437\u043d\u0430\u0435\u0442, \u043c\u043e\u0436\u0435\u0442 \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0443\u043c\u0435\u043d\u0438\u0435 \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0441\u043f\u0430\u0441\u0442\u0438 \u0432\u0430\u043c \u043c\u0438\u0440 (\u043a\u0430\u043a \u0438 \u0437\u043d\u0430\u043d\u0438\u0435 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043e\u043a):<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/05d\/581\/a27\/05d581a275ae7af85cf4af308b87d7ab.png\" width=\"1386\" height=\"1400\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/05d\/581\/a27\/05d581a275ae7af85cf4af308b87d7ab.png\"\/><\/figure>\n<p>\u0414\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435, \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0437\u0430\u043b\u0438\u043f\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c; \u041c\u0438\u0448\u0430 \u041b\u043e\u043c\u043e\u043d\u043e\u0441\u043e\u0432 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u0443\u043c \u0432 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442.<\/p>\n<p><em>\u0420\u0430\u0437\u0431\u043e\u0440 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u0441 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 <\/em>Python <a href=\"https:\/\/t.me\/+b9siS41vBj0wMzg6\" rel=\"noopener noreferrer nofollow\">\u0432 \u043c\u043e\u0435\u043c \u043a\u0430\u043d\u0430\u043b\u0435<\/a> \u0438 \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u043e <a href=\"https:\/\/t.me\/+FQIu7j2fWU4zZWVi\" rel=\"noopener noreferrer nofollow\">\u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e<\/a>, <em> \u0430 \u0437\u0434\u0435\u0441\u044c \u0441\u043e\u0431\u0440\u0430\u043d\u0430 <\/em><a href=\"https:\/\/t.me\/addlist\/8vDUwYRGujRmZjFi\" rel=\"noopener noreferrer nofollow\"><em>\u0446\u0435\u043b\u0430\u044f \u043f\u0430\u043f\u043a\u0430 <\/em><\/a><em>\u0441 \u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u043a \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u043c.<\/em><\/p>\n<p>\u0422\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043e\u0447\u0435\u043d\u044c \u0432\u0435\u043b\u0438\u043a\u0430, \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/adb\/37d\/354\/adb37d35477f2043f30a11d4fe685451.jpeg\" width=\"3764\" height=\"20510\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/adb\/37d\/354\/adb37d35477f2043f30a11d4fe685451.jpeg\" data-blurred=\"true\"\/><\/figure>\n<p>\u041d\u0435\u043c\u0430\u043b\u043e \u0432\u0441\u0435\u0433\u043e) \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0442\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0438 \u043f\u0440\u0430\u0432\u0434\u0430 \u043e\u0431\u0448\u0438\u0440\u043d\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043a\u043e\u0441\u043d\u0451\u043c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u044b\u0445 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0432\u0435\u0449\u0435\u0439:<\/p>\n<ul>\n<li>\n<p><a href=\"#1\" rel=\"noopener noreferrer nofollow\">\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u043a\u0430 \u0438 \u041e-\u043d\u043e\u0442\u0430\u0446\u0438\u044f<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#2\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445: \u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u0441\u0442\u0435\u043a, \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, map \u0438 \u0434\u0440\u0443\u0433\u0438\u0435<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#3\" rel=\"noopener noreferrer nofollow\">\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438<\/a><\/p>\n<\/li>\n<li>\n<p>\u0438 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u2014 <a href=\"#4\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b<\/a>; \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u043a\u043e\u0441\u043d\u0443\u0442\u044c\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e  <\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \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 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 Python, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u0442\u0435\u0441\u0442\u0438\u0442\u044c, \u043a\u0430\u043a \u0432\u0441\u0451 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/p>\n<p>\u041f\u043e\u0435\u0445\u0430\u043b\u0438!<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/901\/c9f\/7fc\/901c9f7fcaefdb7b6eaa51b518bed882.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/901\/c9f\/7fc\/901c9f7fcaefdb7b6eaa51b518bed882.gif\"\/><\/figure>\n<p><a class=\"anchor\" name=\"1\" id=\"1\"><\/a><\/p>\n<h2>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438 \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437<\/h2>\n<p>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u044e\u0442 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043f\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 (\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c). \u0412 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445: \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 100 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0438\u0437 1000. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u043e\u0447\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u0430\u043b\u043e \u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442: \u043e\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0412\u0430\u0436\u043d\u0430 \u043b\u0438\u0448\u044c \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u0442. \u0435. \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0441\u0442\u0440\u0435\u043c\u043b\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c <code>4n^3 + 7n<\/code> \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c <code>n<\/code> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 <code>n<\/code> \u043d\u0430 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043b\u0438\u044f\u0442\u044c \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 <code>n<\/code> \u0432 \u043a\u0443\u0431, \u0447\u0435\u043c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u043d\u0430 <code>4<\/code> \u0438\u043b\u0438 \u0436\u0435 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 <code>7n<\/code>. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0440\u0430\u0432\u043d\u0430 <code>\u041e(n^3)<\/code>, \u0442. \u0435. \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0443\u0431\u0438\u0447\u0435\u0441\u043a\u0438.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0431\u0443\u043a\u0432\u044b \u041e (\u041e-\u043d\u043e\u0442\u0430\u0446\u0438\u044f) \u043f\u0440\u0438\u0448\u043b\u043e \u0438\u0437 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438, \u0433\u0434\u0435 \u0435\u0451 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0424\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e <code>O(f(n))<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 (\u0438\u043b\u0438 \u043e\u0431\u044a\u0451\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438) \u0440\u0430\u0441\u0442\u0451\u0442 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u0431\u044a\u0451\u043c\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u043d\u0430 <code>f(n)<\/code>.<\/p>\n<p>\u0412\u0441\u0442\u0440\u0435\u0447\u0430\u0439\u0442\u0435 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u0435\u0439 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/442\/bf0\/eda\/442bf0edacde23d46499c90ac02f781a.png\" width=\"2488\" height=\"2192\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/442\/bf0\/eda\/442bf0edacde23d46499c90ac02f781a.png\"\/><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a0e\/e2c\/4f6\/a0ee2c4f6eeef2730acc9a789d19d5de.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a0e\/e2c\/4f6\/a0ee2c4f6eeef2730acc9a789d19d5de.gif\"\/><\/figure>\n<h3>O(1) \u2014 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>\u0421\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u043e\u0433\u0434\u0430 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u043a\u0430\u043a <code>O(1)<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043d\u0438 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043d\u0438 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e \u043d\u0438\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e-\u0442\u043e \u0440\u0430\u0437. \u0412\u0441\u0435\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0442\u043e\u043a\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0440\u0435\u0442\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c, \u043d\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0443\u0436\u043d\u043e \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>\u0425\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e O(1): \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/089\/b17\/511\/089b1751129fda3cddff71f2d15f2c3c.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/089\/b17\/511\/089b1751129fda3cddff71f2d15f2c3c.gif\"\/><\/figure>\n<h3>O(n) \u2014 \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>\u0422\u0430\u043a\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u043d\u0435 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0435. \u041d\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u0432\u0441\u0435\u043c <code>n<\/code> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/355\/055\/c6b\/355055c6b2668658e0f83e629a3cc7ff.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/355\/055\/c6b\/355055c6b2668658e0f83e629a3cc7ff.gif\"\/><\/figure>\n<h3>O(log n) \u2014 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a. \u0415\u0441\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0432 \u043d\u0451\u043c \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043f\u043e\u043b\u0430\u043c. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0435\u0441\u043b\u0438 \u043e\u043d \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u0441\u043a\u043e\u043c\u043e\u0433\u043e, \u0442\u043e \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u043c \u0432\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u2014 \u0442\u0430\u043c \u0435\u0433\u043e \u0442\u043e\u0447\u043d\u043e \u043d\u0435\u0442. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043c\u0435\u043d\u044c\u0448\u0435, \u0442\u043e \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u2014 \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443. \u0418 \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u043f\u043e\u043b\u0430\u043c, \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c <code>log n<\/code> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>\u0412\u043e\u0442 \u043d\u0438\u0436\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0448\u0430\u0433\u043e\u0432 \u043f\u0440\u0438 \u043f\u043e\u0438\u0441\u043a\u0435 \u0447\u0438\u0441\u043b\u0430 47 \u0432 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/438\/547\/f5d\/438547f5d228fb9534cc53372cd98168.gif\" width=\"773\" height=\"406\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/438\/547\/f5d\/438547f5d228fb9534cc53372cd98168.gif\"\/><\/figure>\n<h3>O(n^2) \u2014 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>\u0422\u0430\u043a\u0443\u044e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0430\u043c\u0438. \u0412 \u043a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0434\u0432\u0430 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0446\u0438\u043a\u043b\u0430: \u043e\u0434\u0438\u043d, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0443, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0441\u0442\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0432 \u0443\u0436\u0435 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043a\u0430\u043a <code>n*n<\/code>, \u0442. \u0435. <code>n^2<\/code>.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b9e\/868\/4e4\/b9e8684e473aea0cf9304aa975669459.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b9e\/868\/4e4\/b9e8684e473aea0cf9304aa975669459.gif\"\/><\/figure>\n<h3>\u0412 \u0438\u0442\u043e\u0433\u0435<\/h3>\n<p>\u041b\u0443\u0447\u0448\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0438\u043c\u0435\u044e\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c O(1) \u0438\u043b\u0438 O(log n), \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0440\u0430\u0441\u0442\u0451\u0442 \u0441\u043b\u0430\u0431\u043e \u043f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0434\u043b\u044f \u041e(1). \u0425\u0443\u0434\u0448\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0438\u043c\u0435\u044e\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c O(n!), O(2^n) \u0438\u043b\u0438 O(n^2), \u0447\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u0435\u0442 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d0f\/3e2\/bc2\/d0f3e2bc2b3dd7564b5309d87cdf7b49.png\" width=\"794\" height=\"564\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d0f\/3e2\/bc2\/d0f3e2bc2b3dd7564b5309d87cdf7b49.png\"\/><\/figure>\n<p>\u041a\u0430\u043a \u0440\u0430\u0441\u0442\u0451\u0442 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0438\u0434\u043e\u0432 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/de7\/64c\/512\/de764c512b88cb5631f8048605927ddb.png\" width=\"1258\" height=\"471\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/de7\/64c\/512\/de764c512b88cb5631f8048605927ddb.png\"\/><\/figure>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f, \u043f\u043e\u0438\u0441\u043a\u0430 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u043b\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0441\u0442\u0435\u043a\u0430, \u0441\u0432\u044f\u0437\u043d\u044b\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d75\/d58\/f80\/d75d58f8013d47ee54b2b9f3aa102c9a.png\" width=\"1321\" height=\"611\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d75\/d58\/f80\/d75d58f8013d47ee54b2b9f3aa102c9a.png\"\/><\/figure>\n<p>\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c07\/bce\/343\/c07bce3431e396ae755b339f53150ddf.png\" width=\"1205\" height=\"609\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c07\/bce\/343\/c07bce3431e396ae755b339f53150ddf.png\"\/><\/figure>\n<p>\u0421\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u043f\u043e\u0435\u0445\u0430\u043b\u0438 \u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445!<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3bf\/5d7\/29a\/3bf5d729afa6591bb1ce200e0f923378.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3bf\/5d7\/29a\/3bf5d729afa6591bb1ce200e0f923378.gif\"\/><\/figure>\n<p><a class=\"anchor\" name=\"2\" id=\"2\"><\/a><\/p>\n<h2>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/p>\n<\/li>\n<li>\n<p>\u0441\u0442\u0435\u043a<\/p>\n<\/li>\n<li>\n<p>\u043e\u0447\u0435\u0440\u0435\u0434\u044c<\/p>\n<\/li>\n<li>\n<p>\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e<\/p>\n<\/li>\n<li>\n<p>map<\/p>\n<\/li>\n<li>\n<p>\u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/p>\n<\/li>\n<li>\n<p>\u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043f\u043e\u0438\u0441\u043a\u0430<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e<\/p>\n<\/li>\n<li>\n<p>\u0434\u0432\u043e\u0438\u0447\u043d\u0430\u044f \u043a\u0443\u0447\u0430<\/p>\n<\/li>\n<li>\n<p>\u0433\u0440\u0430\u0444<\/p>\n<\/li>\n<\/ul>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6c2\/7fa\/aa2\/6c27faaa2a9ece191b0ed4b81e2bdeb2.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6c2\/7fa\/aa2\/6c27faaa2a9ece191b0ed4b81e2bdeb2.gif\"\/><\/figure>\n<h3>\u0421\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/032\/cde\/54e\/032cde54ecd9432f67ad46f1295dee89.png\" alt=\"\u0421\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a\" width=\"527\" height=\"222\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/032\/cde\/54e\/032cde54ecd9432f67ad46f1295dee89.png\"\/><\/p>\n<div><figcaption>\u0421\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/figcaption><\/div>\n<\/figure>\n<p><strong>\u0421\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/strong> \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0435 \u0447\u0430\u0441\u0442\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u043d\u043e\u0433\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043b\u0438\u0431\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043b\u0438\u0431\u043e \u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<p>\u0421\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0433\u0440\u0443\u043f\u043f\u044b \u0443\u0437\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0435 \u0432\u0435\u0449\u0438: \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043d\u0435\u043c \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f (\u044d\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430) \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c (\u0438\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0443) \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0443\u0437\u0435\u043b \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0421\u0430\u043c\u044b\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0433\u043e\u043b\u043e\u0432\u043e\u0439 (<em>head<\/em>) \u043e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430, \u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u2014 \u0445\u0432\u043e\u0441\u0442\u043e\u043c (<em>tail<\/em>). \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 null-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0433\u0434\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0432 \u043e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0445\u0430\u043e\u0442\u0438\u0447\u043d\u043e \u0438 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u0443\u0437\u043b\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0441\u0441\u044b\u043b\u043e\u043a. \u0417\u0430 \u0441\u0447\u0451\u0442 \u044d\u0442\u043e\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0432 \u043e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043e\u0434\u043d\u0430\u043a\u043e, \u0434\u043e\u0441\u0442\u0443\u043f \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0432 \u043e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u043d\u0435\u0442.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 <strong>\u0434\u0432\u0443\u0441\u0432\u044f\u0437\u043d\u044b\u0435 \u0441\u043f\u0438\u0441\u043a\u0438<\/strong>: \u0432 \u043d\u0438\u0445 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0435\u0441\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0438 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439, \u0438 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435. \u0415\u0441\u0442\u044c \u0435\u0449\u0451 <strong>\u043a\u043e\u043b\u044c\u0446\u0435\u0432\u043e\u0439 \u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/strong> \u2014 \u0443 \u043d\u0435\u0433\u043e <strong>\u0445\u0432\u043e\u0441\u0442<\/strong> (\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0443\u0437\u0435\u043b) \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <strong>\u0433\u043e\u043b\u043e\u0432\u0443<\/strong> (\u043f\u0435\u0440\u0432\u044b\u0439 \u0443\u0437\u0435\u043b).<\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0443\u0437\u043b\u0430 \u0441 \u0447\u0438\u0441\u043b\u043e\u043c 99 \u0438\u0437 \u043e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b54\/54f\/ea7\/b5454fea7894775747f1217df1746f22.png\" width=\"1040\" height=\"505\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b54\/54f\/ea7\/b5454fea7894775747f1217df1746f22.png\"\/><\/figure>\n<p>\u0421\u0432\u044f\u0437\u043d\u044b\u0435 \u0441\u043f\u0438\u0441\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0435\u043a\u0430 \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 (\u0437\u0434\u0435\u0441\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0432\u044f\u0437\u043d\u044b\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u044b).<\/p>\n<p><strong>\u0421\u0442\u0435\u043a<\/strong><\/p>\n<ul>\n<li>\n<p>\u044d\u0442\u043e <strong>LIFO<\/strong>-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (<a href=\"https:\/\/ru.wikipedia.org\/wiki\/LIFO\" rel=\"noopener noreferrer nofollow\">last in, first out<\/a>)<\/p>\n<\/li>\n<li>\n<p>\u0433\u043e\u043b\u043e\u0432\u0430 \u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430, \u043b\u0435\u0436\u0430\u0449\u0435\u0433\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0442\u0435\u043a\u0430, \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041e\u0447\u0435\u0440\u0435\u0434\u044c<\/strong><\/p>\n<ul>\n<li>\n<p>\u044d\u0442\u043e <strong>FIFO<\/strong>-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (<a href=\"https:\/\/ru.wikipedia.org\/wiki\/FIFO\" rel=\"noopener noreferrer nofollow\">first in, first out<\/a>)<\/p>\n<\/li>\n<li>\n<p>\u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u0432\u0443\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u0437 \u0433\u043e\u043b\u043e\u0432\u044b, \u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0445\u0432\u043e\u0441\u0442<\/p>\n<\/li>\n<\/ul>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0d0\/c56\/76c\/0d0c5676c4ab0155794ac502348a3032.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0d0\/c56\/76c\/0d0c5676c4ab0155794ac502348a3032.gif\"\/><\/figure>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441\u043e \u0441\u0432\u044f\u0437\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/p>\n<\/th>\n<th>\n<p>\u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u043f\u043e\u0438\u0441\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(n)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(1)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(n)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u043e\u0434 \u0443\u0441\u043b\u043e\u0432\u0438\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(n)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0f9\/326\/8c5\/0f93268c5188212e80cbcf35bde8bc1a.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0f9\/326\/8c5\/0f93268c5188212e80cbcf35bde8bc1a.gif\"\/><\/figure>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430 Python:<\/p>\n<pre><code class=\"python\">class Node(object):     # \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 data \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c next \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0443\u0437\u0435\u043b     def __init__(self, data, next = None):         self.data = data;         self.next = next;      def setData(self, data):         self.data = data;              def getData(self):  # \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f data \u0438\u0437 \u0443\u0437\u043b\u0430         return self.data      def setNext(self, next):  # \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430         self.next = next      def getNext(self):  # \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430         return self.next      class LinkedList(object):     def __init__(self):  # \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c head \u0432 \u0441\u043f\u0438\u0441\u043a\u0435         self.head = None      def printLinkedList(self):  # \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u043c data \u0438\u0437 \u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430         temp = self.head         while(temp):             print(temp.data, end=' ')             temp = temp.next      def insertAtStart(self, data):  # \u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u0443\u0437\u043b\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e         newNode = Node(data)         newNode.next = self.head         self.head = newNode              def insertBetween(self, previousNode, data):  # \u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u0443\u0437\u043b\u0430 \u043f\u043e\u0441\u043b\u0435 previousNode         if (previousNode.next is None):             print('Previous node should have next node!')         else:             newNode = Node(data)             newNode.next = previousNode.next             previousNode.next = newNode                  def insertAtEnd(self, data):  # \u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u0432 \u043a\u043e\u043d\u0435\u0446 \u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430         newNode = Node(data)         temp = self.head         while(temp.next != None):  # get last node             temp = temp.next         temp.next = newNode      def delete(self, data):  # \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e data \u0438\u043b\u0438 key         temp = self.head         if (temp.next is not None):  # \u0435\u0441\u043b\u0438 data\/key \u043d\u0430\u0439\u0434\u0435\u043d \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0443\u0437\u043b\u0435             if(temp.data == data):                 self.head = temp.next                 temp = None                 return             else:                 while(temp.next != None):  # \u0438\u043d\u0430\u0447\u0435 \u0438\u0441\u043a\u0430\u0442\u044c \u0432\u0441\u0435 \u0443\u0437\u043b\u044b                     if(temp.data == data):                         break                     prev = temp                       temp = temp.next                                  if temp == None:  # \u0435\u0441\u043b\u0438 \u0443\u0437\u0435\u043b \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d                     return                                  prev.next = temp.next                 return                  # \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a     def search(self, node, data):         if node == None:             return False         if node.data == data:             return True         return self.search(node.getNext(), data)  if __name__ == '__main__':     List = LinkedList()     List.head = Node(1)  # \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0443\u0437\u0435\u043b - head     node2 = Node(2)     List.head.setNext(node2)  # \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0443\u0437\u0435\u043b --> node2     node3 = Node(3)     node2.setNext(node3)  # \u043f\u043e\u0441\u043b\u0435 node2 \u0438\u0434\u0451\u0442 node3     List.insertAtStart(4)  # \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c node4 \u0432\u043d\u0430\u0447\u0430\u043b\u043e, \u0441\u0435\u0439\u0447\u0430\u0441: 4 1 2 3     List.insertBetween(node2, 5)  # \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c node5 \u043f\u043e\u0441\u043b\u0435 node2, \u0441\u0435\u0439\u0447\u0430\u0441: 4 1 2 5 3 6      List.insertAtEnd(6)  # \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c 6 \u0432 \u043a\u043e\u043d\u0435\u0446     List.printLinkedList()      List.delete(3)  # \u0443\u0434\u0430\u043b\u044f\u0435\u043c 3, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c: 4 1 2 5 6      List.printLinkedList()      print(List.search(List.head, 1)) <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9f5\/81c\/1eb\/9f581c1ebbb26963d5a65e72b65ed91c.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9f5\/81c\/1eb\/9f581c1ebbb26963d5a65e72b65ed91c.gif\"\/><\/figure>\n<h3>\u0421\u0442\u0435\u043a<\/h3>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/eed\/555\/772\/eed555772e766285a45c9061faab8fe0.png\" alt=\"\u0421\u0442\u0435\u043a\" width=\"391\" height=\"281\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/eed\/555\/772\/eed555772e766285a45c9061faab8fe0.png\"\/><\/p>\n<div><figcaption>\u0421\u0442\u0435\u043a<\/figcaption><\/div>\n<\/figure>\n<p><strong>\u0421\u0442\u0435\u043a<\/strong> \u2014 \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0435\u0435 \u043d\u0430\u0447\u0430\u043b\u0435<a href=\"https:\/\/uproger.com\/bolshaya-shpargalka-po-algoritmam-s-sobesedovanij\/\" rel=\"noopener noreferrer nofollow\">.<\/a> \u041e\u043d\u0430 \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u0441\u0442\u043e\u043f\u043a\u0443 \u043a\u043d\u0438\u0433: \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u043a\u043d\u0438\u0433\u0443 \u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u0441\u0442\u0435\u043a\u0430, \u0441\u043f\u0435\u0440\u0432\u0430 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0443\u0431\u0440\u0430\u0442\u044c \u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u0441\u0432\u0435\u0440\u0445\u0443.<\/p>\n<p>\u0421\u0442\u0435\u043a \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 <strong>LIFO<\/strong> (<strong>L<\/strong>ast <strong>I<\/strong>n <strong>F<\/strong>irst <strong>O<\/strong>ut, &#171;\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u043f\u0440\u0438\u0448\u0435\u043b \u2014 \u043f\u0435\u0440\u0432\u044b\u043c \u0432\u044b\u0448\u0435\u043b&#187;)\u200a, \u0442\u043e \u0435\u0441\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043b\u0430\u0434\u0443\u0442\u0441\u044f \u043d\u0430\u0432\u0435\u0440\u0445 \u0438 \u0441\u0432\u0435\u0440\u0445\u0443 \u0436\u0435 \u0431\u0435\u0440\u0443\u0442\u0441\u044f. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0432 \u0441\u0442\u0435\u043a, \u043f\u0435\u0440\u0432\u044b\u043c \u0432\u044b\u0439\u0434\u0435\u0442 \u0438\u0437 \u043d\u0435\u0433\u043e.<\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0441\u0442\u0435\u043a\u0430 \u0443\u0439\u043c\u0430 \u2014 \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0435, \u043d\u0430 \u043e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435, \u043d\u0430 \u0434\u0432\u0443\u0441\u0432\u044f\u0437\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u0438 \u0442.\u0434. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0435\u0447\u044c \u0431\u0443\u0434\u0435\u0442 \u0438\u0434\u0442\u0438 \u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0435\u043a\u0430 \u043d\u0430 \u043e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435.<\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0441\u0442\u0435\u043a \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0441\u0442\u0435\u043a\u0430, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 \u0441\u0442\u0435\u043a.<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0441\u0442\u0435\u043a \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0441\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442. \u041a\u043e\u0433\u0434\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0441\u0442\u0435\u043a\u0430, \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0441\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442. \u0415\u0441\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0435\u043a\u0430, \u0442\u043e \u0441\u0442\u0435\u043a \u043f\u0443\u0441\u0442.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f2d\/c06\/fee\/f2dc06feee97d19caf5f455ade63c192.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f2d\/c06\/fee\/f2dc06feee97d19caf5f455ade63c192.gif\"\/><\/figure>\n<p> \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0441\u0442\u0435\u043a\u0430: <\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/p>\n<\/th>\n<th>\n<p>\u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0441\u0442\u0435\u043a\u0430 (<em>push<\/em>)<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(1)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0441\u0442\u0435\u043a\u0430 (<em>pop<\/em>)<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(1)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0431\u0435\u0437 \u0435\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f (<em>peek<\/em>)<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(1)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0442\u0435\u043a\u0430 \u043d\u0430 \u043f\u0443\u0441\u0442\u043e\u0442\u0443 (<em>isEmpty<\/em>)<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(1)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d37\/fc2\/388\/d37fc23887f9933ec8953692045ebcd4.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d37\/fc2\/388\/d37fc23887f9933ec8953692045ebcd4.gif\"\/><\/figure>\n<p>\u0421\u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0435\u043a \u0432 Python, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u0430\u043a (\u0437\u0434\u0435\u0441\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e \u043d\u0435 \u0432 \u0442\u0435\u043c\u0435):<\/p>\n<pre><code class=\"python\">from typing import TypeVar, Generic, List T = TypeVar('T')  class Stack(Generic[T]): def __init__(self) -> None: self._container: List[T] = []  def push(self, item: T) -> None: self._container.append(item)  def pop(self) -> T: return self._container.pop()  def __repr__(self) -> str: return repr(self._container) <\/code><\/pre>\n<p>\u0421\u0442\u0435\u043a\u0438 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043e \u0445\u0430\u043d\u043e\u0439\u0441\u043a\u0438\u0445 \u0431\u0430\u0448\u043d\u044f\u0445. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0434\u0438\u0441\u043a \u043d\u0430 \u0431\u0430\u0448\u043d\u044e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e <em>push<\/em>. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0434\u0438\u0441\u043a \u0441 \u043e\u0434\u043d\u043e\u0439 \u0431\u0430\u0448\u043d\u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c \u0435\u0433\u043e \u0441 \u043f\u0435\u0440\u0432\u043e\u0439 (<em>pop<\/em>) \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u0442\u043e\u0440\u0443\u044e (<em>push<\/em>). \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0431\u0430\u0448\u043d\u0438 \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u044b <code>Stack<\/code> \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u0438\u0437 \u043d\u0438\u0445 \u0434\u0438\u0441\u043a\u0430\u043c\u0438:<\/p>\n<pre><code class=\"python\">num_discs: int = 3 tower_a: Stack[int] = Stack() tower_b: Stack[int] = Stack() tower_c: Stack[int] = Stack() for i in range(1, num_discs + 1): tower_a.push(i) <\/code><\/pre>\n<p>\u041d\u0443 \u0438 \u0432\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>hanoi()<\/code>, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0430\u044f \u0437\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0434\u0438\u0441\u043a\u043e\u0432 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0431\u0430\u0448\u043d\u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u0440\u0435\u0442\u044c\u044e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0431\u0430\u0448\u043d\u044e:<\/p>\n<pre><code class=\"python\">def hanoi(begin: Stack[int], end: Stack[int], temp: Stack[int], n: int) -> None: if n == 1: end.push(begin.pop()) else: hanoi(begin, temp, end, n \u2014 1) hanoi(begin, end, temp, 1) hanoi(temp, end, begin, n - 1) <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>hanoi()<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0431\u0430\u0448\u043d\u0438 <code>tower_a<\/code>, <code>tower_b<\/code> \u0438 <code>tower_c<\/code>, \u0438 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0434\u0438\u0441\u043a\u0438 \u0431\u044b\u043b\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u044b.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/88f\/917\/846\/88f917846e2eaf645ef031db52bfe518.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/88f\/917\/846\/88f917846e2eaf645ef031db52bfe518.gif\"\/><\/figure>\n<h3>\u041e\u0447\u0435\u0440\u0435\u0434\u044c<\/h3>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/628\/258\/727\/628258727c4094ba9c353c2d393d62e0.png\" alt=\"\u041e\u0447\u0435\u0440\u0435\u0434\u044c\" width=\"300\" height=\"196\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/628\/258\/727\/628258727c4094ba9c353c2d393d62e0.png\"\/><\/p>\n<div><figcaption>\u041e\u0447\u0435\u0440\u0435\u0434\u044c<\/figcaption><\/div>\n<\/figure>\n<p>\u042d\u0442\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0432 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u043e\u043c \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0435. \u041f\u0435\u0440\u0432\u044b\u043c \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u044e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0442\u043e \u043f\u0440\u0438\u0448\u0435\u043b \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u2014 \u0432\u0441\u0435 \u043a\u0430\u043a \u0432 \u0436\u0438\u0437\u043d\u0438.<\/p>\n<p>\u041e\u0447\u0435\u0440\u0435\u0434\u044c \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 <strong>FIFO<\/strong> (<strong>F<\/strong>irst <strong>I<\/strong>n <strong>F<\/strong>irst <strong>O<\/strong>ut, &#171;\u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u0438\u0448\u0435\u043b \u2014 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u044b\u0448\u0435\u043b&#187;). \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0431\u044b\u043b\u0438 \u0443\u0431\u0440\u0430\u043d\u044b \u0432\u0441\u0435 \u0440\u0430\u043d\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p><strong>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u043a\u043e\u043d\u0435\u0446 (<code>enqueue<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 (<code>dequeue<\/code>)<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c:<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c<\/p>\n<\/th>\n<th>\n<p>\u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/th>\n<th>\n<p>\u0425\u0443\u0434\u0448\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041f\u043e\u0438\u0441\u043a<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(n)<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(n)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0412\u0441\u0442\u0430\u0432\u043a\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(1)<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(1)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(1)<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(1)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0fa\/4db\/c40\/0fa4dbc401d8e6da9a995dbf10c91206.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0fa\/4db\/c40\/0fa4dbc401d8e6da9a995dbf10c91206.gif\"\/><\/figure>\n<p>\u041e\u0447\u0435\u0440\u0435\u0434\u044c \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">from typing import TypeVar, Generic, Deque T = TypeVar('T')  class Queue(Generic[T]): def __init__(self) -> None: self._container: Deque[T] = Deque()  @property def empty(self) -> bool: return not self._container # \u043d\u0435 \u0440\u0430\u0432\u043d\u043e True \u0434\u043b\u044f \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430  def push(self, item: T) -> None: self._container.append(item)  def pop(self) -> T: return self._container.popleft() # FIFO  def __repr__(self) -> str: return repr(self._container) <\/code><\/pre>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u0432 \u044d\u0442\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 <code>Queue<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f <code>deque<\/code>, \u0430 \u043d\u0435 <code>list<\/code>. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u043e\u0442\u043a\u0443\u0434\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 <code>pop<\/code>. \u0412 \u0441\u0442\u0435\u043a\u0435 \u043c\u044b \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441 \u043f\u0440\u0430\u0432\u043e\u0433\u043e \u043a\u043e\u043d\u0446\u0430 \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0438\u0445 \u0442\u043e\u0436\u0435 \u0441\u043f\u0440\u0430\u0432\u0430. \u0412 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043c\u044b \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u043f\u0440\u0430\u0432\u0430, \u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0441\u043b\u0435\u0432\u0430. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 <code>list<\/code> \u0432 Python \u0438\u043c\u0435\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>pop<\/code> \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0432\u0430, \u043d\u043e \u043d\u0435 \u0441\u043b\u0435\u0432\u0430. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 <code>deque<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043b\u044e\u0431\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>popleft()<\/code>, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435\u0442 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u0430 \u0432 <code>list<\/code>.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8da\/d33\/8e9\/8dad338e9eb3a3b3a6bfb53c56dc3b6f.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8da\/d33\/8e9\/8dad338e9eb3a3b3a6bfb53c56dc3b6f.gif\"\/><\/figure>\n<h3>\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/df8\/d0d\/93b\/df8d0d93b3211b10d56cee870f6c3cab.png\" width=\"1024\" height=\"731\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/df8\/d0d\/93b\/df8d0d93b3211b10d56cee870f6c3cab.png\"\/><\/figure>\n<p><strong>\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e<\/strong> \u0445\u0440\u0430\u043d\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0435\u0437 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430 (\u043d\u0435 \u0432\u0435\u0437\u0434\u0435, \u0432 C++ \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e), \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044f \u0438\u0445 (\u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u043c\u0443\u043b\u044c\u0442\u0438\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, \u0442\u0430\u043c \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u044b). \u041e\u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b: \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0436\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043a \u0434\u0432\u0443\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u043c \u0441\u0440\u0430\u0437\u0443.<\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u0434\u0432\u0443\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432, \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u044f \u0438\u0445 \u0432 \u043e\u0434\u043d\u043e (\u0431\u0435\u0437 \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432)<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0434\u0432\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0438 \u200a\u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0438\u0437 \u0442\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u043e\u0431\u043e\u0438\u0445 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u0445<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0437\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435, \u043d\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0434\u0430\u0435\u0442 \u0431\u0443\u043b\u0435\u0432\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043b\u0438 \u043e\u0434\u043d\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<\/ul>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6fb\/eb2\/fe1\/6fbeb2fe1c89c81de530cdc249a4de38.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6fb\/eb2\/fe1\/6fbeb2fe1c89c81de530cdc249a4de38.gif\"\/><\/figure>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/p>\n<\/th>\n<th>\n<p>\u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u043f\u043e\u0438\u0441\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(1)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(1)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 (\u0434\u043b\u044f \u043d\u0435\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430)<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(1)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/618\/c8e\/437\/618c8e437bc62c16d8a524c445755fa5.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/618\/c8e\/437\/618c8e437bc62c16d8a524c445755fa5.gif\"\/><\/figure>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u043c\u0438 \u0432 Python \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u043f\u0440\u0438\u044f\u0442\u043d\u043e:<\/p>\n<pre><code class=\"python\">a = set([1, 2, 1, 3, 4]) b = {4, 4, 5, 6} c = {1, 2}  print(a, b, c)   # {1, 2, 3, 4} {4, 5, 6} {1, 2}  print(c.issubset(a), c &lt;= a)   # True True  print(a.union(b), a | b)   # {1, 2, 3, 4, 5, 6} {1, 2, 3, 4, 5, 6}  print(a.intersection(b), a &amp; b)   # {4} {4}  print(a.difference(b), a - b)   # {1, 2, 3} {1, 2, 3}  print(c)  # {1, 2} c.add(3)   print(c)  # {1, 2, 3} c.remove(2) print(c)  # {1, 3} c.pop() print(c)  # {3} c.clear() print(c)  # set() <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/135\/088\/2cf\/1350882cf305fd04978846d5a311e9cf.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/135\/088\/2cf\/1350882cf305fd04978846d5a311e9cf.gif\"\/><\/figure>\n<h3>Map (\u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432)<\/h3>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a8f\/0da\/dac\/a8f0dadac9ca582c37d56886e406aae4.png\" alt=\"Map\" width=\"432\" height=\"272\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a8f\/0da\/dac\/a8f0dadac9ca582c37d56886e406aae4.png\"\/><\/p>\n<div><figcaption>Map<\/figcaption><\/div>\n<\/figure>\n<p><strong>Map<\/strong> \u2014 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0445\u0440\u0430\u043d\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u0440\u0430\u0445 \u043a\u043b\u044e\u0447\/\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u044e\u0447 \u0443\u043d\u0438\u043a\u0430\u043b\u0435\u043d. \u0418\u043d\u043e\u0433\u0434\u0430 \u0435\u0435 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0438\u043b\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u043c. Map \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041d\u0435\u0440\u0435\u0434\u043a\u043e \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0443 Map \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c Map \u043a\u0430\u043a \u043e\u0431\u0451\u0440\u0442\u043a\u0443 \u043d\u0430\u0434 \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0449\u0438\u043c\u0438 \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043d\u0438\u0436\u0435.<\/p>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 Map (\u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445):<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/p>\n<\/th>\n<th>\n<p>\u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e(1)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e \u043a\u043b\u044e\u0447\u0443<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e(1)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043b\u044e\u0447\u0443<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e(1)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043b\u044e\u0447\u0443<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e(1)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f26\/ba4\/e49\/f26ba4e49bb2aab81d017e7375235e96.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f26\/ba4\/e49\/f26ba4e49bb2aab81d017e7375235e96.gif\"\/><\/figure>\n<h3>\u0425\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/h3>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7e9\/bf4\/395\/7e9bf43953a58a26dda6e2f8d747524e.png\" alt=\"\u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430\" width=\"315\" height=\"230\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7e9\/bf4\/395\/7e9bf43953a58a26dda6e2f8d747524e.png\"\/><\/p>\n<div><figcaption>\u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/figcaption><\/div>\n<\/figure>\n<p><strong>\u0425\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/strong> \u2014 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0430\u0440\u044b \u043a\u043b\u044e\u0447\/\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0438\u0437 \u0431\u043b\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0425\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Map (\u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439).<\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0432\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0414\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0432\u0432\u043e\u0434\u0430 \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0447\u0438\u0441\u043b\u043e. \u0415\u0441\u043b\u0438 \u0434\u0432\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0432\u043e\u0434\u0430 \u0445\u0435\u0448\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u044f. \u041a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c, \u043e\u043d\u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0430\u0434\u0440\u0435\u0441 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0447\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u0432\u043e\u0434\u0438\u0442\u0435 \u043f\u0430\u0440\u0443 \u043a\u043b\u044e\u0447\/\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043a\u043b\u044e\u0447 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u043e. \u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043b\u044e\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e. \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043d\u043e\u0432\u0430 \u0432\u0432\u0435\u0434\u0435\u0442\u0435 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043b\u044e\u0447, \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0435\u0433\u043e \u0438 \u0432\u0435\u0440\u043d\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0417\u0430\u0442\u0435\u043c \u044d\u0442\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e O(1).<\/p>\n<p>\u0425\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432. \u041e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0434\u0435\u0440\u0435\u0432\u044c\u044f\u0445. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/p>\n<\/th>\n<th>\n<p>\u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e(1)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e \u043a\u043b\u044e\u0447\u0443<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e(1)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043b\u044e\u0447\u0443<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e(1)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043b\u044e\u0447\u0443<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e(1)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e10\/fa1\/06d\/e10fa106df268c633517f7faa6e33812.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e10\/fa1\/06d\/e10fa106df268c633517f7faa6e33812.gif\"\/><\/figure>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043e \u0441\u0430\u043c\u044b\u043c\u0438 \u0432\u0430\u0436\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438:<\/p>\n<pre><code class=\"python\">class HashTable:     def __init__(self):         self.hashTable = [[],] * 10      def checkPrime(self, n):         if n == 1 or n == 0:             return 0         for i in range(2, n\/\/2):             if n % i == 0:                 return 0         return 1      def getPrime(self, n):         if n % 2 == 0:             n = n + 1         while not self.checkPrime(n):             n += 2         return n      def hashFunction(self, key):         capacity = self.getPrime(10)         return key % capacity      def insertData(self, key, data):         index = self.hashFunction(key)         self.hashTable[index] = [key, data]      def removeData(self, key):         index = self.hashFunction(key)         self.hashTable[index] = 0      def __str__(self):         return str(self.hashTable)   hash_table = HashTable()  hash_table.insertData(123, \"apple\") hash_table.insertData(432, \"mango\") hash_table.insertData(213, \"banana\") hash_table.insertData(654, \"guava\")  print(hash_table) hash_table.removeData(123) print(hash_table)  # [[], [], [123, 'apple'], [432, 'mango'], [213, 'banana'], [654, 'guava'], [], [], [], []] # [[], [], 0, [432, 'mango'], [213, 'banana'], [654, 'guava'], [], [], [], []] <\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043f\u043e\u0435\u0445\u0430\u043b\u0438 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u2014 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u043c\u0443 \u0434\u0435\u0440\u0435\u0432\u0443<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/346\/cd7\/c25\/346cd7c25d9ae0ee3d30b3302081c969.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/346\/cd7\/c25\/346cd7c25d9ae0ee3d30b3302081c969.gif\"\/><\/figure>\n<h3>\u0414\u0432\u043e\u0438\u0447\u043d\u043e\u0435 (\u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0435) \u0434\u0435\u0440\u0435\u0432\u043e<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/23b\/6aa\/488\/23b6aa48837e39cc15d6d5fe7ad408c5.png\" width=\"1437\" height=\"1198\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/23b\/6aa\/488\/23b6aa48837e39cc15d6d5fe7ad408c5.png\"\/><\/figure>\n<p><strong>\u0414\u0435\u0440\u0435\u0432\u043e<\/strong> \u2014 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0438\u0437 \u0443\u0437\u043b\u043e\u0432. \u0415\u0439 \u043f\u0440\u0438\u0441\u0443\u0449\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<ul>\n<li>\n<p>\u041a\u0430\u0436\u0434\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0438\u043c\u0435\u0435\u0442 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0443\u0437\u0435\u043b (\u0432\u0432\u0435\u0440\u0445\u0443)<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0443\u0437\u0435\u043b \u0438\u043c\u0435\u0435\u0442 0 \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0443\u0437\u0435\u043b \u0438\u043c\u0435\u0435\u0442 0 \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432, \u0438 \u0442.\u0434.<\/p>\n<\/li>\n<\/ul>\n<p>\u0423 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u043f\u043e\u0438\u0441\u043a\u0430 \u0435\u0441\u0442\u044c 2 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<ul>\n<li>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0438\u043c\u0435\u0435\u0442 \u0434\u043e 2 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432 (\u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432)<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u043c\u0435\u043d\u044c\u0448\u0435 \u0441\u0432\u043e\u0438\u0445 \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432 \u0441\u043f\u0440\u0430\u0432\u0430, \u0430 \u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043c\u043a\u0438 \u0441\u043b\u0435\u0432\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0435\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0432\u043e\u0438\u0447\u043d\u044b\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b. \u041e\u043d\u0438 \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0442\u0430\u043a, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0443 \u043e\u0431\u0449\u0435\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f35\/ae3\/4ae\/f35ae34ae0b647d2229003f24a720998.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f35\/ae3\/4ae\/f35ae34ae0b647d2229003f24a720998.gif\"\/><\/figure>\n<p><strong>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u043c \u0434\u0435\u0440\u0435\u0432\u043e\u043c:<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/p>\n<\/th>\n<th>\n<p>\u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/th>\n<th>\n<p>\u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u043f\u043e\u0438\u0441\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(log n)<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(n)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(log n)<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(n)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(log n)<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(n)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/37f\/af6\/c35\/37faf6c35c30aed0e6324cd4d91332ae.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/37f\/af6\/c35\/37faf6c35c30aed0e6324cd4d91332ae.gif\"\/><\/figure>\n<p>\u0427\u0442\u043e \u0436, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430:<\/p>\n<pre><code class=\"python\">class BinaryTreeNode:     def __init__(self, value, parent=None):         self.left = None  # \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043b\u0435\u0432\u044b\u0439 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0443\u0437\u0435\u043b         self.right = None  # \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0440\u0430\u0432\u044b\u0439 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0443\u0437\u0435\u043b         self.parent = parent  # \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f         self.value = value  # \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c. \u0412\u043e\u043e\u0431\u0449\u0435, \u0443 \u043d\u0430\u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u0442\u0430\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438: \u043f\u043e\u0438\u0441\u043a \u0443\u0437\u043b\u0430, \u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0443\u0437\u043b\u0430, \u043e\u0431\u0445\u043e\u0434 \u0434\u0435\u0440\u0435\u0432\u0430.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u0443\u0437\u043b\u0430. \u0415\u0441\u043b\u0438 \u0438\u0441\u043a\u043e\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u043f\u043e\u0438\u0441\u043a\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u0437\u043b\u0430, \u0442\u043e \u043e\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043b\u0435\u0432\u043e\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0435. \u0418\u0441\u043a\u043e\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u0437\u043b\u0430, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0440\u0430\u0432\u043e\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0435. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u0434\u043e\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043f\u043e\u0438\u0441\u043a\u0430:<\/p>\n<pre><code class=\"python\">    def find_node(root, value):         node = self         while node:             if value == node.value:                 return node             if value &lt; node.value:                 node = node.left             if value > node.value:                 node = node.right         return None <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/37c\/894\/1c9\/37c8941c9f3f0f4891853e03c1ce9322.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/37c\/894\/1c9\/37c8941c9f3f0f4891853e03c1ce9322.gif\"\/><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c <strong>\u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u0443\u0437\u043b\u0430<\/strong>. \u0412\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u043d\u044c\u0448\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u0437\u043b\u0430 \u043d\u0430\u0434\u043e \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u0432 \u043b\u0435\u0432\u043e\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0435, \u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u2014 \u0432 \u043f\u0440\u0430\u0432\u043e\u043c. \u0427\u0442\u043e\u0431\u044b \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0443\u0437\u0435\u043b, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0443\u0437\u0435\u043b \u043d\u0435 \u043f\u0443\u0441\u0442. \u0414\u0430\u043b\u0435\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u0432\u0430 \u043f\u0443\u0442\u0438:<\/p>\n<ul>\n<li>\n<p>\u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0430\u043a, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u043c. \u041f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u043e\u0433\u043e \u0438\u043b\u0438 \u043b\u0435\u0432\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u043b\u0438 \u0443\u0437\u0435\u043b \u043f\u0443\u0441\u0442, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0443\u0437\u0435\u043b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u0438\u0441\u043a\u0430:<\/p>\n<pre><code class=\"python\">    def insert_node(self, value):         return self._insert_node(value, self)      def _insert_node(self, value, parent_node):         if value &lt; parent_node.value:             if parent_node.left is None:                 parent_node.left = BinaryTreeNode(value, parent_node)             else:                 self._insert_node(value, parent_node.left)         elif value > parent_node.value:             if parent_node.right is None:                 parent_node.right = BinaryTreeNode(value, parent_node)             else:                 self._insert_node(value, parent_node.right) <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/657\/b26\/fb3\/657b26fb3216156f541ab0c9670fe5f4.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/657\/b26\/fb3\/657b26fb3216156f541ab0c9670fe5f4.gif\"\/><\/figure>\n<p><strong>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0443\u0437\u043b\u0430.<\/strong> \u0427\u0442\u043e\u0431\u044b \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u0432\u044f\u0437\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435, \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0435\u0433\u043e \u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0432 \u043f\u043e\u043b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0435.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0443\u0437\u0435\u043b \u0438\u043b\u0438 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u043f\u043e\u0438\u0441\u043a\u0430, \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442 \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0434\u0432\u0443\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>\u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043b\u0435\u0432\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0438\u043b\u0438 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u0440\u0430\u0432\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0438\u043b\u0438 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bb7\/98a\/c30\/bb798ac30343daf2c3f0e8b30d56afbe.png\" width=\"3524\" height=\"1990\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bb7\/98a\/c30\/bb798ac30343daf2c3f0e8b30d56afbe.png\"\/><\/figure>\n<p>\u041e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430. \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432 \u043a\u043e\u0434\u0435 \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442:<\/p>\n<pre><code class=\"python\">    def remove_node(self, value):         return self._remove_node(value, self)      def _remove_node(self, value, node):         if node is None:             return None          if value &lt; node.value:             node.left = self._remove_node(value, node.left)             return node         elif value > node.value:             node.right = self._remove_node(value, node.right)             return node         else:             if node.left is None:                 return node.right             elif node.right is None:                 return node.left             else:                 original = node                 node = node.right                 while node.left:                     node = node.left                 node.right = self._remove_min(original.right)                 node.left = original.left                 return node <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1a1\/34f\/871\/1a134f871acabcb0ab5c85df5f466a49.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1a1\/34f\/871\/1a134f871acabcb0ab5c85df5f466a49.gif\"\/><\/figure>\n<p><strong>\u041e\u0431\u0445\u043e\u0434 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432<\/strong>. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 \u0434\u0435\u0440\u0435\u0432\u043e\u043c \u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0435\u0433\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u0444\u0430\u0439\u043b \u0438\u043b\u0438 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0432 \u043f\u0435\u0447\u0430\u0442\u044c, \u043d\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u0438\u0431\u0435\u0433\u0430\u0435\u043c \u043a <strong>\u043e\u0431\u0445\u043e\u0434\u0443 \u0434\u0435\u0440\u0435\u0432\u0430<\/strong> \u2014 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0435\u0434\u0438\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0432\u0435\u0440\u0448\u0438\u043d \u0434\u0435\u0440\u0435\u0432\u0430.<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0430\u043a\u0438\u0435 3 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043e\u0431\u0445\u043e\u0434\u0430 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432:<\/p>\n<ul>\n<li>\n<p><strong>\u041f\u0440\u044f\u043c\u043e\u0439 \u043e\u0431\u0445\u043e\u0434 (\u041a\u041b\u041f)<\/strong>: \u043a\u043e\u0440\u0435\u043d\u044c \u2192 \u043b\u0435\u0432\u043e\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u043e \u2192 \u043f\u0440\u0430\u0432\u043e\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u043e<\/p>\n<\/li>\n<li>\n<p><strong>\u0426\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u0445\u043e\u0434 (\u041b\u041a\u041f)<\/strong>: \u043b\u0435\u0432\u043e\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u043e \u2192 \u043a\u043e\u0440\u0435\u043d\u044c \u2192 \u043f\u0440\u0430\u0432\u043e\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u043e<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043e\u0431\u0445\u043e\u0434 (\u041b\u041f\u041a)<\/strong>: \u043b\u0435\u0432\u043e\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u043e \u2192 \u043f\u0440\u0430\u0432\u043e\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u043e \u2192 \u043a\u043e\u0440\u0435\u043d\u044c<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a\u0438\u0435 \u043e\u0431\u0445\u043e\u0434\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f <strong>\u043f\u043e\u0438\u0441\u043a\u043e\u043c \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443<\/strong>. \u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044c\u0441\u044f \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e \u0432\u043d\u0438\u0437 \u043f\u043e \u0434\u0435\u0440\u0435\u0432\u0443 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0440\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c\u0443 \u0443\u0437\u043b\u0443 \u2014 \u0443\u0437\u043b\u0443 \u043d\u0430 \u0442\u043e\u043c \u0436\u0435 \u0443\u0440\u043e\u0432\u043d\u0435. \u0415\u0449\u0435 \u0435\u0441\u0442\u044c <strong>\u043f\u043e\u0438\u0441\u043a \u0432 \u0448\u0438\u0440\u0438\u043d\u0443<\/strong> \u2014 \u043e\u0431\u0445\u043e\u0434 \u0443\u0437\u043b\u043e\u0432 \u0434\u0435\u0440\u0435\u0432\u0430 \u043f\u043e \u0443\u0440\u043e\u0432\u043d\u044f\u043c: \u043e\u0442 \u043a\u043e\u0440\u043d\u044f \u0438 \u0434\u0430\u043b\u0435\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/771\/e26\/543\/771e26543e25e2cd35b739771fff289e.png\" width=\"2618\" height=\"3068\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/771\/e26\/543\/771e26543e25e2cd35b739771fff289e.png\"\/><\/figure>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u043c\u043e\u0436\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0438\u043b\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438, \u0438\u043b\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0435\u043a\u0430. \u0410 \u043f\u043e\u0438\u0441\u043a \u0432 \u0448\u0438\u0440\u0438\u043d\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0437\u0430 \u0441\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u0438:<\/p>\n<pre><code class=\"python\">    def traverse_recursive(node):         if node is not None:             print(f\"node = {node.value}\")             traverse_recursive(node.left)             traverse_recursive(node.right)      def traverse_with_stack(root):         stack = []         stack.append(root)         while len(stack) > 0:             current_node = stack.pop()             print(f\"node = {current_node.value}\")             if current_node.right is not None:                 stack.append(current_node.right)             if current_node.left is not None:                 stack.append(current_node.left)      def traverse_with_queue(root):         queue = []         queue.append(root)         while len(queue) > 0:             current_node = queue.pop(0)             print(f\"node = {current_node.value}\")             if current_node.left:                 queue.append(current_node.left)             if current_node.right:                 queue.append(current_node.right) <\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043c\u044b \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0432\u0430\u0436\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u2014 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u043c\u0443 \u0434\u0435\u0440\u0435\u0432\u0443.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3f3\/f7c\/631\/3f3f7c631eafbdc8bf9e3254fc7e9a4b.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3f3\/f7c\/631\/3f3f7c631eafbdc8bf9e3254fc7e9a4b.gif\"\/><\/figure>\n<h3>\u041f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e (\u0431\u043e\u0440)<\/h3>\n<p>(\u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0443\u0437\u043b\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e 1 \u0431\u0443\u043a\u0432\u0435, \u0441\u043b\u043e\u0432\u0430 \u0442\u0443\u0442 \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438)<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b76\/5f0\/bf1\/b765f0bf11ac53449d0be29466c687a7.png\" width=\"800\" height=\"750\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b76\/5f0\/bf1\/b765f0bf11ac53449d0be29466c687a7.png\"\/><\/figure>\n<p><strong>\u041f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u0435 (\u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0435) \u0434\u0435\u0440\u0435\u0432\u043e<\/strong> (\u0431\u043e\u0440) \u2014 \u0440\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u0430 \u043f\u043e\u0438\u0441\u043a\u0430. \u041e\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043c\u0435\u0442\u043a\u0430\u0445, \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0443\u0437\u0435\u043b \u043d\u0430 \u0434\u0435\u0440\u0435\u0432\u0435. \u0422\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442, \u0447\u0442\u043e\u0431\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u043b\u043e\u0432\u0430 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u043d\u0438\u043c \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0432 \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u043c \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 1 \u0431\u0443\u043a\u0432\u0443 \u0441\u043b\u043e\u0432\u0430. \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u043e\u0432\u043e, \u043d\u0443\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0432\u0435\u0442\u0432\u044f\u043c \u0434\u0435\u0440\u0435\u0432\u0430, \u043f\u0440\u043e\u0445\u043e\u0434\u044f \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0431\u0443\u043a\u0432\u0435 \u0437\u0430 \u0440\u0430\u0437. \u0414\u0435\u0440\u0435\u0432\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u0435\u0442\u0432\u0438\u0442\u044c\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0431\u0443\u043a\u0432 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0432 \u043d\u0435\u043c \u0441\u043b\u043e\u0432 \u0438\u043b\u0438 \u043a\u043e\u0433\u0434\u0430 \u0441\u043b\u043e\u0432\u043e \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0431\u0443\u043a\u0432\u0443 (\u0434\u0430\u043d\u043d\u044b\u0435) \u0438 \u0431\u0443\u043b\u0435\u0432\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043e\u043d \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0432 \u0441\u043b\u043e\u0432\u0435.<\/p>\n<p>\u041f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447:<\/p>\n<ul>\n<li>\n<p><strong>\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a<\/strong>: \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u0432, \u0442\u043e \u0431\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043c\u0435\u0441\u0442\u0430, \u0447\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u043b\u0438 <code>set<\/code> \u0441\u0442\u0440\u043e\u043a<\/p>\n<\/li>\n<li>\n<p><strong>\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u0442\u0440\u043e\u043a<\/strong>: \u043f\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u043c\u0443 \u0431\u043e\u0440\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c <code>DFS<\/code>-\u043e\u043c \u0438 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u043a <strong>\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a<\/strong>: \u0432 \u0431\u043e\u0440 \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u043b\u043e\u0432\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<\/ul>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d16\/689\/b23\/d16689b232ad55271bcce80599bc612b.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d16\/689\/b23\/d16689b232ad55271bcce80599bc612b.gif\"\/><\/figure>\n<p>\u041f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u042d\u0442\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0434\u0435\u0440\u0435\u0432\u0430 \u0438 \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7be\/039\/4b2\/7be0394b2361cbf51ad74703c91290a6.png\" width=\"1021\" height=\"529\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7be\/039\/4b2\/7be0394b2361cbf51ad74703c91290a6.png\"\/><\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0435 \u0431\u0435\u0437 \u043b\u043e\u0436\u043a\u0438 \u0434\u0451\u0433\u0442\u044f, \u0432\u043e\u0442 2 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u043e\u0440\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430:<\/p>\n<ol>\n<li>\n<p>\u0411\u043e\u0440 \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u043b\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u0430 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0442\u0438\u043f (\u0441\u0442\u0440\u043e\u043a\u0438, \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u043b\u0438\u0431\u043e \u0447\u0438\u0441\u043b\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u043a\u0438). \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u043a \u0441\u0442\u0440\u043e\u043a\u0435<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0431\u043e\u0440\u0435, \u0430 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u0431\u0443\u0434\u0443\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0438, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043f\u0430\u043c\u044f\u0442\u0438 (\u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u0443 \u0441\u043b\u043e\u0432 \u043d\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0439 \u043f\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0443)<\/p>\n<\/li>\n<\/ol>\n<p>\u041a\u0430\u043a-\u0442\u043e \u0432\u043e\u0442 \u0442\u0430\u043a, \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0442\u0443\u0442 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0441\u0438\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u0435\u0445\u0430\u043b\u0438 \u043a \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0439 \u043a\u0443\u0447\u0435)<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/204\/a18\/a8b\/204a18a8b05045e1b91339336a03b778.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/204\/a18\/a8b\/204a18a8b05045e1b91339336a03b778.gif\"\/><\/figure>\n<h3>\u0414\u0432\u043e\u0438\u0447\u043d\u0430\u044f \u043a\u0443\u0447\u0430 (\u043f\u0438\u0440\u0430\u043c\u0438\u0434\u0430)<\/h3>\n<p>\u0414\u0432\u043e\u0438\u0447\u043d\u044b\u0435 \u043a\u0443\u0447\u0438 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7ae\/f94\/970\/7aef949702163d3358a80af438a18c6c.png\" alt=\"\u0414\u0432\u043e\u0438\u0447\u043d\u0430\u044f \u043a\u0443\u0447\u0430\" width=\"477\" height=\"212\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7ae\/f94\/970\/7aef949702163d3358a80af438a18c6c.png\"\/><\/p>\n<div><figcaption>\u0414\u0432\u043e\u0438\u0447\u043d\u0430\u044f \u043a\u0443\u0447\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0443\u0447\u0438 \u043d\u0430 \u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/de3\/f50\/1e2\/de3f501e2258acfa67708ae29dab9642.png\" width=\"1332\" height=\"445\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/de3\/f50\/1e2\/de3f501e2258acfa67708ae29dab9642.png\"\/><\/figure>\n<p><strong>\u0414\u0432\u043e\u0438\u0447\u043d\u0430\u044f \u043a\u0443\u0447\u0430<\/strong> \u2014 \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u043d\u0435\u0439 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0434\u0432\u0443\u0445 \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432. \u0422\u0430\u043a\u0436\u0435 \u043e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u043c \u0434\u0435\u0440\u0435\u0432\u043e\u043c: \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432 \u043d\u0435\u0439 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043d\u044f\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u0441\u0435 \u0443\u0440\u043e\u0432\u043d\u0438, \u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e.<\/p>\n<p>\u0414\u0432\u043e\u0438\u0447\u043d\u0430\u044f \u043a\u0443\u0447\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c <strong>\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439<\/strong> \u0438\u043b\u0438 <strong>\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439<\/strong>. \u0412 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u0443\u0447\u0435 \u043a\u043b\u044e\u0447 \u043b\u044e\u0431\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043b\u044e\u0447\u0435\u0439 \u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432 \u0438\u043b\u0438 \u0440\u0430\u0432\u0435\u043d \u0438\u043c. \u0412 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u0443\u0447\u0435 \u0432\u0441\u0435 \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442: \u043a\u043b\u044e\u0447 \u043b\u044e\u0431\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043b\u044e\u0447\u0435\u0439 \u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432 \u0438\u043b\u0438 \u0440\u0430\u0432\u0435\u043d \u0438\u043c.<\/p>\n<p>\u041f\u043e\u0440\u044f\u0434\u043e\u043a \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0432 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0439 \u043a\u0443\u0447\u0435 \u0432\u0430\u0436\u0435\u043d, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0443\u0437\u043b\u043e\u0432 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438 \u0442\u043e\u043c \u0436\u0435 \u0443\u0440\u043e\u0432\u043d\u0435.<\/p>\n<p><strong>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c:<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c<\/p>\n<\/th>\n<th>\n<p>\u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/th>\n<th>\n<p>\u0425\u0443\u0434\u0448\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041f\u043e\u0438\u0441\u043a<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(n)<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(n)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0412\u0441\u0442\u0430\u0432\u043a\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(1)<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(log n)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(log n)<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(log n)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/10f\/569\/4dd\/10f5694dd17994877307e95055b110d3.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/10f\/569\/4dd\/10f5694dd17994877307e95055b110d3.gif\"\/><\/figure>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0443 \u0434\u0432\u043e\u0438\u0447\u043d\u0443\u044e \u043a\u0443\u0447\u0443 \u043d\u0430 Python. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u0443\u0447\u0430 \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430, \u0442\u043e \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, &#8212; \u044d\u0442\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>currentSize<\/code>, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u0443\u0447\u0438.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <code>BinHeap<\/code>:<\/p>\n<pre><code class=\"python\">class BinHeap:     def __init__(self):         self.heapList = [0]         self.currentSize = 0 <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/10e\/8eb\/cbe\/10e8ebcbe280a2a0529e9b131a56c260.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/10e\/8eb\/cbe\/10e8ebcbe280a2a0529e9b131a56c260.gif\"\/><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>insert<\/code>. \u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043a \u043a\u043e\u043d\u0446\u0443 \u0441\u043f\u0438\u0441\u043a\u0430. \u0425\u043e\u0440\u043e\u0448\u0430\u044f \u043d\u043e\u0432\u043e\u0441\u0442\u044c \u2014 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u043d\u043e\u0442\u044b \u0434\u0435\u0440\u0435\u0432\u0430. \u041f\u043b\u043e\u0445\u0430\u044f \u2014 \u0432\u0435\u0441\u044c\u043c\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0430\u0440\u0443\u0448\u0438\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043a\u0443\u0447\u0438. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043d\u0430\u043c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441 \u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043a\u043e\u043c. \u0415\u0441\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u043c\u0438. \u0412\u043e\u0442 \u0442\u0443\u0442 \u043d\u0438\u0436\u0435 \u0432\u0438\u0434\u043d\u043e \u0441\u0435\u0440\u0438\u044e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0434\u043b\u044f \u201c\u043f\u0440\u043e\u0441\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f\u201d \u043d\u043e\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0430 \u0435\u0433\u043e \u0437\u0430\u043a\u043e\u043d\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0432 \u0434\u0435\u0440\u0435\u0432\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/98a\/b12\/894\/98ab12894bbfb09806c759f3af7bfa02.png\" width=\"559\" height=\"887\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/98a\/b12\/894\/98ab12894bbfb09806c759f3af7bfa02.png\"\/><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>insert<\/code>. \u0411\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u0443\u0436\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 <code>percUp<\/code>. \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432 \u0434\u0435\u0440\u0435\u0432\u043e \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, <code>percUp<\/code> \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u043a\u0430\u043a \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043e:<\/p>\n<pre><code class=\"python\">    def percUp(self,i):         while i \/\/ 2 > 0:           if self.heapList[i] &lt; self.heapList[i \/\/ 2]:              tmp = self.heapList[i \/\/ 2]              self.heapList[i \/\/ 2] = self.heapList[i]              self.heapList[i] = tmp           i = i \/\/ 2 <\/code><\/pre>\n<pre><code class=\"python\">    def insert(self,k):         self.heapList.append(k)         self.currentSize = self.currentSize + 1         self.percUp(self.currentSize) <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e54\/b21\/545\/e54b215456e47634e0883905e6a621ac.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e54\/b21\/545\/e54b215456e47634e0883905e6a621ac.gif\"\/><\/figure>\n<p>\u0421 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>insert<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 <code>delMin<\/code>. \u0422\u0430\u043a \u043a\u0430\u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043a\u0443\u0447\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u0440\u0435\u043d\u044c \u0431\u044b\u043b \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0430, \u043d\u0430\u0439\u0442\u0438 \u0435\u0451 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e. \u0421\u043b\u043e\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c <code>delMin<\/code> &#8212; \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043a\u0443\u0447\u0438 \u043f\u043e\u0441\u043b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0434\u0432\u0430 \u0448\u0430\u0433\u0430. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0432\u0437\u044f\u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u043d\u0443\u0432 \u0435\u0433\u043e \u043d\u0430 \u043c\u0435\u0441\u0442\u043e \u043a\u043e\u0440\u043d\u044f. \u0422\u0430\u043a \u043c\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043a\u0443\u0447\u0438. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432\u0435\u0441\u044c\u043c\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430\u0440\u0443\u0448\u0438\u0442\u0441\u044f \u0435\u0451 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0442\u043e\u0440\u044b\u043c \u0448\u0430\u0433\u043e\u043c \u0441\u0442\u0430\u043d\u0435\u0442 \u0441\u043f\u0443\u0441\u043a \u043a\u043e\u0440\u043d\u044f \u043d\u0430 \u0435\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e. \u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0441\u0435\u0440\u0438\u044f \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043a\u043e\u0440\u043d\u044f \u0434\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u043a\u0443\u0447\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c62\/0f4\/825\/c620f48254e48ae2d97fac6fc9d1d703.png\" width=\"539\" height=\"1188\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c62\/0f4\/825\/c620f48254e48ae2d97fac6fc9d1d703.png\"\/><\/figure>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u043a\u043e\u0440\u0435\u043d\u044c \u0441 \u043c\u0435\u043d\u044c\u0448\u0438\u043c, \u0447\u0435\u043c \u043e\u043d \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u043c. \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u043b\u044f \u0443\u0437\u043b\u0430 \u0438 \u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043e\u043d \u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u0431\u043e\u0438\u0445 \u0441\u0432\u043e\u0438\u0445 \u0434\u0435\u0442\u0435\u0439. \u041a\u043e\u0434 \u0434\u043b\u044f \u201c\u043f\u0440\u043e\u0441\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f\u201d \u0443\u0437\u043b\u0430 \u0432\u043d\u0438\u0437 \u043f\u043e \u0434\u0435\u0440\u0435\u0432\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 <code>percDown<\/code> \u0438 <code>minChild<\/code> \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"python\">    def percDown(self,i):         while (i * 2) &lt;= self.currentSize:             mc = self.minChild(i)             if self.heapList[i] > self.heapList[mc]:                 tmp = self.heapList[i]                 self.heapList[i] = self.heapList[mc]                 self.heapList[mc] = tmp             i = mc      def minChild(self,i):         if i * 2 + 1 > self.currentSize:             return i * 2         else:             if self.heapList[i*2] &lt; self.heapList[i*2+1]:                 return i * 2             else:                 return i * 2 + 1 <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/942\/04e\/7ca\/94204e7ca5af3adf35361538b03c3229.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/942\/04e\/7ca\/94204e7ca5af3adf35361538b03c3229.gif\"\/><\/figure>\n<p>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 <code>delMin<\/code> \u043d\u0438\u0436\u0435. \u0412\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u043d\u043e\u0432\u0430 \u043e\u0442\u0434\u0430\u043d\u0430 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#8212; <code>percDown<\/code>):<\/p>\n<pre><code class=\"python\">    def delMin(self):         retval = self.heapList[1]         self.heapList[1] = self.heapList[self.currentSize]         self.currentSize = self.currentSize - 1         self.heapList.pop()         self.percDown(1)         return retval <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/012\/6dc\/eeb\/0126dceebadb83d19f3ecd836dbffc8e.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/012\/6dc\/eeb\/0126dceebadb83d19f3ecd836dbffc8e.gif\"\/><\/figure>\n<p>\u041d\u0443 \u0438 \u0432 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u0443\u0447\u0443 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u043a\u043b\u044e\u0447\u0435\u0439:<\/p>\n<pre><code class=\"python\">    def buildHeap(self,alist):         i = len(alist) \/\/ 2         self.currentSize = len(alist)         self.heapList = [0] + alist[:]         while (i > 0):             self.percDown(i)             i = i - 1 <\/code><\/pre>\n<p>\u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043d\u0438\u0436\u0435 \u0432\u0438\u0434\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u0443\u0447\u0438 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 [9, 6, 5, 2, 3] \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0434\u0430<\/p>\n<pre><code class=\"python\">bh = BinHeap() bh.buildHeap([9,5,6,2,3]) <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fc1\/ab1\/603\/fc1ab16037f43c29691b6224285f3b79.png\" width=\"639\" height=\"239\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fc1\/ab1\/603\/fc1ab16037f43c29691b6224285f3b79.png\"\/><\/figure>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e, \u0432\u043e\u0442 \u043c\u044b \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u0432\u043e\u0438\u0447\u043d\u0443\u044e \u043a\u0443\u0447\u0443 \u0438\u043b\u0438 \u043f\u0438\u0440\u0430\u043c\u0438\u0434\u0443, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435)<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ee6\/054\/3ae\/ee60543aed145e5827174c20147d01e7.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ee6\/054\/3ae\/ee60543aed145e5827174c20147d01e7.gif\"\/><\/figure>\n<h3>\u0413\u0440\u0430\u0444<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/06a\/8ae\/2c3\/06a8ae2c389c8f33de2d682eb4a3c214.png\" width=\"552\" height=\"600\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/06a\/8ae\/2c3\/06a8ae2c389c8f33de2d682eb4a3c214.png\"\/><\/figure>\n<p>\u0412 \u043f\u0440\u043e\u0441\u0442\u043e\u043d\u0430\u0440\u043e\u0434\u044c\u0435 <strong>\u0433\u0440\u0430\u0444<\/strong> \u2014 \u044d\u0442\u043e \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0443\u0437\u043b\u043e\u0432 (\u0432\u0435\u0440\u0448\u0438\u043d) \u0438 \u0441\u0432\u044f\u0437\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 (\u0440\u0451\u0431\u0435\u0440).<\/p>\n<p>\u0413\u0440\u0430\u0444\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 2 \u0442\u0438\u043f\u0430: <strong>\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435<\/strong> \u0438 <strong>\u043d\u0435\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435<\/strong>. \u0423 \u043d\u0435\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0433\u0440\u0430\u0444\u043e\u0432 \u0440\u0435\u0431\u0440\u0430 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u0443 \u0440\u0435\u0431\u0435\u0440 \u0432 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0433\u0440\u0430\u0444\u0430\u0445 \u043e\u043d\u043e \u0435\u0441\u0442\u044c.<\/p>\n<p>\u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0433\u0440\u0430\u0444 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442 \u0432 \u043a\u0430\u043a\u043e\u043c-\u043b\u0438\u0431\u043e \u0438\u0437 \u0434\u0432\u0443\u0445 \u0432\u0438\u0434\u043e\u0432: \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/815\/1da\/5b8\/8151da5b8f284cc8233ef0411d199267.png\" alt=\"\u041c\u0430\u0442\u0440\u0438\u0446\u0430 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438\" width=\"555\" height=\"211\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/815\/1da\/5b8\/8151da5b8f284cc8233ef0411d199267.png\"\/><\/p>\n<div><figcaption>\u041c\u0430\u0442\u0440\u0438\u0446\u0430 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0433\u0434\u0435 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0443\u0437\u0435\u043b, \u0430 \u0441\u043f\u0440\u0430\u0432\u0430 \u2014 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0437\u043b\u044b, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u043d \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442\u0441\u044f.<\/p>\n<p><strong>\u041c\u0430\u0442\u0440\u0438\u0446\u0430 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438<\/strong> \u2014 \u044d\u0442\u043e \u0441\u0435\u0442\u043a\u0430 \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u044f\u0434 \u0438\u043b\u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0443\u0437\u043b\u0443 \u0432 \u0433\u0440\u0430\u0444\u0435. \u041d\u0430 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u0440\u044f\u0434\u0430 \u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u0432\u044f\u0437\u0438. \u041d\u0443\u043b\u0438 \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442, \u0447\u0442\u043e \u0441\u0432\u044f\u0437\u044c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442; \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u2014 \u0447\u0442\u043e \u043e\u043d\u0430 \u0435\u0441\u0442\u044c. \u0427\u0442\u043e\u0431\u044b \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u0432\u0435\u0441 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0432\u044f\u0437\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0447\u0438\u0441\u043b\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u044b.<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0440\u0435\u0431\u0435\u0440 \u0438 \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u0433\u0440\u0430\u0444\u0430\u0445 \u2014 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043e\u0431\u0445\u043e\u0434\u0430. \u041a \u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0442\u0438\u043f\u0430\u043c \u043e\u0442\u043d\u043e\u0441\u044f\u0442 <strong>\u043f\u043e\u0438\u0441\u043a \u0432 \u0448\u0438\u0440\u0438\u043d\u0443<\/strong> (breadth-first search) \u0438 <strong>\u043f\u043e\u0438\u0441\u043a \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443<\/strong> (depth-first search). \u0421 \u0438\u0445 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u043b\u0438\u0437\u043a\u043e \u043a \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c\u0443 \u0443\u0437\u043b\u0443 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0442\u0435 \u0438\u043b\u0438 \u0438\u043d\u044b\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0433\u0440\u0430\u0444\u0430.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/181\/f8e\/420\/181f8e4203ab348b788c7dfd6d968ed7.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/181\/f8e\/420\/181f8e4203ab348b788c7dfd6d968ed7.gif\"\/><\/figure>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 &#171;\u0433\u0440\u0430\u0444&#187; \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043a\u043b\u0430\u0441\u0441 <code>Edge<\/code> (\u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 2 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438):<\/p>\n<pre><code class=\"python\">from __future__ import annotations from dataclasses import dataclass  @dataclass class Edge: u: int  # \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \"\u043e\u0442\u043a\u0443\u0434\u0430\" v: int  # \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \"\u043a\u0443\u0434\u0430\"  def reversed(self) -> Edge: return Edge(self.v, self.u)  def __str__(self) -> str: return f\"{self.u} -> {self.v}\" <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <code>Graph<\/code> \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <code>Edge<\/code> (\u043e\u0441\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0438\u0436\u0435):<\/p>\n<pre><code class=\"python\">from typing import TypeVar, Generic, List, Optional from edge import Edge  V = TypeVar('V')  # \u0442\u0438\u043f \u0432\u0435\u0440\u0448\u0438\u043d \u0433\u0440\u0430\u0444\u0430  class Graph(Generic[V]): def __init__(self, vertices: List[V] = []) -> None: self._vertices: List[V] = vertices self._edges: List[List[Edge]] = [[] for _ in vertices] <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0441\u043f\u0438\u0441\u043e\u043a <code>_vertices<\/code> \u2014 \u044d\u0442\u043e \u0441\u0435\u0440\u0434\u0446\u0435 \u0433\u0440\u0430\u0444\u0430. \u0412\u0441\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0441\u043f\u0438\u0441\u043a\u0435, \u0430 \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0438\u0445 \u043f\u043e \u0438\u0445 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0432 \u044d\u0442\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435. \u0421\u0430\u043c\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0435\u0435 \u0438\u043d\u0434\u0435\u043a\u0441 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f <code>int<\/code>, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043b\u0435\u0433\u043a\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435, \u043c\u0435\u0436\u0434\u0443 \u0433\u0440\u0430\u0444\u043e\u0432\u044b\u043c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c <code>_vertices<\/code>, \u044d\u0442\u043e\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0432\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b<br \/> \u0441 \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435 \u0438\u043c\u0435\u043d\u0435\u043c \u0432 \u043e\u0434\u043d\u043e\u043c \u0433\u0440\u0430\u0444\u0435.<\/p>\n<p>\u0414\u043e\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Graph<\/code>:<\/p>\n<pre><code class=\"python\">@property def vertex_count(self) -> int: return len(self._vertices) # \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0435\u0440\u0448\u0438\u043d  @property def edge_count(self) -> int: return sum(map(len, self._edges)) # \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0431\u0435\u0440  # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0432 \u0433\u0440\u0430\u0444 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0435\u0435 \u0438\u043d\u0434\u0435\u043a\u0441 def add_vertex(self, vertex: V) -> int: self._vertices.append(vertex) self._edges.append([]) # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043b\u044f \u0440\u0435\u0431\u0435\u0440 return self.vertex_count - 1 # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c  # \u042d\u0442\u043e \u043d\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444, # \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432 \u043e\u0431\u043e\u0438\u0445 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u0445 def add_edge(self, edge: Edge) -> None: self._edges[edge.u].append(edge) self._edges[edge.v].append(edge.reversed())  # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0435\u0431\u0440\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432\u0435\u0440\u0448\u0438\u043d (\u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434) def add_edge_by_indices(self, u: int, v: int) -> None: edge: Edge = Edge(u, v) self.add_edge(edge)  # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0435\u0431\u0440\u043e, \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432\u0435\u0440\u0448\u0438\u043d (\u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434) def add_edge_by_vertices(self, first: V, second: V) -> None: u: int = self._vertices.index(first) v: int = self._vertices.index(second) self.add_edge_by_indices(u, v)  # \u041f\u043e\u0438\u0441\u043a \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 def vertex_at(self, index: int) -> V: return self._vertices[index]  # \u041f\u043e\u0438\u0441\u043a \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432 \u0433\u0440\u0430\u0444\u0435 def index_of(self, vertex: V) -> int: return self._vertices.index(vertex)  # \u041f\u043e\u0438\u0441\u043a \u0432\u0435\u0440\u0448\u0438\u043d, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c def neighbors_for_index(self, index: int) -> List[V]: return list(map(self.vertex_at, [e.v for e in self._edges[index]]))  # \u041f\u043e\u0438\u0441\u043a \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u044b; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0435 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 (\u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434) def neighbors_for_vertex(self, vertex: V) -> List[V]: return self.neighbors_for_index(self.index_of(vertex))  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435 \u0440\u0435\u0431\u0440\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0432\u0435\u0440\u0448\u0438\u043d\u043e\u0439, \u0438\u043c\u0435\u044e\u0449\u0435\u0439 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 def edges_for_index(self, index: int) -> List[Edge]: return self._edges[index]  # \u041f\u043e\u0438\u0441\u043a \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u044b; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0435 \u0440\u0435\u0431\u0440\u0430 (\u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434) def edges_for_vertex(self, vertex: V) -> List[Edge]: return self.edges_for_index(self.index_of(vertex))  # \u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u0433\u0440\u0430\u0444\u0430 def __str__(self) -> str: desc: str = \"\" for i in range(self.vertex_count): desc += f\"{self.vertex_at(i)} -> {self.neighbors_for_index(i)}\\n\" return desc <\/code><\/pre>\n<p>\u0425\u043c\u043c, \u043d\u0435\u043c\u0430\u043b\u043e \u0432\u0441\u0435\u0433\u043e. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 2 \u0432\u0435\u0440\u0441\u0438\u044f\u0445. \u0418\u0437 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a <code>_vertices<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0442\u0438\u043f\u0430 <code>V<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c Python. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0442\u0438\u043f\u0430 <code>V<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 <code>_vertices<\/code>. \u041d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u044d\u0442\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0438 \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0438\u043c\u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0433\u0434\u0435 \u043e\u043d\u0438 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0441 \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u043e\u0439 \u0432 \u044d\u0442\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0441\u0432\u044f\u0437\u0430\u043d \u0438\u043d\u0434\u0435\u043a\u0441 (\u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e). \u0415\u0441\u043b\u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d, \u0442\u043e \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438, \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044f <code>_vertices<\/code>. \u0418\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u044b 2 \u0432\u0435\u0440\u0441\u0438\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430: \u043e\u0434\u043d\u0430 \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438, \u0434\u0440\u0443\u0433\u0430\u044f \u2014 \u0441\u0430\u043c\u0438\u043c <code>V<\/code>.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/95f\/bef\/40a\/95fbef40a8cb64cfc20e1dd4f137d4a0.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/95f\/bef\/40a\/95fbef40a8cb64cfc20e1dd4f137d4a0.gif\"\/><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0433\u0440\u0430\u0444, \u043d\u0430\u043f\u0438\u0441\u0430\u0432 \u0447\u0442\u043e-\u0442\u043e \u0432 \u0434\u0443\u0445\u0435:<\/p>\n<pre><code class=\"python\">city_graph: Graph[str] = Graph([\"Seattle\", \"San Francisco\", \"LosAngeles\", \"Riverside\", \"Phoenix\", \"Chicago\", \"Boston\", \"New York\", \"Atlanta\", \"Miami\", \"Dallas\", \"Houston\", \"Detroit\", \"Philadelphia\", \"Washington\"])  city_graph.add_edge_by_vertices(\"Seattle\", \"Chicago\") city_graph.add_edge_by_vertices(\"Seattle\", \"San Francisco\") city_graph.add_edge_by_vertices(\"San Francisco\", \"Riverside\") city_graph.add_edge_by_vertices(\"San Francisco\", \"Los Angeles\") city_graph.add_edge_by_vertices(\"Los Angeles\", \"Riverside\") city_graph.add_edge_by_vertices(\"Los Angeles\", \"Phoenix\") city_graph.add_edge_by_vertices(\"Riverside\", \"Phoenix\") city_graph.add_edge_by_vertices(\"Riverside\", \"Chicago\") city_graph.add_edge_by_vertices(\"Phoenix\", \"Dallas\") city_graph.add_edge_by_vertices(\"Phoenix\", \"Houston\") city_graph.add_edge_by_vertices(\"Dallas\", \"Chicago\") city_graph.add_edge_by_vertices(\"Dallas\", \"Atlanta\") city_graph.add_edge_by_vertices(\"Dallas\", \"Houston\") city_graph.add_edge_by_vertices(\"Houston\", \"Atlanta\") city_graph.add_edge_by_vertices(\"Houston\", \"Miami\") city_graph.add_edge_by_vertices(\"Atlanta\", \"Chicago\") city_graph.add_edge_by_vertices(\"Atlanta\", \"Washington\") city_graph.add_edge_by_vertices(\"Atlanta\", \"Miami\") city_graph.add_edge_by_vertices(\"Miami\", \"Washington\") city_graph.add_edge_by_vertices(\"Chicago\", \"Detroit\") city_graph.add_edge_by_vertices(\"Detroit\", \"Boston\") city_graph.add_edge_by_vertices(\"Detroit\", \"Washington\") city_graph.add_edge_by_vertices(\"Detroit\", \"New York\") city_graph.add_edge_by_vertices(\"Boston\", \"New York\") city_graph.add_edge_by_vertices(\"New York\", \"Philadelphia\") city_graph.add_edge_by_vertices(\"Philadelphia\", \"Washington\") print(city_graph)  # Seattle -> ['Chicago', 'San Francisco'] # San Francisco -> ['Seattle', 'Riverside', 'Los Angeles'] # Los Angeles -> ['San Francisco', 'Riverside', 'Phoenix'] # Riverside -> ['San Francisco', 'Los Angeles', 'Phoenix', 'Chicago'] # Phoenix -> ['Los Angeles', 'Riverside', 'Dallas', 'Houston'] # Chicago -> ['Seattle', 'Riverside', 'Dallas', 'Atlanta', 'Detroit'] # Boston -> ['Detroit', 'New York'] # New York -> ['Detroit', 'Boston', 'Philadelphia'] # Atlanta -> ['Dallas', 'Houston', 'Chicago', 'Washington', 'Miami'] # Miami -> ['Houston', 'Atlanta', 'Washington'] # Dallas -> ['Phoenix', 'Chicago', 'Atlanta', 'Houston'] # Houston -> ['Phoenix', 'Dallas', 'Atlanta', 'Miami'] # Detroit -> ['Chicago', 'Boston', 'Washington', 'New York'] # Philadelphia -> ['New York', 'Washington'] # Washington -> ['Atlanta', 'Miami', 'Detroit', 'Philadelphia'] <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/828\/fbe\/921\/828fbe921ed79143b48e3951445a51db.png\" width=\"1314\" height=\"628\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/828\/fbe\/921\/828fbe921ed79143b48e3951445a51db.png\"\/><\/figure>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u0430\u044f \u0441\u0435\u0442\u044c? \u041f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430 \u2014 \u0447\u0442\u043e-\u0442\u043e, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0435 \u0441 700 \u043c\u0438\u043b\u044c\/\u0447\u0430\u0441, \u043f\u0438\u0448\u0438\u0442\u0435, \u043a\u0442\u043e \u0443\u0433\u0430\u0434\u0430\u043b)<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e09\/d70\/51f\/e09d7051fad2a137cb54fefa4947413b.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e09\/d70\/51f\/e09d7051fad2a137cb54fefa4947413b.gif\"\/><\/figure>\n<p><a class=\"anchor\" name=\"3\" id=\"3\"><\/a><\/p>\n<h2>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438<\/h2>\n<p>\u041b\u043e\u0432\u0438\u0442\u0435 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0443 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/36a\/bdb\/357\/36abdb35713c462d550baff1385c5458.png\" width=\"1205\" height=\"609\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/36a\/bdb\/357\/36abdb35713c462d550baff1385c5458.png\"\/><\/figure>\n<p>\u0410 \u0432\u043e\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9f6\/7e4\/38d\/9f67e438d05fa51fdaadca189a7b629f.gif\" width=\"880\" height=\"445\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9f6\/7e4\/38d\/9f67e438d05fa51fdaadca189a7b629f.gif\"\/><\/figure>\n<p>\u0427\u0442\u043e \u0436, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u043f\u043e\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/32e\/7aa\/52a\/32e7aa52aba620012ac39e8151faafc4.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/32e\/7aa\/52a\/32e7aa52aba620012ac39e8151faafc4.gif\"\/><\/figure>\n<h3>\u0411\u044b\u0441\u0442\u0440\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 (Quick Sort)<\/h3>\n<p>\u041a\u0430\u043a \u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u043b\u0438\u044f\u043d\u0438\u0435\u043c, \u0431\u044b\u0441\u0442\u0440\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u00ab\u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0439 \u0438 \u0432\u043b\u0430\u0441\u0442\u0432\u0443\u0439\u00bb. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0447\u0443\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043d\u043e \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u0445 \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0441\u043b\u0438\u044f\u043d\u0438\u0435\u043c, \u0430 \u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 O(n^2), \u043d\u043e \u044d\u0442\u043e \u0440\u0435\u0434\u043a\u043e\u0435 \u044f\u0432\u043b\u0435\u043d\u0438\u0435. Quick Sort \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 3 \u044d\u0442\u0430\u043f\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f 1 \u043e\u043f\u043e\u0440\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u043f\u043e\u0440\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 \u043d\u0435\u0433\u043e, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u2014 \u043d\u0430\u043f\u0440\u0430\u0432\u043e. \u042d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f 2 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0448\u0430\u0433\u0430 \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043d\u043e\u0432\u043e\u043c\u0443 \u0441\u043f\u0438\u0441\u043a\u0443, \u0433\u0434\u0435 \u043d\u043e\u0432\u044b\u0435 \u043e\u043f\u043e\u0440\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/776\/44c\/dd1\/77644cdd195a079d90a516cead646b3e.gif\" width=\"300\" height=\"180\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/776\/44c\/dd1\/77644cdd195a079d90a516cead646b3e.gif\"\/><\/figure>\n<pre><code class=\"python\">def partition(array, begin, end):  # \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u043f\u043e\u043b\u0430\u043c \u043f\u043e \u043e\u043f\u043e\u0440\u043d\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443     pivot_idx = begin     for i in xrange(begin+1, end+1):         if array[i] &lt;= array[begin]:             pivot_idx += 1             array[i], array[pivot_idx] = array[pivot_idx], array[i]     array[pivot_idx], array[begin] = array[begin], array[pivot_idx]     return pivot_idx  def quick_sort_recursion(array, begin, end):  # \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u043f\u043e\u0434\u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u043f\u043e\u043a\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u043e\u0434\u043c\u0430\u0441\u0441\u0438\u0432\u0430 != 1     if begin >= end:         return     pivot_idx = partition(array, begin, end)     quick_sort_recursion(array, begin, pivot_idx-1)     quick_sort_recursion(array, pivot_idx+1, end)  def quick_sort(array, begin=0, end=None):       if end is None:         end = len(array) - 1     return quick_sort_recursion(array, begin, end) <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0a9\/afd\/372\/0a9afd372156de5806bd87f93c875834.gif\" width=\"600\" height=\"341\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0a9\/afd\/372\/0a9afd372156de5806bd87f93c875834.gif\"\/><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/959\/6f9\/338\/9596f93381ee34dc0a9f5d4c373c4a78.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/959\/6f9\/338\/9596f93381ee34dc0a9f5d4c373c4a78.gif\"\/><\/figure>\n<h3>\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u043b\u0438\u044f\u043d\u0438\u0435\u043c (Merge Sort)<\/h3>\n<p>\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u043b\u0438\u044f\u043d\u0438\u0435\u043c \u2014 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u00ab\u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0439 \u0438 \u0432\u043b\u0430\u0441\u0442\u0432\u0443\u0439\u00bb. \u0421\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u044d\u0442\u0430\u043f\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u041d\u0435\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 N \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u00ab\u043d\u0435\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439\u00bb \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0430 N \u2014 \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043f\u0438\u0441\u043a\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438 \u043f\u043e \u0434\u0432\u0430, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043d\u043e\u0432\u044b\u0435 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u043f\u0438\u0441\u043a\u0438 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8b4\/380\/d0e\/8b4380d0e4901e33e91198adf466558a.gif\" width=\"300\" height=\"180\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8b4\/380\/d0e\/8b4380d0e4901e33e91198adf466558a.gif\"\/><\/figure>\n<pre><code class=\"python\">def merge_sort(arr):     # \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430     if len(arr) &lt;= 1:         return arr     mid = len(arr) \/\/ 2     # \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c merge_sort \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0441 \u0434\u0432\u0443\u0445 \u0441\u0442\u043e\u0440\u043e\u043d     left, right = merge_sort(arr[:mid]), merge_sort(arr[mid:])      # \u041e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0432\u043c\u0435\u0441\u0442\u0435     return merge(left, right, arr.copy())   def merge(left, right, merged):      left_cursor, right_cursor = 0, 0     while left_cursor &lt; len(left) and right_cursor &lt; len(right):                # \u0421\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442         if left[left_cursor] &lt;= right[right_cursor]:             merged[left_cursor+right_cursor]=left[left_cursor]             left_cursor += 1         else:             merged[left_cursor + right_cursor] = right[right_cursor]             right_cursor += 1                  for left_cursor in range(left_cursor, len(left)):         merged[left_cursor + right_cursor] = left[left_cursor]              for right_cursor in range(right_cursor, len(right)):         merged[left_cursor + right_cursor] = right[right_cursor]      return merged <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/21f\/1a3\/ec0\/21f1a3ec016004112fbb9180f76067dd.gif\" width=\"600\" height=\"339\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/21f\/1a3\/ec0\/21f1a3ec016004112fbb9180f76067dd.gif\"\/><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f01\/93d\/aae\/f0193daaec9657bda71d435ba4c1d65c.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f01\/93d\/aae\/f0193daaec9657bda71d435ba4c1d65c.gif\"\/><\/figure>\n<h3>\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0432\u0441\u0442\u0430\u0432\u043a\u0430\u043c\u0438 (Insertion Sort)<\/h3>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/873\/cae\/dff\/873caedff4cdca3bfb4facb10cd06c32.gif\" width=\"500\" height=\"300\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/873\/cae\/dff\/873caedff4cdca3bfb4facb10cd06c32.gif\"\/><\/figure>\n<p>\u0412 <strong>\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435 \u0432\u0441\u0442\u0430\u0432\u043a\u0430\u043c\u0438<\/strong> \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c. \u0412\u043e\u0442 \u0438 \u0432\u0441\u044f \u0438\u0434\u0435\u044f.<\/p>\n<pre><code class=\"python\">def insertion_sort(arr):     for i in range(len(arr)):         cursor = arr[i]         pos = i                  while pos > 0 and arr[pos - 1] > cursor:             # \u041c\u0435\u043d\u044f\u0435\u043c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0447\u0438\u0441\u043b\u043e, \u043f\u0440\u043e\u0434\u0432\u0438\u0433\u0430\u044f \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443             arr[pos] = arr[pos - 1]             pos = pos - 1         # \u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043e\u0431\u043c\u0435\u043d         arr[pos] = cursor      return arr <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fcc\/ea3\/8f3\/fccea38f39ce8c98392ccccabe6711d6.gif\" width=\"600\" height=\"340\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fcc\/ea3\/8f3\/fccea38f39ce8c98392ccccabe6711d6.gif\"\/><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5a0\/702\/9f2\/5a07029f2b18bf0b57bc9ea90564614f.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5a0\/702\/9f2\/5a07029f2b18bf0b57bc9ea90564614f.gif\"\/><\/figure>\n<h3>\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u0443\u0437\u044b\u0440\u044c\u043a\u043e\u043c (Bubble Sort)<\/h3>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c1b\/3ef\/245\/c1b3ef2456d67076d03a74c6b2ea9db5.gif\" width=\"300\" height=\"180\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c1b\/3ef\/245\/c1b3ef2456d67076d03a74c6b2ea9db5.gif\"\/><\/figure>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c <strong>\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u0443\u0437\u044b\u0440\u044c\u043a\u043e\u043c<\/strong> \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u043f\u0440\u043e\u0445\u043e\u0434\u0430\u0445 \u043f\u043e \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u043c\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0443. \u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0438, \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432 \u043f\u0430\u0440\u0435 \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0439, \u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0435\u043d\u044f\u044e\u0442 \u043c\u0435\u0441\u0442\u0430\u043c\u0438. \u0417\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043e\u0434\u0438\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u0441\u0442\u0430\u0435\u0442 \u043d\u0430 \u0441\u0432\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"n\u22121\" alt=\"n\u22121\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2ac\/805\/699\/2ac80569918c722be6c64a950b438676.svg\" width=\"45\" height=\"17\"\/> \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"n\" alt=\"n\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/df5\/04d\/5f5\/df504d5f5ce5cbcde462b2e3b797d989.svg\" width=\"12\" height=\"12\"\/><\/p>\n<pre><code class=\"python\">def bubble_sort(arr):     def swap(i, j):         arr[i], arr[j] = arr[j], arr[i]      n = len(arr)     swapped = True          x = -1     while swapped:         swapped = False         x = x + 1         for i in range(1, n-x):             if arr[i - 1] > arr[i]:  # \u0435\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u0442\u043e\u044f\u0442 \u0432 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435,                 swap(i - 1, i)  # \u0442\u043e \u043c\u0435\u043d\u044f\u0435\u043c \u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u043c\u0438, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c arr                 swapped = True <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/132\/1a8\/c2d\/1321a8c2d653c5b4fdca906baff445a5.gif\" width=\"600\" height=\"341\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/132\/1a8\/c2d\/1321a8c2d653c5b4fdca906baff445a5.gif\"\/><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aaf\/e88\/39b\/aafe8839beb8e57c42fbffdddd5dfe20.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aaf\/e88\/39b\/aafe8839beb8e57c42fbffdddd5dfe20.gif\"\/><\/figure>\n<h3>\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u0435\u043c (\u0448\u0435\u0439\u043a\u0435\u0440\u043d\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430)<\/h3>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5d3\/967\/f0d\/5d3967f0d52be1c598572d16d532d34d.gif\" width=\"423\" height=\"389\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5d3\/967\/f0d\/5d3967f0d52be1c598572d16d532d34d.gif\"\/><\/figure>\n<p><strong>\u0428\u0435\u0439\u043a\u0435\u0440\u043d\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430<\/strong> \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043f\u0443\u0437\u044b\u0440\u044c\u043a\u043e\u0432\u043e\u0439 \u0442\u0435\u043c, \u0447\u0442\u043e \u043e\u043d\u0430 \u0434\u0432\u0443\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f: \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0441\u0442\u0440\u043e\u0433\u043e \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e, \u0430 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e, \u0437\u0430\u0442\u0435\u043c \u0441\u043f\u0440\u0430\u0432\u0430 \u043d\u0430\u043b\u0435\u0432\u043e.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9c0\/bce\/7b8\/9c0bce7b830e66dde7ebe49333c65729.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9c0\/bce\/7b8\/9c0bce7b830e66dde7ebe49333c65729.gif\"\/><\/figure>\n<h3>\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0440\u0430\u0441\u0447\u0451\u0441\u043a\u043e\u0439<\/h3>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/531\/81b\/d14\/53181bd1445133562ed0f3693571fa80.gif\" width=\"422\" height=\"395\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/531\/81b\/d14\/53181bd1445133562ed0f3693571fa80.gif\"\/><\/figure>\n<p><strong>\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0440\u0430\u0441\u0447\u0451\u0441\u043a\u043e\u0439<\/strong> \u2014 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0435 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u0443\u0437\u044b\u0440\u044c\u043a\u043e\u043c. \u0418\u0434\u0435\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u00ab\u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c\u00bb \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0446\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438 \u043f\u0443\u0437\u044b\u0440\u044c\u043a\u043e\u0432\u043e\u0439 \u0438 \u0448\u0435\u0439\u043a\u0435\u0440\u043d\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430\u0445 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0442\u043e \u043f\u0440\u0438 \u00ab\u0440\u0430\u0441\u0447\u0451\u0441\u044b\u0432\u0430\u043d\u0438\u0438\u00bb \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0435\u0440\u0451\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u0430 \u043f\u043e\u0442\u043e\u043c \u043e\u043d\u043e \u0441\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e. \u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u0440\u044b\u0432 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0430 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u2014 \u0444\u0430\u043a\u0442\u043e\u0440\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f, \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u0430\u0432\u043d\u043e 1.247. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u044f\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043f\u043e\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 \u043d\u0430 1.247; \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0448\u0430\u0433\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043d\u043e\u0432\u0430 \u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0444\u0430\u043a\u0442\u043e\u0440 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u2014 \u0438 \u0442\u0430\u043a \u0434\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/22c\/d05\/2cb\/22cd052cbb900ac2abda9365abc8422c.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/22c\/d05\/2cb\/22cd052cbb900ac2abda9365abc8422c.gif\"\/><\/figure>\n<h3>\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0432\u044b\u0431\u043e\u0440\u043e\u043c (Selection Sort )<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dcb\/dd1\/578\/dcbdd1578be857b35d544d6d88ed4801.gif\" width=\"551\" height=\"314\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dcb\/dd1\/578\/dcbdd1578be857b35d544d6d88ed4801.gif\"\/><\/figure>\n<p>\u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"i\" alt=\"i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/821\/196\/a33\/821196a33f2300ddb7bed700e6dc178a.svg\" width=\"7\" height=\"16\"\/>-\u043e\u043c \u0448\u0430\u0433\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u043c <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"i\" alt=\"i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6b3\/1a2\/e0f\/6b31a2e0f4b1881dbfebff2642e1a11d.svg\" width=\"7\" height=\"16\"\/>-\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u043c\u0435\u043d\u044f\u0435\u043c \u0435\u0433\u043e \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0441 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"i\" alt=\"i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/566\/9ae\/cb2\/5669aecb2962f7a7e55cd1ed0a959dd1.svg\" width=\"7\" height=\"16\"\/>-\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u043c\u0430\u0441\u0441\u0438\u0432, \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u043d\u0435\u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e.<\/p>\n<pre><code class=\"python\">def selection_sort(arr):             for i in range(len(arr)):         minimum = i                  for j in range(i + 1, len(arr)):             # \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435             if arr[j] &lt; arr[minimum]:                 minimum = j          # \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u043d\u0446\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0430         arr[minimum], arr[i] = arr[i], arr[minimum]                  return arr <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6e1\/ea1\/8c7\/6e1ea18c7121582805e1bba9af3a9096.gif\" width=\"600\" height=\"343\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6e1\/ea1\/8c7\/6e1ea18c7121582805e1bba9af3a9096.gif\"\/><\/figure>\n<p>\u0412\u043e\u0442 \u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0441 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438, \u0432\u043f\u0435\u0440\u0451\u0434 \u043a \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bda\/c8c\/df1\/bdac8cdf1ad422d0b260e35a7188ee22.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bda\/c8c\/df1\/bdac8cdf1ad422d0b260e35a7188ee22.gif\"\/><\/figure>\n<p><a class=\"anchor\" name=\"4\" id=\"4\"><\/a><\/p>\n<h2>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b<\/h2>\n<p>\u041e\u0434\u043d\u0430 \u0433\u0438\u0444\u043a\u0430 \u043b\u0443\u0447\u0448\u0435 \u0442\u044b\u0441\u044f\u0447\u0438 \u0441\u043b\u043e\u0432:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/16f\/47b\/175\/16f47b175fb0784492720cb1c4c41aed.gif\" width=\"774\" height=\"334\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/16f\/47b\/175\/16f47b175fb0784492720cb1c4c41aed.gif\"\/><\/figure>\n<p>\u0418\u043b\u0438 \u0432\u043e\u0442 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0443\u0442 \u043d\u0438\u0436\u0435 \u0443 \u043d\u0430\u0441 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0438\u0441\u043a \u0432\u0441\u0435\u0445 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0445 \u043f\u0443\u0442\u0435\u0439 \u0438\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 S \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b. \u041a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0434\u0438\u043d \u0448\u0430\u0433, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0440\u0430\u043d\u0435\u0435 \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u0432\u0435\u0441\u043e\u043c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ab8\/c2e\/64b\/ab8c2e64b8277335d55644293d3c9b20.png\" width=\"654\" height=\"677\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ab8\/c2e\/64b\/ab8c2e64b8277335d55644293d3c9b20.png\"\/><\/figure>\n<p>\u0418\u0442\u0430\u043a, <strong>\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b<\/strong> \u2014 \u044d\u0442\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0435\u0433\u043e \u043f\u0443\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0443\u0437\u043b\u0430\u043c\u0438 \u0432 \u0433\u0440\u0430\u0444\u0435. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043b\u044e\u0431\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u0432\u0438\u0434\u0435 \u0433\u0440\u0430\u0444\u0430. \u041f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u0440\u0443\u0437\u0435\u0439 \u0432 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445, \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u0438\u043b\u0438 \u043f\u043e\u0438\u0441\u043a \u043f\u0443\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 \u043b\u0430\u0431\u0438\u0440\u0438\u043d\u0442 \u2014 \u0432\u0441\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b.<\/p>\n<p>\u041f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/148\/0ab\/07a\/1480ab07ae6aa57d3a47df88555d17ee.png\" width=\"731\" height=\"623\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/148\/0ab\/07a\/1480ab07ae6aa57d3a47df88555d17ee.png\"\/><\/figure>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b \u0434\u043b\u044f \u0433\u0440\u0430\u0444\u043e\u0432, \u0430 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u0433\u0440\u0430\u0444\u043e\u043f\u043e\u0434\u043e\u0431\u043d\u043e\u043c \u0432\u0438\u0434\u0435. \u0414\u0430\u043b\u044c\u0448\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0441\u0430\u043c\u044b\u0439 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0435\u0433\u043e \u043f\u0443\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 2 \u0433\u043e\u0440\u043e\u0434\u0430\u043c\u0438.<\/p>\n<p>\u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u043c\u0435\u0436\u0434\u0443 \u0435\u0432\u0440\u043e\u043f\u0435\u0439\u0441\u043a\u0438\u043c\u0438 \u0433\u043e\u0440\u043e\u0434\u0430\u043c\u0438 \u0420\u0435\u0439\u043a\u044c\u044f\u0432\u0438\u043a\u043e\u043c \u0438 \u0411\u0435\u043b\u0433\u0440\u0430\u0434\u043e\u043c. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0433\u043e\u0440\u043e\u0434\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0434\u043e\u0440\u043e\u0433\u0430\u043c\u0438 (\u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043e\u0434\u0438\u043d \u043f\u0430\u0440\u043e\u043c).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/a90\/9dd\/222\/a909dd2227f483b9ba736c27ad6b08a5.jpeg\" alt=\"\u0413\u0440\u0430\u0444 \u0435\u0432\u0440\u043e\u043f\u0435\u0439\u0441\u043a\u0438\u0445 \u0433\u043e\u0440\u043e\u0434\u043e\u0432\" width=\"755\" height=\"571\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a90\/9dd\/222\/a909dd2227f483b9ba736c27ad6b08a5.jpeg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>\u0413\u0440\u0430\u0444 \u0435\u0432\u0440\u043e\u043f\u0435\u0439\u0441\u043a\u0438\u0445 \u0433\u043e\u0440\u043e\u0434\u043e\u0432<\/figcaption><\/div>\n<\/figure>\n<ul>\n<li>\n<p>\u043a\u0430\u0436\u0434\u044b\u0439 \u0433\u043e\u0440\u043e\u0434 \u2014 \u044d\u0442\u043e \u0443\u0437\u0435\u043b<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u0436\u0434\u0430\u044f \u0434\u043e\u0440\u043e\u0433\u0430 \u2014 \u044d\u0442\u043e \u0440\u0435\u0431\u0440\u043e<\/p>\n<\/li>\n<li>\n<p>\u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0434\u043e\u0440\u043e\u0433\u0438 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u044f \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0433\u043e\u0440\u043e\u0434\u0430\u043c\u0438, \u043f\u043b\u0430\u0442\u0430 \u0437\u0430 \u043f\u0440\u043e\u0435\u0437\u0434 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043c\u044b \u043e\u0442\u0434\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u0435 \u0440\u0451\u0431\u0440\u0430\u043c \u0441 \u0431\u043e\u043b\u0435\u0435 \u043d\u0438\u0437\u043a\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438. \u0412 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0433\u043e\u0440\u043e\u0434\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0437\u0434\u0435\u0441\u044c \u0434\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0438\u0437 \u0420\u0435\u0439\u043a\u044c\u044f\u0432\u0438\u043a\u0430 \u0434\u043e \u0411\u0435\u043b\u0433\u0440\u0430\u0434\u0430 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041d\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0443\u0442\u0435\u0439 \u0438\u0437 \u0420\u0435\u0439\u043a\u044c\u044f\u0432\u0438\u043a\u0430 \u0432 \u0411\u0435\u043b\u0433\u0440\u0430\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0447\u0435\u0440\u0435\u0437 \u0434\u0440\u0443\u0433\u0438\u0435 \u0433\u043e\u0440\u043e\u0434\u0430:<\/p>\n<ul>\n<li>\n<p>Reykjavik <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/402\/5d7\/06d\/4025d706d670e8508c0b3c965ea67316.svg\" width=\"32\" height=\"13\"\/> Oslo <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ea2\/d8d\/abc\/ea2d8dabcbb7d0cb2f7a49f917820f90.svg\" width=\"32\" height=\"13\"\/> Berlin <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cfc\/db0\/5f9\/cfcdb05f953093e276bd373c427566b8.svg\" width=\"32\" height=\"13\"\/> Belgrade<\/p>\n<\/li>\n<li>\n<p>Reykjavik <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/76a\/6e8\/6b9\/76a6e86b9d7ea14aef0e04b0bc57171f.svg\" width=\"32\" height=\"13\"\/> London <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/838\/734\/e9e\/838734e9e192c28fb519bb3532a9f945.svg\" width=\"32\" height=\"13\"\/> Berlin <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f38\/4cb\/a36\/f384cba36105a01447f2b4a4fd198a62.svg\" width=\"32\" height=\"13\"\/> Rome <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/96c\/c7c\/cb4\/96cc7ccb4f5f2b524630ff9db60a3446.svg\" width=\"32\" height=\"13\"\/> Athens <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9ea\/f40\/26f\/9eaf4026f40d29f8dd684084cf05eca9.svg\" width=\"32\" height=\"13\"\/> Belgrade<\/p>\n<\/li>\n<li>\n<p>Reykjavik <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f81\/a27\/77d\/f81a2777d5e53b42a7d0ad897358668a.svg\" width=\"32\" height=\"13\"\/> London <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2ef\/8e7\/7a8\/2ef8e77a853fe034354372eec1b55d10.svg\" width=\"32\" height=\"13\"\/> Berlin <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/37b\/564\/e19\/37b564e1921b01deeffc56961488d5d5.svg\" width=\"32\" height=\"13\"\/> Rome <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/56d\/75d\/fa6\/56d75dfa6465038418aeac8b76022463.svg\" width=\"32\" height=\"13\"\/> Athens <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/66c\/b01\/1a7\/66cb011a718859304f16ed5edada4ec3.svg\" width=\"32\" height=\"13\"\/> Moscow <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f62\/225\/1fb\/f622251fbc00a866138ecff9ce046807.svg\" width=\"32\" height=\"13\"\/> Belgrade<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u0443\u0442\u0435\u0439 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0411\u0435\u043b\u0433\u0440\u0430\u0434\u0435, \u043d\u043e \u0432\u0441\u0435 \u043e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043f\u0443\u0442\u044c \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043e\u0431\u0449\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9e4\/199\/9d4\/9e41999d4ece7b657330fe7f263966a9.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9e4\/199\/9d4\/9e41999d4ece7b657330fe7f263966a9.gif\"\/><\/figure>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b?<\/p>\n<p><strong>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c:<\/strong><\/p>\n<ol>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0420\u0435\u0439\u043a\u044c\u044f\u0432\u0438\u043a \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0420\u0435\u0439\u043a\u044c\u044f\u0432\u0438\u043a\u043e\u043c \u0438 \u0432\u0441\u0435\u043c\u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0433\u043e\u0440\u043e\u0434\u0430\u043c\u0438 \u0432 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\u221e\" alt=\"\u221e\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/169\/ac4\/bb0\/169ac4bb0041f5122b5e65fbeb6a6c1e.svg\" width=\"19\" height=\"12\"\/>, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0420\u0435\u0439\u043a\u044c\u044f\u0432\u0438\u043a\u043e\u043c \u0438 \u0441\u0430\u043c\u0438\u043c \u0441\u043e\u0431\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0440\u0430\u0432\u043d\u044b\u043c 0.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e, \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0438:<\/strong><\/p>\n<ol>\n<li>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0443\u0437\u0435\u043b \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u00ab\u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430\u00bb \u0438 \u043f\u043e\u0441\u0435\u0449\u0430\u0435\u043c \u0432\u0441\u0435\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439. \u041f\u0440\u0438 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0441\u0435\u0434\u0430, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0438\u0445 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u043f\u043e\u0441\u0435\u0442\u0438\u043c \u0432\u0441\u0435\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430 \u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0438 \u0438\u0445 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0443\u0437\u0435\u043b \u043a\u0430\u043a \u00ab\u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u044b\u0439\u00bb). \u041e\u0442\u043c\u0435\u0442\u043a\u0430 \u0443\u0437\u043b\u0430 \u043a\u0430\u043a \u00ab\u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u043e\u0433\u043e\u00bb \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u0430 \u0435\u0433\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a 1 \u0448\u0430\u0433\u0443 \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u0441\u0435\u0442\u0438\u043c \u0432\u0441\u0435 \u0443\u0437\u043b\u044b \u0433\u0440\u0430\u0444\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u043e\u0442\u043c\u0435\u0442\u043a\u0438 \u0420\u0435\u0439\u043a\u044c\u044f\u0432\u0438\u043a\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0432\u043d\u043e 0, \u043a\u0430\u043a \u00ab\u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430\u00bb. \u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u0441\u0435\u0442\u0438\u043c \u0434\u0432\u0430 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u0443\u0437\u043b\u0430 \u0420\u0435\u0439\u043a\u044c\u044f\u0432\u0438\u043a\u0430: \u041b\u043e\u043d\u0434\u043e\u043d \u0438 \u041e\u0441\u043b\u043e. \u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u044c, \u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u0441\u0435\u0449\u0430\u0435\u043c \u0443\u0437\u043b\u044b, \u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u041b\u043e\u043d\u0434\u043e\u043d\u0430 \u0434\u043e 4 \u0438 \u041e\u0441\u043b\u043e \u0434\u043e 5.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/18e\/e0b\/342\/18ee0b34256764c4c015fe7e187e9d0c.jpeg\" alt=\"img\" width=\"792\" height=\"603\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/18e\/e0b\/342\/18ee0b34256764c4c015fe7e187e9d0c.jpeg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>img<\/figcaption><\/div>\n<\/figure>\n<p>\u0417\u0430\u0442\u0435\u043c \u043e\u0442\u043c\u0435\u0447\u0430\u0435\u043c \u0420\u0435\u0439\u043a\u044c\u044f\u0432\u0438\u043a \u043a\u0430\u043a \u00ab\u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u044b\u0439\u00bb. \u041c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0435\u0433\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0430\u0432\u043d\u0430 \u043d\u0443\u043b\u044e, \u0438 \u043d\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0435\u0433\u043e \u043f\u043e\u0441\u0435\u0449\u0430\u0442\u044c. \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430 \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u041b\u043e\u043d\u0434\u043e\u043d.<\/p>\n<p>\u041f\u043e\u0441\u0435\u0449\u0430\u0435\u043c \u0432\u0441\u0435 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u0443\u0437\u043b\u044b \u041b\u043e\u043d\u0434\u043e\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u044b \u043a\u0430\u043a \u00ab\u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u044b\u0435\u00bb. \u0421\u043e\u0441\u0435\u0434\u0438 \u041b\u043e\u043d\u0434\u043e\u043d\u0430 \u2014 \u0420\u0435\u0439\u043a\u044c\u044f\u0432\u0438\u043a \u0438 \u0411\u0435\u0440\u043b\u0438\u043d. \u041d\u043e \u043c\u044b \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u0420\u0435\u0439\u043a\u044c\u044f\u0432\u0438\u043a, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0443\u0436\u0435 \u0431\u044b\u043b\u0438 \u0432 \u043d\u0435\u043c. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0411\u0435\u0440\u043b\u0438\u043d\u0430, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0431\u0440\u0430, \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0435\u0433\u043e \u041b\u043e\u043d\u0434\u043e\u043d \u0438 \u0411\u0435\u0440\u043b\u0438\u043d (3), \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u041b\u043e\u043d\u0434\u043e\u043d\u0430 (4), \u0447\u0442\u043e \u0434\u0430\u0435\u0442 \u043d\u0430\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 7.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/2d9\/717\/971\/2d9717971f0c0399872e02bc0099b6c7.jpeg\" alt=\"img\" width=\"781\" height=\"605\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2d9\/717\/971\/2d9717971f0c0399872e02bc0099b6c7.jpeg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>img<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0442\u043c\u0435\u0447\u0430\u0435\u043c \u041b\u043e\u043d\u0434\u043e\u043d \u043a\u0430\u043a \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u044b\u0439 \u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0443\u0437\u0435\u043b \u2014 \u041e\u0441\u043b\u043e. \u041f\u043e\u0441\u0435\u0449\u0430\u0435\u043c \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u041e\u0441\u043b\u043e \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0438\u0445 \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043c\u043e\u0436\u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u0434\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0434\u043e \u0411\u0435\u0440\u043b\u0438\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 \u041e\u0441\u043b\u043e (\u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c 6), \u0447\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u041b\u043e\u043d\u0434\u043e\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u041c\u043e\u0441\u043a\u0432\u044b \u0441 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0438 \u0434\u043e 8.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/407\/c2b\/f15\/407c2bf15a845b579a4ce9120dba2ba7.jpeg\" alt=\"img\" width=\"781\" height=\"605\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/407\/c2b\/f15\/407c2bf15a845b579a4ce9120dba2ba7.jpeg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>img<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0442\u043c\u0435\u0447\u0430\u0435\u043c \u041e\u0441\u043b\u043e \u043a\u0430\u043a \u00ab\u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u044b\u0439\u00bb \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e 5. \u041c\u0435\u0436\u0434\u0443 \u0411\u0435\u0440\u043b\u0438\u043d\u043e\u043c \u0438 \u041c\u043e\u0441\u043a\u0432\u043e\u0439 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0411\u0435\u0440\u043b\u0438\u043d \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (6) \u043d\u0438\u0436\u0435, \u0447\u0435\u043c \u0443 \u041c\u043e\u0441\u043a\u0432\u044b (8). \u0414\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u043c \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u0440\u0430\u043d\u044c\u0448\u0435: \u043f\u043e\u0441\u0435\u0449\u0430\u0435\u043c \u0420\u0438\u043c \u0438 \u0411\u0435\u043b\u0433\u0440\u0430\u0434 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0438\u0445 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u0411\u0435\u0440\u043b\u0438\u043d \u043a\u0430\u043a \u00ab\u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u044b\u0439\u00bb \u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0433\u043e\u0440\u043e\u0434\u0443.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/b6f\/fa0\/e69\/b6ffa0e6923facc890519556240c3716.jpeg\" alt=\"img\" width=\"781\" height=\"605\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b6f\/fa0\/e69\/b6ffa0e6923facc890519556240c3716.jpeg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>img<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u044b \u0443\u0436\u0435 \u043d\u0430\u0448\u043b\u0438 \u043f\u0443\u0442\u044c \u0438\u0437 \u0420\u0435\u0439\u043a\u044c\u044f\u0432\u0438\u043a\u0430 \u0432 \u0411\u0435\u043b\u0433\u0440\u0430\u0434 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c 15. \u041d\u043e \u043b\u0443\u0447\u0448\u0438\u0439 \u043b\u0438 \u043e\u043d?<\/p>\n<p>\u041d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c. \u041e\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u0443\u0442\u0438, \u0438\u043c \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0420\u0435\u0439\u043a\u044c\u044f\u0432\u0438\u043a <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3ce\/9ab\/024\/3ce9ab024e710e8a1b507d5a02b39256.svg\" width=\"32\" height=\"13\"\/> \u041e\u0441\u043b\u043e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/52c\/6df\/284\/52c6df284f07ce4da222444dd0018202.svg\" width=\"32\" height=\"13\"\/> \u0411\u0435\u0440\u043b\u0438\u043d <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a16\/1ef\/194\/a161ef19427f0b0bcb75496c25a3befa.svg\" width=\"32\" height=\"13\"\/> \u0420\u0438\u043c <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/574\/231\/774\/5742317740b8f91d431fa22d5521c1d8.svg\" width=\"32\" height=\"13\"\/> \u0410\u0444\u0438\u043d\u044b <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\longrightarrow\" alt=\"\\longrightarrow\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cd6\/e77\/a6e\/cd6e77a6e681cabc6e564f5a0084c1f3.svg\" width=\"32\" height=\"13\"\/> \u0411\u0435\u043b\u0433\u0440\u0430\u0434 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c 11.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/97e\/b2c\/605\/97eb2c60561a6b7813423a849a8b05e4.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/97e\/b2c\/605\/97eb2c60561a6b7813423a849a8b05e4.gif\"\/><\/figure>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b \u043d\u0430 Python.<\/p>\n<p><strong>\u041a\u043b\u0430\u0441\u0441 Graph.<\/strong> \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <code>Graph<\/code>. \u042d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u043d\u0435 \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b, \u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0431\u043e\u043b\u0435\u0435 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e\u0439.<\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0433\u0440\u0430\u0444 \u043a\u0430\u043a \u0441\u043b\u043e\u0432\u0430\u0440\u044c. \u041a\u043b\u044e\u0447\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0433\u043e\u0440\u043e\u0434\u0430\u043c, \u0430 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0440\u0451\u0431\u0440\u0430\u043c, \u0433\u0434\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0434\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0433\u043e\u0440\u043e\u0434\u043e\u0432 \u043d\u0430 \u0433\u0440\u0430\u0444\u0435:<\/p>\n<pre><code class=\"python\">import sys   class Graph(object):     def __init__(self, nodes, init_graph):         self.nodes = nodes         self.graph = self.construct_graph(nodes, init_graph)              def construct_graph(self, nodes, init_graph):         '''         \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a\u0430: \u0435\u0441\u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0443\u0442\u044c \u043e\u0442 \u0443\u0437\u043b\u0430 A \u043a B \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c V, \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0443\u0442\u044c \u043e\u0442 \u0443\u0437\u043b\u0430 B \u043a \u0443\u0437\u043b\u0443 A \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c V.         '''         graph = {}         for node in nodes:             graph[node] = {}                  graph.update(init_graph)                  for node, edges in graph.items():             for adjacent_node, value in edges.items():                 if graph[adjacent_node].get(node, False) == False:                     graph[adjacent_node][node] = value                              return graph          def get_nodes(self):         \"\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u0437\u043b\u044b \u0433\u0440\u0430\u0444\u0430\"         return self.nodes          def get_outgoing_edges(self, node):         \"\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0443\u0437\u043b\u0430\"         connections = []         for out_node in self.nodes:             if self.graph[node].get(out_node, False) != False:                 connections.append(out_node)         return connections          def value(self, node1, node2):         \"\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0431\u0440\u0430 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0443\u0437\u043b\u0430\u043c\u0438.\"         return self.graph[node1][node2] <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/283\/011\/085\/283011085792e5b6a137b32d2c8f66e8.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/283\/011\/085\/283011085792e5b6a137b32d2c8f66e8.gif\"\/><\/figure>\n<p><strong>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/strong> \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<pre><code class=\"python\">def dijkstra_algorithm(graph, start_node): <\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430: <code>graph<\/code> \u0438 <code>start_node<\/code>. <code>graph<\/code> \u2014 \u044d\u0442\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Graph<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a <code>start_node<\/code> \u2014 \u044d\u0442\u043e \u0443\u0437\u0435\u043b, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f. \u041c\u044b \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>get_nodes()<\/code> \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0435\u043f\u043e\u0441\u0435\u0449\u0451\u043d\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432:<\/p>\n<pre><code class=\"python\">unvisited_nodes = list(graph.get_nodes()) <\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0430 \u0441\u043b\u043e\u0432\u0430\u0440\u044f, <code>shorttest_path<\/code> \u0438 <code>previous_nodes<\/code>:<\/p>\n<ul>\n<li>\n<p><code>Shorttest_path<\/code> \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0443\u044e \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0433\u043e\u0440\u043e\u0434\u0430 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 start_node. \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p><code>previous_nodes<\/code> \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0442\u0440\u0430\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u043b\u0443\u0447\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0434\u043e \u0411\u0435\u0440\u043b\u0438\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 \u041e\u0441\u043b\u043e, <code>previous_nodes[\"\u0411\u0435\u0440\u043b\u0438\u043d\"]<\/code> \u0432\u0435\u0440\u043d\u0435\u0442 \u00ab\u041e\u0441\u043b\u043e\u00bb, \u0430 <code>previous_nodes[\u041e\u0441\u043b\u043e]<\/code> \u0432\u0435\u0440\u043d\u0435\u0442 \u00ab\u0420\u0435\u0439\u043a\u044c\u044f\u0432\u0438\u043a\u00bb. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0439 \u043f\u0443\u0442\u044c.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">    shortest_path = {}     previous_nodes = {}     # \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c max_value \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \"\u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0438\" \u043d\u0435\u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432        max_value = sys.maxsize     for node in unvisited_nodes:         shortest_path[node] = max_value     # \u041e\u0434\u043d\u0430\u043a\u043e \u043c\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430 0        shortest_path[start_node] = 0 <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. \u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u0441\u0435\u0442\u0438\u0442 \u0432\u0441\u0435 \u0443\u0437\u043b\u044b \u0432 \u0433\u0440\u0430\u0444\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u044d\u0442\u043e \u043a\u0430\u043a \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 <code>while<\/code>.<\/p>\n<pre><code class=\"python\">while unvisited_nodes: <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u043e\u0441\u0435\u0449\u0430\u0442\u044c \u0443\u0437\u043b\u044b. \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0440\u0443\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430\u0439\u0442\u0438 \u0443\u0437\u0435\u043b \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c.<\/p>\n<pre><code class=\"python\">        current_min_node = None         for node in unvisited_nodes: # Iterate over the nodes             if current_min_node == None:                 current_min_node = node             elif shortest_path[node] &lt; shortest_path[current_min_node]:                 current_min_node = node <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0441\u0435\u0449\u0430\u0435\u0442 \u0432\u0441\u0435\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0443\u0437\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0449\u0435 \u043d\u0435 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u044b. \u0415\u0441\u043b\u0438 \u043d\u043e\u0432\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u0441\u043e\u0441\u0435\u0434\u0443 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043b\u0443\u0447\u0448\u0438\u0439 \u043f\u0443\u0442\u044c, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u043d\u043e\u0441\u0438\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0438 <code>shorttest_path<\/code> \u0438 <code>previous_nodes<\/code>.<\/p>\n<pre><code class=\"python\">        # \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f.         neighbors = graph.get_outgoing_edges(current_min_node)         for neighbor in neighbors:             tentative_value = shortest_path[current_min_node] + graph.value(current_min_node, neighbor)             if tentative_value &lt; shortest_path[neighbor]:                 shortest_path[neighbor] = tentative_value                 # \u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043b\u0443\u0447\u0448\u0438\u0439 \u043f\u0443\u0442\u044c \u043a \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u0443\u0437\u043b\u0443                 previous_nodes[neighbor] = current_min_node <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0435\u0433\u043e \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0443\u0437\u0435\u043b \u043a\u0430\u043a \u00ab\u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u044b\u0439\u00bb:<\/p>\n<pre><code class=\"python\">unvisited_nodes.remove(current_min_node) <\/code><\/pre>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0434\u0432\u0430 \u0441\u043b\u043e\u0432\u0430\u0440\u044f:<\/p>\n<pre><code class=\"python\">return previous_nodes, shortest_path <\/code><\/pre>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435, \u0432\u0435\u0441\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">def dijkstra_algorithm(graph, start_node):     unvisited_nodes = list(graph.get_nodes())       # \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0447\u0442\u043e\u0431\u044b \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043d\u0430 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0435\u0433\u043e \u043f\u043e \u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u0443      shortest_path = {}       # \u0442\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u043c \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0439 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u043c\u0443 \u0443\u0437\u043b\u0443     previous_nodes = {}       # \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c max_value \u043a\u0430\u043a \u221e \u0434\u043b\u044f \u043d\u0435\u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432        max_value = sys.maxsize     for node in unvisited_nodes:         shortest_path[node] = max_value     # \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u043a\u0430\u043a 0       shortest_path[start_node] = 0          # \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u0441\u0435\u0442\u0438\u043c \u0432\u0441\u0435 \u0443\u0437\u043b\u044b     while unvisited_nodes:         # \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0443\u0437\u0435\u043b \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u043e\u0446\u0435\u043d\u043a\u043e\u0439         current_min_node = None         for node in unvisited_nodes: # Iterate over the nodes             if current_min_node == None:                 current_min_node = node             elif shortest_path[node] &lt; shortest_path[current_min_node]:                 current_min_node = node                          # \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0438\u0445 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f         neighbors = graph.get_outgoing_edges(current_min_node)         for neighbor in neighbors:             tentative_value = shortest_path[current_min_node] + graph.value(current_min_node, neighbor)             if tentative_value &lt; shortest_path[neighbor]:                 shortest_path[neighbor] = tentative_value                 # We also update the best path to the current node                 previous_nodes[neighbor] = current_min_node           # \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043e\u0442\u043c\u0435\u0447\u0430\u0435\u043c \u0443\u0437\u0435\u043b \u043a\u0430\u043a \"\u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u044b\u0439\"         unvisited_nodes.remove(current_min_node)          return previous_nodes, shortest_path <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/811\/799\/7e3\/8117997e3c5c46374f8b66eaf1594f46.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/811\/799\/7e3\/8117997e3c5c46374f8b66eaf1594f46.gif\"\/><\/figure>\n<p><strong>\u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u0435\u0447\u0430\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.<\/strong> \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0434\u0432\u0430 \u0441\u043b\u043e\u0432\u0430\u0440\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>dijskstra_algorithm<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u043d\u0430 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u043e\u0432. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0430 \u0441\u043b\u043e\u0432\u0430\u0440\u044f, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043b\u0443\u0447\u0448\u0438\u0439 \u043f\u0443\u0442\u044c \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u0446\u0435\u043d\u043a\u0443.<\/p>\n<pre><code class=\"python\">def print_result(previous_nodes, shortest_path, start_node, target_node):     path = []     node = target_node          while node != start_node:         path.append(node)         node = previous_nodes[node]       # Add the start node manually     path.append(start_node)          print(\"\u041d\u0430\u0439\u0434\u0435\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043b\u0443\u0447\u0448\u0438\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 {}.\".format(shortest_path[target_node]))     print(\" -> \".join(reversed(path))) <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2a5\/20b\/3ad\/2a520b3ad2b1ad458f7255912aea6814.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2a5\/20b\/3ad\/2a520b3ad2b1ad458f7255912aea6814.gif\"\/><\/figure>\n<p><strong>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c.<\/strong> \u0412\u0440\u0443\u0447\u043d\u0443\u044e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0443\u0437\u043b\u044b \u0438 \u0438\u0445 \u0440\u0451\u0431\u0440\u0430.<\/p>\n<pre><code class=\"python\">nodes = [\"Reykjavik\", \"Oslo\", \"Moscow\", \"London\", \"Rome\", \"Berlin\", \"Belgrade\", \"Athens\"]   init_graph = {} for node in nodes:     init_graph[node] = {}      init_graph[\"Reykjavik\"][\"Oslo\"] = 5 init_graph[\"Reykjavik\"][\"London\"] = 4 init_graph[\"Oslo\"][\"Berlin\"] = 1 init_graph[\"Oslo\"][\"Moscow\"] = 3 init_graph[\"Moscow\"][\"Belgrade\"] = 5 init_graph[\"Moscow\"][\"Athens\"] = 4 init_graph[\"Athens\"][\"Belgrade\"] = 1 init_graph[\"Rome\"][\"Berlin\"] = 2 init_graph[\"Rome\"][\"Athens\"] = 2 <\/code><\/pre>\n<p>\u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Graph<\/code>.<\/p>\n<pre><code class=\"python\">graph = Graph(nodes, init_graph) <\/code><\/pre>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043d\u0430\u0448 \u0433\u0440\u0430\u0444 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>dijkstra_algorithm()<\/code>.<\/p>\n<pre><code class=\"python\">previous_nodes, shortest_path = dijkstra_algorithm(graph=graph, start_node=\"Reykjavik\") <\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:<\/p>\n<pre><code class=\"python\">print_result(previous_nodes, shortest_path, start_node=\"Reykjavik\", target_node=\"Belgrade\") <\/code><\/pre>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e!<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5ee\/548\/01e\/5ee54801ed4e7062480ff86e07614fcc.gif\" width=\"1\" height=\"1\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5ee\/548\/01e\/5ee54801ed4e7062480ff86e07614fcc.gif\"\/><\/figure>\n<h2>The end<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0442\u043e, \u0447\u0442\u043e \u0441 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e 99% \u043f\u043e\u043f\u0430\u0434\u0451\u0442\u0441\u044f \u043d\u0430 \u0430\u043b\u0433\u043e\u0441\u043e\u0431\u0435\u0441\u0435: \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437, \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0440\u0430\u0437\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438, \u043d\u0443 \u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b \u043a\u0430\u043a \u0431\u043e\u043d\u0443\u0441.<\/p>\n<p>\u0412\u043e\u043e\u0431\u0449\u0435, \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0439 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0438\u0441\u0442\u0430\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u043f\u043e \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438 \u0432\u043e\u0442 \u044d\u0442\u043e:<\/p>\n<ul>\n<li>\n<p>\u00ab\u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u043e Computer Science\u00bb \u2014 \u0412\u043b\u0430\u0434\u0441\u0442\u043e\u043d \u0424\u0435\u0440\u0440\u0435\u0439\u0440\u0430 \u0424\u0438\u043b\u043e, \u041c\u043e\u0442\u043e \u041f\u0438\u043a\u0442\u0435\u0442<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u00ab\u0413\u0440\u043e\u043a\u0430\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b\u00bb \u2014 \u0410\u0434\u0438\u0442\u044c\u044f \u0411\u0445\u0430\u0440\u0433\u0430\u0432\u0430<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043a\u0438\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043b\u044e\u0431\u0438\u043c\u044b\u0435 \u043a\u043d\u0438\u0433\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0445, \u0443\u0432\u0435\u0440\u0435\u043d, \u043c\u043d\u043e\u0433\u0438\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e<\/p>\n<p>\u0423\u0441\u043f\u0435\u0448\u043d\u044b\u0445 \u0441\u043e\u0431\u0435\u0441\u043e\u0432)<\/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\/794556\/\"> https:\/\/habr.com\/ru\/articles\/794556\/<\/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<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0422\u0430\u043a \u0443\u0436 \u043f\u043e\u0432\u0435\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043b\u044e\u0431\u043e\u0439 \u0443\u0432\u0430\u0436\u0430\u044e\u0449\u0438\u0439 \u0441\u0435\u0431\u044f \u0440\u0430\u0431\u043e\u0442\u043e\u0434\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0438 FAANG \u2014 \u043f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043e \u0432\u0441\u0435\u0445 IT-\u0441\u043e\u0431\u0435\u0441\u0430\u0445 \u0435\u0441\u0442\u044c \u043e\u043d\u0430: <em>\u0441\u0435\u043a\u0446\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432<\/em>. \u041a\u0442\u043e-\u0442\u043e \u0435\u0439 \u0440\u0430\u0434, \u043a\u0442\u043e-\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c, \u043d\u043e \u0441\u0435\u043a\u0446\u0438\u044f \u0435\u0441\u0442\u044c \u0438 \u0443\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043a\u0430\u0442\u0430\u0442\u044c \u0440\u0443\u043a\u0430\u0432\u0430 \u0438 \u0434\u043e\u0441\u0442\u043e\u0439\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u0441\u0443\u0440\u043e\u0432\u0443\u044e \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u041f\u0440\u0438 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0440\u0430\u0441\u0441\u043b\u0430\u0431\u044c\u0442\u0435\u0441\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0439\u0442\u0435 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435, \u0432\u0435\u0434\u044c \u0435\u0441\u0442\u044c \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u0430\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u0432\u043d\u0435 \u0441\u043e\u0431\u0435\u0441\u0430. \u041a\u0442\u043e \u0437\u043d\u0430\u0435\u0442, \u043c\u043e\u0436\u0435\u0442 \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0443\u043c\u0435\u043d\u0438\u0435 \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0441\u043f\u0430\u0441\u0442\u0438 \u0432\u0430\u043c \u043c\u0438\u0440 (\u043a\u0430\u043a \u0438 \u0437\u043d\u0430\u043d\u0438\u0435 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043e\u043a):<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0414\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435, \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0437\u0430\u043b\u0438\u043f\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c; \u041c\u0438\u0448\u0430 \u041b\u043e\u043c\u043e\u043d\u043e\u0441\u043e\u0432 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u0443\u043c \u0432 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442.<\/p>\n<p><em>\u0420\u0430\u0437\u0431\u043e\u0440 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u0441 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 <\/em>Python <a href=\"https:\/\/t.me\/+b9siS41vBj0wMzg6\" rel=\"noopener noreferrer nofollow\">\u0432 \u043c\u043e\u0435\u043c \u043a\u0430\u043d\u0430\u043b\u0435<\/a> \u0438 \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u043e <a href=\"https:\/\/t.me\/+FQIu7j2fWU4zZWVi\" rel=\"noopener noreferrer nofollow\">\u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e<\/a>, <em> \u0430 \u0437\u0434\u0435\u0441\u044c \u0441\u043e\u0431\u0440\u0430\u043d\u0430 <\/em><a href=\"https:\/\/t.me\/addlist\/8vDUwYRGujRmZjFi\" rel=\"noopener noreferrer nofollow\"><em>\u0446\u0435\u043b\u0430\u044f \u043f\u0430\u043f\u043a\u0430 <\/em><\/a><em>\u0441 \u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u043a \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u043c.<\/em><\/p>\n<p>\u0422\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043e\u0447\u0435\u043d\u044c \u0432\u0435\u043b\u0438\u043a\u0430, \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0435\u043c\u0430\u043b\u043e \u0432\u0441\u0435\u0433\u043e) \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0442\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0438 \u043f\u0440\u0430\u0432\u0434\u0430 \u043e\u0431\u0448\u0438\u0440\u043d\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043a\u043e\u0441\u043d\u0451\u043c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u044b\u0445 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0432\u0435\u0449\u0435\u0439:<\/p>\n<ul>\n<li>\n<p><a href=\"#1\" rel=\"noopener noreferrer nofollow\">\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u043a\u0430 \u0438 \u041e-\u043d\u043e\u0442\u0430\u0446\u0438\u044f<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#2\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445: \u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u0441\u0442\u0435\u043a, \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, map \u0438 \u0434\u0440\u0443\u0433\u0438\u0435<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#3\" rel=\"noopener noreferrer nofollow\">\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438<\/a><\/p>\n<\/li>\n<li>\n<p>\u0438 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u2014 <a href=\"#4\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b<\/a>; \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u043a\u043e\u0441\u043d\u0443\u0442\u044c\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e  <\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \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 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 Python, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u0442\u0435\u0441\u0442\u0438\u0442\u044c, \u043a\u0430\u043a \u0432\u0441\u0451 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/p>\n<p>\u041f\u043e\u0435\u0445\u0430\u043b\u0438!<\/p>\n<figure class=\"\"><\/figure>\n<p><a class=\"anchor\" name=\"1\" id=\"1\"><\/a><\/p>\n<h2>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438 \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437<\/h2>\n<p>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u044e\u0442 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043f\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 (\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c). \u0412 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445: \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 100 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0438\u0437 1000. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u043e\u0447\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u0430\u043b\u043e \u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442: \u043e\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0412\u0430\u0436\u043d\u0430 \u043b\u0438\u0448\u044c \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u0442. \u0435. \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0441\u0442\u0440\u0435\u043c\u043b\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c <code>4n^3 + 7n<\/code> \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c <code>n<\/code> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 <code>n<\/code> \u043d\u0430 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043b\u0438\u044f\u0442\u044c \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 <code>n<\/code> \u0432 \u043a\u0443\u0431, \u0447\u0435\u043c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u043d\u0430 <code>4<\/code> \u0438\u043b\u0438 \u0436\u0435 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 <code>7n<\/code>. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0440\u0430\u0432\u043d\u0430 <code>\u041e(n^3)<\/code>, \u0442. \u0435. \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0443\u0431\u0438\u0447\u0435\u0441\u043a\u0438.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0431\u0443\u043a\u0432\u044b \u041e (\u041e-\u043d\u043e\u0442\u0430\u0446\u0438\u044f) \u043f\u0440\u0438\u0448\u043b\u043e \u0438\u0437 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438, \u0433\u0434\u0435 \u0435\u0451 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0424\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e <code>O(f(n))<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 (\u0438\u043b\u0438 \u043e\u0431\u044a\u0451\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438) \u0440\u0430\u0441\u0442\u0451\u0442 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u0431\u044a\u0451\u043c\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u043d\u0430 <code>f(n)<\/code>.<\/p>\n<p>\u0412\u0441\u0442\u0440\u0435\u0447\u0430\u0439\u0442\u0435 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u0435\u0439 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"\"><\/figure>\n<h3>O(1) \u2014 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>\u0421\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u043e\u0433\u0434\u0430 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u043a\u0430\u043a <code>O(1)<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043d\u0438 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043d\u0438 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e \u043d\u0438\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e-\u0442\u043e \u0440\u0430\u0437. \u0412\u0441\u0435\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0442\u043e\u043a\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0440\u0435\u0442\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c, \u043d\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0443\u0436\u043d\u043e \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>\u0425\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e O(1): \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<figure class=\"\"><\/figure>\n<h3>O(n) \u2014 \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>\u0422\u0430\u043a\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u043d\u0435 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0435. \u041d\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u0432\u0441\u0435\u043c <code>n<\/code> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439.<\/p>\n<figure class=\"\"><\/figure>\n<h3>O(log n) \u2014 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a. \u0415\u0441\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0432 \u043d\u0451\u043c \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043f\u043e\u043b\u0430\u043c. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0435\u0441\u043b\u0438 \u043e\u043d \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u0441\u043a\u043e\u043c\u043e\u0433\u043e, \u0442\u043e \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u043c \u0432\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u2014 \u0442\u0430\u043c \u0435\u0433\u043e \u0442\u043e\u0447\u043d\u043e \u043d\u0435\u0442. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043c\u0435\u043d\u044c\u0448\u0435, \u0442\u043e \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u2014 \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443. \u0418 \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u043f\u043e\u043b\u0430\u043c, \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c <code>log n<\/code> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>\u0412\u043e\u0442 \u043d\u0438\u0436\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0448\u0430\u0433\u043e\u0432 \u043f\u0440\u0438 \u043f\u043e\u0438\u0441\u043a\u0435 \u0447\u0438\u0441\u043b\u0430 47 \u0432 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0435.<\/p>\n<figure class=\"full-width\"><\/figure>\n<h3>O(n^2) \u2014 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>\u0422\u0430\u043a\u0443\u044e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0430\u043c\u0438. \u0412 \u043a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0434\u0432\u0430 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0446\u0438\u043a\u043b\u0430: \u043e\u0434\u0438\u043d, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0443, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0441\u0442\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0432 \u0443\u0436\u0435 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043a\u0430\u043a <code>n*n<\/code>, \u0442. \u0435. <code>n^2<\/code>.<\/p>\n<figure class=\"\"><\/figure>\n<h3>\u0412 \u0438\u0442\u043e\u0433\u0435<\/h3>\n<p>\u041b\u0443\u0447\u0448\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0438\u043c\u0435\u044e\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c O(1) \u0438\u043b\u0438 O(log n), \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0440\u0430\u0441\u0442\u0451\u0442 \u0441\u043b\u0430\u0431\u043e \u043f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0434\u043b\u044f \u041e(1). \u0425\u0443\u0434\u0448\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0438\u043c\u0435\u044e\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c O(n!), O(2^n) \u0438\u043b\u0438 O(n^2), \u0447\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u0435\u0442 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041a\u0430\u043a \u0440\u0430\u0441\u0442\u0451\u0442 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0438\u0434\u043e\u0432 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f, \u043f\u043e\u0438\u0441\u043a\u0430 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u043b\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0441\u0442\u0435\u043a\u0430, \u0441\u0432\u044f\u0437\u043d\u044b\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0421\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u043f\u043e\u0435\u0445\u0430\u043b\u0438 \u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445!<\/p>\n<figure class=\"\"><\/figure>\n<p><a class=\"anchor\" name=\"2\" id=\"2\"><\/a><\/p>\n<h2>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/p>\n<\/li>\n<li>\n<p>\u0441\u0442\u0435\u043a<\/p>\n<\/li>\n<li>\n<p>\u043e\u0447\u0435\u0440\u0435\u0434\u044c<\/p>\n<\/li>\n<li>\n<p>\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e<\/p>\n<\/li>\n<li>\n<p>map<\/p>\n<\/li>\n<li>\n<p>\u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/p>\n<\/li>\n<li>\n<p>\u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043f\u043e\u0438\u0441\u043a\u0430<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e<\/p>\n<\/li>\n<li>\n<p>\u0434\u0432\u043e\u0438\u0447\u043d\u0430\u044f \u043a\u0443\u0447\u0430<\/p>\n<\/li>\n<li>\n<p>\u0433\u0440\u0430\u0444<\/p>\n<\/li>\n<\/ul>\n<figure class=\"\"><\/figure>\n<h3>\u0421\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/h3>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/figcaption><\/div>\n<\/figure>\n<p><strong>\u0421\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/strong> \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0435 \u0447\u0430\u0441\u0442\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u043d\u043e\u0433\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043b\u0438\u0431\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043b\u0438\u0431\u043e \u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<p>\u0421\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0433\u0440\u0443\u043f\u043f\u044b \u0443\u0437\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0435 \u0432\u0435\u0449\u0438: \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043d\u0435\u043c \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f (\u044d\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430) \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c (\u0438\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0443) \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0443\u0437\u0435\u043b \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0421\u0430\u043c\u044b\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0433\u043e\u043b\u043e\u0432\u043e\u0439 (<em>head<\/em>) \u043e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430, \u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u2014 \u0445\u0432\u043e\u0441\u0442\u043e\u043c (<em>tail<\/em>). \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 null-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0433\u0434\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0432 \u043e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0445\u0430\u043e\u0442\u0438\u0447\u043d\u043e \u0438 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u0443\u0437\u043b\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0441\u0441\u044b\u043b\u043e\u043a. \u0417\u0430 \u0441\u0447\u0451\u0442 \u044d\u0442\u043e\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0432 \u043e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043e\u0434\u043d\u0430\u043a\u043e, \u0434\u043e\u0441\u0442\u0443\u043f \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0432 \u043e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u043d\u0435\u0442.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 <strong>\u0434\u0432\u0443\u0441\u0432\u044f\u0437\u043d\u044b\u0435 \u0441\u043f\u0438\u0441\u043a\u0438<\/strong>: \u0432 \u043d\u0438\u0445 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0435\u0441\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0438 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439, \u0438 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435. \u0415\u0441\u0442\u044c \u0435\u0449\u0451 <strong>\u043a\u043e\u043b\u044c\u0446\u0435\u0432\u043e\u0439 \u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/strong> \u2014 \u0443 \u043d\u0435\u0433\u043e <strong>\u0445\u0432\u043e\u0441\u0442<\/strong> (\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0443\u0437\u0435\u043b) \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <strong>\u0433\u043e\u043b\u043e\u0432\u0443<\/strong> (\u043f\u0435\u0440\u0432\u044b\u0439 \u0443\u0437\u0435\u043b).<\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0443\u0437\u043b\u0430 \u0441 \u0447\u0438\u0441\u043b\u043e\u043c 99 \u0438\u0437 \u043e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0421\u0432\u044f\u0437\u043d\u044b\u0435 \u0441\u043f\u0438\u0441\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0435\u043a\u0430 \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 (\u0437\u0434\u0435\u0441\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0432\u044f\u0437\u043d\u044b\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u044b).<\/p>\n<p><strong>\u0421\u0442\u0435\u043a<\/strong><\/p>\n<ul>\n<li>\n<p>\u044d\u0442\u043e <strong>LIFO<\/strong>-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (<a href=\"https:\/\/ru.wikipedia.org\/wiki\/LIFO\" rel=\"noopener noreferrer nofollow\">last in, first out<\/a>)<\/p>\n<\/li>\n<li>\n<p>\u0433\u043e\u043b\u043e\u0432\u0430 \u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430, \u043b\u0435\u0436\u0430\u0449\u0435\u0433\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0442\u0435\u043a\u0430, \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041e\u0447\u0435\u0440\u0435\u0434\u044c<\/strong><\/p>\n<ul>\n<li>\n<p>\u044d\u0442\u043e <strong>FIFO<\/strong>-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (<a href=\"https:\/\/ru.wikipedia.org\/wiki\/FIFO\" rel=\"noopener noreferrer nofollow\">first in, first out<\/a>)<\/p>\n<\/li>\n<li>\n<p>\u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u0432\u0443\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u0437 \u0433\u043e\u043b\u043e\u0432\u044b, \u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0445\u0432\u043e\u0441\u0442<\/p>\n<\/li>\n<\/ul>\n<figure class=\"\"><\/figure>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441\u043e \u0441\u0432\u044f\u0437\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/p>\n<\/th>\n<th>\n<p>\u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u043f\u043e\u0438\u0441\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(n)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(1)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(n)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u043e\u0434 \u0443\u0441\u043b\u043e\u0432\u0438\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">O(n)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<figure class=\"\"><\/figure>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430 Python:<\/p>\n<pre><code class=\"python\">class Node(object):     # \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 data \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c next \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0443\u0437\u0435\u043b     def __init__(self, data, next = None):         self.data = data;         self.next = next;      def setData(self, data):         self.data = data;              def getData(self):  # \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f data \u0438\u0437 \u0443\u0437\u043b\u0430         return self.data      def setNext(self, next):  # \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430         self.next = next      def getNext(self):  # \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430         return self.next      class LinkedList(object):     def __init__(self):  # \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c head \u0432 \u0441\u043f\u0438\u0441\u043a\u0435         self.head = None      def printLinkedList(self):  # \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u043c data \u0438\u0437 \u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430         temp = self.head         while(temp):             print(temp.data, end=' ')             temp = temp.next      def insertAtStart(self, data):  # \u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u0443\u0437\u043b\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e         newNode = Node(data)         newNode.next = self.head         self.head = newNode              def insertBetween(self, previousNode, data):  # \u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u0443\u0437\u043b\u0430 \u043f\u043e\u0441\u043b\u0435 previousNode         if (previousNode.next is None):             print('Previous node should have next node!')         else:             newNode = Node(data)             newNode.next = previousNode.next             previousNode.next = newNode                  def insertAtEnd(self, data):  # \u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u0432 \u043a\u043e\u043d\u0435\u0446 \u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430         newNode = Node(data)         temp = self.head         while(temp.next != None):  # get last node             temp = temp.next         temp.next = newNode      def delete(self, data):  # \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e data \u0438\u043b\u0438 key         temp = self.head         if (temp.next is not None):  # \u0435\u0441\u043b\u0438 data\/key \u043d\u0430\u0439\u0434\u0435\u043d \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0443\u0437\u043b\u0435             if(temp.data == data):                 self.head = temp.next                 temp = None                 return             else:                 while(temp.next != None):  # \u0438\u043d\u0430\u0447\u0435 \u0438\u0441\u043a\u0430\u0442\u044c \u0432\u0441\u0435 \u0443\u0437\u043b\u044b                     if(temp.data == data):                         break                     prev = temp                       temp = temp.next                                  if temp == None:  # \u0435\u0441\u043b\u0438 \u0443\u0437\u0435\u043b \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d                     return                                  prev.next = temp.next                 return                  # \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a     def search(self, node, data):         if node == None:  <\/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-368540","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/368540","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=368540"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/368540\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=368540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=368540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=368540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}