2 недели назад
Бинарное дерево поиска python
Okay, let’s dive into implementing a Binary Search Tree (BST) in Python. A Binary Search Tree is a node-based binary tree data structure which has the following properties: The left subtree of a node contains only nodes with keys lesser than the node’s key. The right subtree of a node contains only nodes with keys greater than the node’s key. The left and right subtree each must also be a binary search tree. There must be no duplicate nodes. (Some implementations allow duplicates, but the standard definition usually implies unique keys or special handling for duplicates). Core Components A BST typically involves two classes: Node Class: Represents a single node in the tree...
1159 читали · 4 года назад
Работа с файлами Python. Статья 3 (бинарные файлы)
Мой канал о программировании Old Programmer, а здесь: Тематическое оглавление моего Zen-канала (Old Programmer). А тут материалы по Python. Сегодня рассматриваем файлы с бинарной точки зрения. Материалы по текстовым файлам: статья 1 и статья 2. Чтобы трактовать открываемые файлы как последовательность байтов необходимо, что бы в строке режима открытия присутствовала буква 'b', от слова binary. Эксперимент с бинарным файлом на языке Python Чтобы понять, как работать с файлами в бинарном формате проведем несколько экспериментов...