id int64 0 328k | repository_name stringlengths 7 58 | file_path stringlengths 9 302 | class_name stringlengths 5 256 | human_written_code stringlengths 16 2.16M | class_skeleton stringlengths 18 1.49M ⌀ | total_program_units int64 1 1.76k | total_doc_str int64 0 771 | AvgCountLine float64 0 7.89k | AvgCountLineBlank float64 0 297 | AvgCountLineCode float64 0 7.89k | AvgCountLineComment float64 0 7.89k | AvgCyclomatic float64 0 130 | CommentToCodeRatio float64 0 168 | CountClassBase float64 0 40 | CountClassCoupled float64 0 583 | CountClassCoupledModified float64 0 575 | CountClassDerived float64 0 5.35k | CountDeclInstanceMethod float64 0 529 | CountDeclInstanceVariable float64 0 296 | CountDeclMethod float64 0 599 | CountDeclMethodAll float64 0 1.12k | CountLine float64 1 40.4k | CountLineBlank float64 0 8.16k | CountLineCode float64 1 25.7k | CountLineCodeDecl float64 1 8.15k | CountLineCodeExe float64 0 24.2k | CountLineComment float64 0 16.5k | CountStmt float64 1 9.71k | CountStmtDecl float64 1 8.15k | CountStmtExe float64 0 9.69k | MaxCyclomatic float64 0 759 | MaxInheritanceTree float64 0 16 | MaxNesting float64 0 34 | SumCyclomatic float64 0 2.9k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
15,200 | google/flatbuffers | google_flatbuffers/python/flatbuffers/number_types.py | python.flatbuffers.number_types.Uint8Flags | from . import packer
class Uint8Flags(object):
bytewidth = 1
min_val = 0
max_val = 2 ** 8 - 1
py_type = int
name = 'uint8'
packer_type = packer.uint8 |
class Uint8Flags(object):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 7 | 0 | 7 | 7 | 6 | 0 | 7 | 7 | 6 | 0 | 1 | 0 | 0 |
15,201 | google/flatbuffers | google_flatbuffers/python/flatbuffers/number_types.py | python.flatbuffers.number_types.VOffsetTFlags | class VOffsetTFlags(Uint16Flags):
pass | class VOffsetTFlags(Uint16Flags):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 2 | 0 | 0 |
15,202 | google/flatbuffers | google_flatbuffers/python/flatbuffers/reflection/AdvancedFeatures.py | python.flatbuffers.reflection.AdvancedFeatures.AdvancedFeatures | class AdvancedFeatures(object):
AdvancedArrayFeatures = 1
AdvancedUnionFeatures = 2
OptionalScalars = 4
DefaultVectorsAndStrings = 8 | class AdvancedFeatures(object):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | 0 | 5 | 5 | 4 | 0 | 5 | 5 | 4 | 0 | 1 | 0 | 0 |
15,203 | google/flatbuffers | google_flatbuffers/python/flatbuffers/reflection/BaseType.py | python.flatbuffers.reflection.BaseType.BaseType | class BaseType(object):
None_ = 0
UType = 1
Bool = 2
Byte = 3
UByte = 4
Short = 5
UShort = 6
Int = 7
UInt = 8
Long = 9
ULong = 10
Float = 11
Double = 12
String = 13
Vector = 14
Obj = 15
Union = 16
Array = 17
Vector64 = 18
MaxBaseType = 19 | class BaseType(object):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 21 | 0 | 21 | 21 | 20 | 0 | 21 | 21 | 20 | 0 | 1 | 0 | 0 |
15,204 | google/flatbuffers | google_flatbuffers/python/flatbuffers/reflection/Enum.py | python.flatbuffers.reflection.Enum.Enum | import flatbuffers
class Enum(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = Enum()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsEnum(cls, buf, offs... |
class Enum(object):
@classmethod
def GetRootAs(cls, buf, offset=0):
pass
@classmethod
def GetRootAsEnum(cls, buf, offset=0):
'''This method is deprecated. Please switch to GetRootAs.'''
pass
@classmethod
def EnumBufferHasIdentifier(cls, buf, offset, size_prefixed=False)... | 21 | 1 | 5 | 0 | 5 | 0 | 2 | 0.17 | 1 | 4 | 3 | 0 | 14 | 1 | 17 | 17 | 124 | 16 | 92 | 48 | 68 | 16 | 89 | 45 | 68 | 2 | 1 | 1 | 27 |
15,205 | google/flatbuffers | google_flatbuffers/python/flatbuffers/reflection/EnumVal.py | python.flatbuffers.reflection.EnumVal.EnumVal | import flatbuffers
class EnumVal(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = EnumVal()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsEnumVal(cls, ... |
class EnumVal(object):
@classmethod
def GetRootAs(cls, buf, offset=0):
pass
@classmethod
def GetRootAsEnumVal(cls, buf, offset=0):
'''This method is deprecated. Please switch to GetRootAs.'''
pass
@classmethod
def EnumValBufferHasIdentifier(cls, buf, offset, size_prefix... | 17 | 1 | 5 | 0 | 5 | 0 | 2 | 0.16 | 1 | 2 | 2 | 0 | 10 | 1 | 13 | 13 | 91 | 12 | 68 | 37 | 49 | 11 | 65 | 34 | 49 | 2 | 1 | 1 | 20 |
15,206 | google/flatbuffers | google_flatbuffers/python/flatbuffers/reflection/Field.py | python.flatbuffers.reflection.Field.Field | import flatbuffers
class Field(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = Field()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsField(cls, buf, o... |
class Field(object):
@classmethod
def GetRootAs(cls, buf, offset=0):
pass
@classmethod
def GetRootAsField(cls, buf, offset=0):
'''This method is deprecated. Please switch to GetRootAs.'''
pass
@classmethod
def FieldBufferHasIdentifier(cls, buf, offset, size_prefixed=Fal... | 26 | 1 | 5 | 0 | 5 | 0 | 2 | 0.19 | 1 | 3 | 2 | 0 | 19 | 1 | 22 | 22 | 156 | 21 | 113 | 55 | 85 | 22 | 110 | 52 | 85 | 2 | 1 | 1 | 38 |
15,207 | google/flatbuffers | google_flatbuffers/python/flatbuffers/reflection/KeyValue.py | python.flatbuffers.reflection.KeyValue.KeyValue | import flatbuffers
class KeyValue(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = KeyValue()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsKeyValue(cl... |
class KeyValue(object):
@classmethod
def GetRootAs(cls, buf, offset=0):
pass
@classmethod
def GetRootAsKeyValue(cls, buf, offset=0):
'''This method is deprecated. Please switch to GetRootAs.'''
pass
@classmethod
def KeyValueBufferHasIdentifier(cls, buf, offset, size_pre... | 10 | 1 | 4 | 0 | 4 | 0 | 1 | 0.15 | 1 | 0 | 0 | 0 | 3 | 1 | 6 | 6 | 35 | 5 | 26 | 16 | 16 | 4 | 23 | 13 | 16 | 2 | 1 | 1 | 8 |
15,208 | google/flatbuffers | google_flatbuffers/python/flatbuffers/reflection/Object.py | python.flatbuffers.reflection.Object.Object | import flatbuffers
class Object(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = Object()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsObject(cls, buf... |
class Object(object):
@classmethod
def GetRootAs(cls, buf, offset=0):
pass
@classmethod
def GetRootAsObject(cls, buf, offset=0):
'''This method is deprecated. Please switch to GetRootAs.'''
pass
@classmethod
def ObjectBufferHasIdentifier(cls, buf, offset, size_prefixed=... | 22 | 1 | 5 | 0 | 5 | 0 | 2 | 0.18 | 1 | 3 | 2 | 0 | 15 | 1 | 18 | 18 | 127 | 17 | 93 | 47 | 69 | 17 | 90 | 44 | 69 | 2 | 1 | 1 | 29 |
15,209 | google/flatbuffers | google_flatbuffers/python/flatbuffers/reflection/RPCCall.py | python.flatbuffers.reflection.RPCCall.RPCCall | import flatbuffers
class RPCCall(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = RPCCall()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsRPCCall(cls, ... |
class RPCCall(object):
@classmethod
def GetRootAs(cls, buf, offset=0):
pass
@classmethod
def GetRootAsRPCCall(cls, buf, offset=0):
'''This method is deprecated. Please switch to GetRootAs.'''
pass
@classmethod
def RPCCallBufferHasIdentifier(cls, buf, offset, size_prefix... | 17 | 1 | 5 | 0 | 5 | 0 | 2 | 0.15 | 1 | 2 | 2 | 0 | 10 | 1 | 13 | 13 | 95 | 12 | 72 | 40 | 52 | 11 | 69 | 37 | 52 | 2 | 1 | 1 | 20 |
15,210 | google/flatbuffers | google_flatbuffers/python/flatbuffers/reflection/Schema.py | python.flatbuffers.reflection.Schema.Schema | import flatbuffers
class Schema(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = Schema()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsSchema(cls, buf... |
class Schema(object):
@classmethod
def GetRootAs(cls, buf, offset=0):
pass
@classmethod
def GetRootAsSchema(cls, buf, offset=0):
'''This method is deprecated. Please switch to GetRootAs.'''
pass
@classmethod
def SchemaBufferHasIdentifier(cls, buf, offset, size_prefixed=... | 24 | 1 | 6 | 0 | 6 | 0 | 2 | 0.17 | 1 | 4 | 4 | 0 | 17 | 1 | 20 | 20 | 155 | 19 | 116 | 59 | 87 | 20 | 113 | 56 | 87 | 2 | 1 | 1 | 32 |
15,211 | google/flatbuffers | google_flatbuffers/python/flatbuffers/reflection/SchemaFile.py | python.flatbuffers.reflection.SchemaFile.SchemaFile | import flatbuffers
class SchemaFile(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = SchemaFile()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsSchemaF... |
class SchemaFile(object):
@classmethod
def GetRootAs(cls, buf, offset=0):
pass
@classmethod
def GetRootAsSchemaFile(cls, buf, offset=0):
'''This method is deprecated. Please switch to GetRootAs.'''
pass
@classmethod
def SchemaFileBufferHasIdentifier(cls, buf, offset, si... | 12 | 1 | 4 | 0 | 4 | 0 | 1 | 0.23 | 1 | 0 | 0 | 0 | 5 | 1 | 8 | 8 | 50 | 7 | 35 | 21 | 23 | 8 | 32 | 18 | 23 | 2 | 1 | 1 | 11 |
15,212 | google/flatbuffers | google_flatbuffers/python/flatbuffers/reflection/Service.py | python.flatbuffers.reflection.Service.Service | import flatbuffers
class Service(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = Service()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsService(cls, ... |
class Service(object):
@classmethod
def GetRootAs(cls, buf, offset=0):
pass
@classmethod
def GetRootAsService(cls, buf, offset=0):
'''This method is deprecated. Please switch to GetRootAs.'''
pass
@classmethod
def ServiceBufferHasIdentifier(cls, buf, offset, size_prefix... | 19 | 1 | 5 | 0 | 5 | 0 | 2 | 0.18 | 1 | 2 | 2 | 0 | 12 | 1 | 15 | 15 | 106 | 14 | 78 | 41 | 57 | 14 | 75 | 38 | 57 | 2 | 1 | 1 | 23 |
15,213 | google/flatbuffers | google_flatbuffers/python/flatbuffers/reflection/Type.py | python.flatbuffers.reflection.Type.Type | import flatbuffers
class Type(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = Type()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsType(cls, buf, offs... |
class Type(object):
@classmethod
def GetRootAs(cls, buf, offset=0):
pass
@classmethod
def GetRootAsType(cls, buf, offset=0):
'''This method is deprecated. Please switch to GetRootAs.'''
pass
@classmethod
def TypeBufferHasIdentifier(cls, buf, offset, size_prefixed=False)... | 14 | 1 | 4 | 0 | 4 | 0 | 2 | 0.22 | 1 | 0 | 0 | 0 | 7 | 1 | 10 | 10 | 65 | 9 | 46 | 24 | 32 | 10 | 43 | 21 | 32 | 2 | 1 | 1 | 16 |
15,214 | google/flatbuffers | google_flatbuffers/python/flatbuffers/table.py | python.flatbuffers.table.Table | from . import number_types as N
from . import encode
class Table(object):
"""Table wraps a byte slice and provides read access to its data.
The variable `Pos` indicates the root of the FlatBuffers object therein."""
__slots__ = ('Bytes', 'Pos')
def __init__(self, buf, pos):
N.enforce_number(p... |
class Table(object):
'''Table wraps a byte slice and provides read access to its data.
The variable `Pos` indicates the root of the FlatBuffers object therein.'''
def __init__(self, buf, pos):
pass
def Offset(self, vtableOffset):
'''Offset provides access into the Table's vtable.
... | 13 | 11 | 9 | 1 | 5 | 3 | 1 | 0.52 | 1 | 5 | 3 | 0 | 12 | 2 | 12 | 12 | 120 | 22 | 65 | 28 | 52 | 34 | 65 | 28 | 52 | 3 | 1 | 1 | 16 |
15,215 | google/flatbuffers | google_flatbuffers/grpc/examples/python/greeter/server.py | server.GreeterServicer | from models import HelloReply, HelloRequest, greeter_grpc_fb
class GreeterServicer(greeter_grpc_fb.GreeterServicer):
def __init__(self):
self.greetings = ['Hi', 'Hallo', 'Ciao']
def SayHello(self, request, context):
r = HelloRequest.HelloRequest().GetRootAs(request, 0)
reply = 'Unknow... |
class GreeterServicer(greeter_grpc_fb.GreeterServicer):
def __init__(self):
pass
def SayHello(self, request, context):
pass
def SayManyHellos(self, request, context):
pass | 4 | 0 | 6 | 0 | 5 | 0 | 2 | 0 | 1 | 2 | 1 | 0 | 3 | 1 | 3 | 5 | 21 | 4 | 17 | 10 | 13 | 0 | 17 | 10 | 13 | 3 | 2 | 1 | 6 |
15,216 | keon/algorithms | keon_algorithms/algorithms/tree/bst/BSTIterator.py | BSTIterator.BSTIterator | class BSTIterator:
def __init__(self, root):
self.stack = []
while root:
self.stack.append(root)
root = root.left
def has_next(self):
return bool(self.stack)
def next(self):
node = self.stack.pop()
tmp = node
if tmp.right:
... | class BSTIterator:
def __init__(self, root):
pass
def has_next(self):
pass
def next(self):
pass | 4 | 0 | 5 | 0 | 5 | 0 | 2 | 0 | 0 | 1 | 0 | 0 | 3 | 1 | 3 | 3 | 19 | 2 | 17 | 7 | 13 | 0 | 17 | 7 | 13 | 3 | 0 | 2 | 6 |
15,217 | keon/algorithms | keon_algorithms/algorithms/tree/trie/add_and_search.py | add_and_search.TrieNode | class TrieNode(object):
def __init__(self, letter, is_terminal=False):
self.children = dict()
self.letter = letter
self.is_terminal = is_terminal | class TrieNode(object):
def __init__(self, letter, is_terminal=False):
pass | 2 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 3 | 1 | 1 | 5 | 0 | 5 | 5 | 3 | 0 | 5 | 5 | 3 | 1 | 1 | 0 | 1 |
15,218 | keon/algorithms | keon_algorithms/algorithms/tree/trie/add_and_search.py | add_and_search.WordDictionary | class WordDictionary(object):
def __init__(self):
self.root = TrieNode('')
def add_word(self, word):
cur = self.root
for letter in word:
if letter not in cur.children:
cur.children[letter] = TrieNode(letter)
cur = cur.children[letter]
cur... | class WordDictionary(object):
def __init__(self):
pass
def add_word(self, word):
pass
def search(self, word, node=None):
pass | 4 | 0 | 10 | 0 | 9 | 1 | 5 | 0.1 | 1 | 2 | 1 | 0 | 3 | 1 | 3 | 3 | 33 | 2 | 29 | 10 | 25 | 3 | 29 | 10 | 25 | 10 | 1 | 5 | 14 |
15,219 | keon/algorithms | keon_algorithms/algorithms/tree/trie/add_and_search.py | add_and_search.WordDictionary2 | import collections
class WordDictionary2(object):
def __init__(self):
self.word_dict = collections.defaultdict(list)
def add_word(self, word):
if word:
self.word_dict[len(word)].append(word)
def search(self, word):
if not word:
return False
if '.' ... |
class WordDictionary2(object):
def __init__(self):
pass
def add_word(self, word):
pass
def search(self, word):
pass | 4 | 0 | 6 | 0 | 6 | 0 | 3 | 0.06 | 1 | 2 | 0 | 0 | 3 | 1 | 3 | 3 | 22 | 3 | 18 | 7 | 14 | 1 | 18 | 7 | 14 | 6 | 1 | 3 | 9 |
15,220 | keon/algorithms | keon_algorithms/algorithms/arrays/merge_intervals.py | algorithms.arrays.merge_intervals.Interval | class Interval:
"""
A set of real numbers with methods to determine if other
numbers are included in the set.
Includes related methods to merge and print interval sets.
"""
def __init__(self, start=0, end=0):
self.start = start
self.end = end
def __repr__(self):
re... | class Interval:
'''
A set of real numbers with methods to determine if other
numbers are included in the set.
Includes related methods to merge and print interval sets.
'''
def __init__(self, start=0, end=0):
pass
def __repr__(self):
pass
def __iter__(self):
p... | 13 | 4 | 4 | 0 | 4 | 0 | 2 | 0.21 | 0 | 2 | 0 | 0 | 8 | 2 | 10 | 10 | 56 | 9 | 39 | 19 | 26 | 8 | 36 | 17 | 25 | 3 | 0 | 2 | 16 |
15,221 | keon/algorithms | keon_algorithms/algorithms/compression/huffman_coding.py | algorithms.compression.huffman_coding.HuffmanCoding | import heapq
from collections import defaultdict, deque
class HuffmanCoding:
def __init__(self):
pass
@staticmethod
def decode_file(file_in_name, file_out_name):
with open(file_in_name, 'rb') as file_in, open(file_out_name, 'wb') as file_out:
reader = HuffmanReader(file_in)
... |
class HuffmanCoding:
def __init__(self):
pass
@staticmethod
def decode_file(file_in_name, file_out_name):
pass
@staticmethod
def _decode_and_write_signs_to_file(file, reader: HuffmanReader, tree: Node, additional_bits: int):
pass
@staticmethod
def encode_file(file_i... | 18 | 0 | 9 | 1 | 8 | 1 | 2 | 0.06 | 0 | 8 | 4 | 0 | 1 | 0 | 9 | 9 | 102 | 18 | 84 | 43 | 66 | 5 | 74 | 33 | 64 | 6 | 0 | 4 | 21 |
15,222 | keon/algorithms | keon_algorithms/algorithms/compression/huffman_coding.py | algorithms.compression.huffman_coding.HuffmanReader | from collections import defaultdict, deque
class HuffmanReader:
def __init__(self, file):
self.file = file
self.buffer = []
self.is_last_byte = False
def get_number_of_additional_bits_in_the_last_byte(self) -> int:
bin_num = self.get_bit() + self.get_bit() + self.get_bit()
... |
class HuffmanReader:
def __init__(self, file):
pass
def get_number_of_additional_bits_in_the_last_byte(self) -> int:
pass
def load_tree(self) -> Node:
'''
Load tree from file
:return:
'''
pass
def _fill_tree(self, leaves_queue):
'''
... | 8 | 3 | 11 | 1 | 8 | 2 | 2 | 0.27 | 0 | 4 | 1 | 0 | 7 | 3 | 7 | 7 | 84 | 14 | 56 | 24 | 48 | 15 | 52 | 24 | 44 | 4 | 0 | 3 | 15 |
15,223 | keon/algorithms | keon_algorithms/algorithms/compression/huffman_coding.py | algorithms.compression.huffman_coding.HuffmanWriter | class HuffmanWriter:
def __init__(self, file):
self.file = file
self.buffer = ''
self.saved_bits = 0
def write_char(self, char):
self.write_int(ord(char))
def write_int(self, num):
bin_int = '{0:08b}'.format(num)
self.write_bits(bin_int)
def write_bits... | class HuffmanWriter:
def __init__(self, file):
pass
def write_char(self, char):
pass
def write_int(self, num):
pass
def write_bits(self, bits):
pass
def save_tree(self, tree):
'''
Generate and save tree code to file
:param tree:
:r... | 9 | 2 | 9 | 1 | 7 | 2 | 2 | 0.28 | 0 | 2 | 0 | 0 | 7 | 3 | 7 | 7 | 69 | 11 | 47 | 21 | 37 | 13 | 47 | 21 | 37 | 4 | 0 | 1 | 14 |
15,224 | keon/algorithms | keon_algorithms/algorithms/compression/huffman_coding.py | algorithms.compression.huffman_coding.Node | class Node:
def __init__(self, frequency=0, sign=None, left=None, right=None):
self.frequency = frequency
self.sign = sign
self.left = left
self.right = right
def __lt__(self, other):
return self.frequency < other.frequency
def __gt__(self, other):
return s... | class Node:
def __init__(self, frequency=0, sign=None, left=None, right=None):
pass
def __lt__(self, other):
pass
def __gt__(self, other):
pass
def __eq__(self, other):
pass
def __str__(self):
pass
def __repr__(self):
pass | 7 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 6 | 4 | 6 | 6 | 21 | 5 | 16 | 11 | 9 | 0 | 16 | 11 | 9 | 1 | 0 | 0 | 6 |
15,225 | keon/algorithms | keon_algorithms/algorithms/compression/huffman_coding.py | algorithms.compression.huffman_coding.TreeFinder | class TreeFinder:
"""
Class to help find signs in tree
"""
def __init__(self, tree):
self.root = tree
self.current_node = tree
self.found = None
def find(self, bit):
"""
Find sign in tree
:param bit:
:return: True if sign is found
"""... | class TreeFinder:
'''
Class to help find signs in tree
'''
def __init__(self, tree):
pass
def find(self, bit):
'''
Find sign in tree
:param bit:
:return: True if sign is found
'''
pass
def _reset(self, found=''):
pass | 4 | 2 | 9 | 0 | 7 | 2 | 2 | 0.38 | 0 | 0 | 0 | 0 | 3 | 3 | 3 | 3 | 33 | 4 | 21 | 7 | 17 | 8 | 18 | 7 | 14 | 4 | 0 | 1 | 6 |
15,226 | keon/algorithms | keon_algorithms/algorithms/dfs/sudoku_solver.py | algorithms.dfs.sudoku_solver.Sudoku | class Sudoku:
def __init__(self, board, row, col):
self.board = board
self.row = row
self.col = col
self.val = self.possible_values()
def possible_values(self):
a = '123456789'
d, val = ({}, {})
for i in range(self.row):
for j in range(self.c... | class Sudoku:
def __init__(self, board, row, col):
pass
def possible_values(self):
pass
def solve(self):
pass
def valid_one(self, n, kee, update):
pass
def undo(self, kee, update):
pass
def __str__(self):
'''[summary]
Generates a boar... | 7 | 1 | 11 | 0 | 10 | 1 | 4 | 0.13 | 0 | 1 | 0 | 0 | 6 | 4 | 6 | 6 | 73 | 7 | 61 | 27 | 54 | 8 | 59 | 27 | 52 | 5 | 0 | 4 | 22 |
15,227 | keon/algorithms | keon_algorithms/algorithms/dp/job_scheduling.py | algorithms.dp.job_scheduling.Job | class Job:
"""
Class to represent a job
"""
def __init__(self, start, finish, profit):
self.start = start
self.finish = finish
self.profit = profit | class Job:
'''
Class to represent a job
'''
def __init__(self, start, finish, profit):
pass | 2 | 1 | 4 | 0 | 4 | 0 | 1 | 0.6 | 0 | 0 | 0 | 0 | 1 | 3 | 1 | 1 | 8 | 0 | 5 | 5 | 3 | 3 | 5 | 5 | 3 | 1 | 0 | 0 | 1 |
15,228 | keon/algorithms | keon_algorithms/algorithms/dp/knapsack.py | algorithms.dp.knapsack.Item | class Item:
def __init__(self, value, weight):
self.value = value
self.weight = weight | class Item:
def __init__(self, value, weight):
pass | 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 1 | 1 | 5 | 1 | 4 | 4 | 2 | 0 | 4 | 4 | 2 | 1 | 0 | 0 | 1 |
15,229 | keon/algorithms | keon_algorithms/algorithms/graph/check_digraph_strongly_connected.py | algorithms.graph.check_digraph_strongly_connected.Graph | from collections import defaultdict
class Graph:
"""
A directed graph where edges are one-way (a two-way edge can be represented by using two edges).
"""
def __init__(self, vertex_count):
"""
Create a new graph with vertex_count vertices.
"""
self.vertex_count = vertex_... |
class Graph:
'''
A directed graph where edges are one-way (a two-way edge can be represented by using two edges).
'''
def __init__(self, vertex_count):
'''
Create a new graph with vertex_count vertices.
'''
pass
def add_edge(self, source, target):
'''
... | 7 | 7 | 8 | 0 | 5 | 3 | 2 | 0.79 | 0 | 1 | 0 | 0 | 6 | 2 | 6 | 6 | 60 | 8 | 29 | 15 | 22 | 23 | 29 | 15 | 22 | 3 | 0 | 2 | 13 |
15,230 | keon/algorithms | keon_algorithms/algorithms/graph/clone_graph.py | algorithms.graph.clone_graph.UndirectedGraphNode | class UndirectedGraphNode:
"""
A node in an undirected graph. Contains a label and a list of neighbouring
nodes (initially empty).
"""
def __init__(self, label):
self.label = label
self.neighbors = []
def shallow_copy(self):
"""
Return a shallow copy of this nod... | class UndirectedGraphNode:
'''
A node in an undirected graph. Contains a label and a list of neighbouring
nodes (initially empty).
'''
def __init__(self, label):
pass
def shallow_copy(self):
'''
Return a shallow copy of this node (ignoring any neighbors)
'''
... | 4 | 3 | 4 | 0 | 2 | 2 | 1 | 1.25 | 0 | 0 | 0 | 0 | 3 | 2 | 3 | 3 | 21 | 3 | 8 | 6 | 4 | 10 | 8 | 6 | 4 | 1 | 0 | 0 | 3 |
15,231 | keon/algorithms | keon_algorithms/algorithms/graph/cycle_detection.py | algorithms.graph.cycle_detection.TraversalState | from enum import Enum
class TraversalState(Enum):
"""
For a given node:
- WHITE: has not been visited yet
- GRAY: is currently being investigated for a cycle
- BLACK: is not part of a cycle
"""
WHITE = 0
GRAY = 1
BLACK = 2 |
class TraversalState(Enum):
'''
For a given node:
- WHITE: has not been visited yet
- GRAY: is currently being investigated for a cycle
- BLACK: is not part of a cycle
'''
pass | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 49 | 10 | 0 | 4 | 4 | 3 | 6 | 4 | 4 | 3 | 0 | 4 | 0 | 0 |
15,232 | keon/algorithms | keon_algorithms/algorithms/graph/dijkstra.py | algorithms.graph.dijkstra.Dijkstra | class Dijkstra:
"""
A fully connected directed graph with edge weights
"""
def __init__(self, vertex_count):
self.vertex_count = vertex_count
self.graph = [[0 for _ in range(vertex_count)] for _ in range(vertex_count)]
def min_distance(self, dist, min_dist_set):
"""
... | class Dijkstra:
'''
A fully connected directed graph with edge weights
'''
def __init__(self, vertex_count):
pass
def min_distance(self, dist, min_dist_set):
'''
Find the vertex that is closest to the visited set
'''
pass
def dijkstra(self, src):
... | 4 | 3 | 13 | 1 | 8 | 3 | 3 | 0.46 | 0 | 2 | 0 | 0 | 3 | 2 | 3 | 3 | 45 | 7 | 26 | 14 | 22 | 12 | 26 | 14 | 22 | 5 | 0 | 3 | 10 |
15,233 | keon/algorithms | keon_algorithms/algorithms/graph/graph.py | algorithms.graph.graph.DirectedEdge | class DirectedEdge:
"""
A directed edge in a directed graph.
Stores the source and target node of the edge.
"""
def __init__(self, node_from, node_to):
self.source = node_from
self.target = node_to
def __eq__(self, obj):
if isinstance(obj, DirectedEdge):
ret... | class DirectedEdge:
'''
A directed edge in a directed graph.
Stores the source and target node of the edge.
'''
def __init__(self, node_from, node_to):
pass
def __eq__(self, obj):
pass
def __repr__(self):
pass | 4 | 1 | 3 | 0 | 3 | 0 | 1 | 0.4 | 0 | 0 | 0 | 0 | 3 | 2 | 3 | 3 | 17 | 3 | 10 | 6 | 6 | 4 | 10 | 6 | 6 | 2 | 0 | 1 | 4 |
15,234 | keon/algorithms | keon_algorithms/algorithms/graph/graph.py | algorithms.graph.graph.DirectedGraph | class DirectedGraph:
"""
A directed graph.
Stores a set of nodes, edges and adjacency matrix.
"""
def __init__(self, load_dict={}):
self.nodes = []
self.edges = []
self.adjacency_list = {}
if load_dict and isinstance(load_dict, dict):
for vertex in load_d... | class DirectedGraph:
'''
A directed graph.
Stores a set of nodes, edges and adjacency matrix.
'''
def __init__(self, load_dict={}):
pass
def add_node(self, node_name):
'''
Add a new named node to the graph.
'''
pass
def add_edge(self, node_name_from... | 4 | 3 | 11 | 0 | 9 | 2 | 3 | 0.41 | 0 | 4 | 2 | 0 | 3 | 3 | 3 | 3 | 42 | 4 | 27 | 14 | 23 | 11 | 27 | 14 | 23 | 4 | 0 | 3 | 8 |
15,235 | keon/algorithms | keon_algorithms/algorithms/graph/graph.py | algorithms.graph.graph.Node | class Node:
"""
A node/vertex in a graph.
"""
def __init__(self, name):
self.name = name
@staticmethod
def get_name(obj):
"""
Return the name of the node
"""
if isinstance(obj, Node):
return obj.name
if isinstance(obj, str):
... | class Node:
'''
A node/vertex in a graph.
'''
def __init__(self, name):
pass
@staticmethod
def get_name(obj):
'''
Return the name of the node
'''
pass
def __eq__(self, obj):
pass
def __repr__(self):
pass
def __hash__(self):
... | 13 | 2 | 3 | 0 | 2 | 0 | 1 | 0.21 | 0 | 1 | 0 | 0 | 10 | 1 | 11 | 11 | 45 | 11 | 28 | 14 | 15 | 6 | 27 | 13 | 15 | 3 | 0 | 1 | 13 |
15,236 | keon/algorithms | keon_algorithms/algorithms/graph/minimum_spanning_tree.py | algorithms.graph.minimum_spanning_tree.DisjointSet | class DisjointSet:
"""
The disjoint set is represented with an list <n> of integers where
<n[i]> is the parent of the node at position <i>.
If <n[i]> = <i>, <i> it's a root, or a head, of a set
"""
def __init__(self, size):
"""
Args:
n (int): Number of vertices in th... | class DisjointSet:
'''
The disjoint set is represented with an list <n> of integers where
<n[i]> is the parent of the node at position <i>.
If <n[i]> = <i>, <i> it's a root, or a head, of a set
'''
def __init__(self, size):
'''
Args:
n (int): Number of vertices in th... | 4 | 4 | 13 | 1 | 6 | 8 | 2 | 1.58 | 0 | 1 | 0 | 0 | 3 | 2 | 3 | 3 | 49 | 7 | 19 | 7 | 15 | 30 | 18 | 7 | 14 | 2 | 0 | 1 | 6 |
15,237 | keon/algorithms | keon_algorithms/algorithms/graph/minimum_spanning_tree.py | algorithms.graph.minimum_spanning_tree.Edge | class Edge:
"""
An edge of an undirected graph
"""
def __init__(self, source, target, weight):
self.source = source
self.target = target
self.weight = weight | class Edge:
'''
An edge of an undirected graph
'''
def __init__(self, source, target, weight):
pass | 2 | 1 | 4 | 0 | 4 | 0 | 1 | 0.6 | 0 | 0 | 0 | 0 | 1 | 3 | 1 | 1 | 9 | 1 | 5 | 5 | 3 | 3 | 5 | 5 | 3 | 1 | 0 | 0 | 1 |
15,238 | keon/algorithms | keon_algorithms/algorithms/graph/path_between_two_vertices_in_digraph.py | algorithms.graph.path_between_two_vertices_in_digraph.Graph | from collections import defaultdict
class Graph:
"""
A directed graph
"""
def __init__(self, vertex_count):
self.vertex_count = vertex_count
self.graph = defaultdict(list)
self.has_path = False
def add_edge(self, source, target):
"""
Add a new directed edge... |
class Graph:
'''
A directed graph
'''
def __init__(self, vertex_count):
pass
def add_edge(self, source, target):
'''
Add a new directed edge to the graph
'''
pass
def dfs(self, source, target):
'''
Determine if there is a path from sour... | 6 | 5 | 7 | 0 | 4 | 3 | 2 | 0.77 | 0 | 1 | 0 | 0 | 5 | 3 | 5 | 5 | 44 | 5 | 22 | 11 | 16 | 17 | 22 | 11 | 16 | 4 | 0 | 2 | 8 |
15,239 | keon/algorithms | keon_algorithms/algorithms/graph/strongly_connected_components_kosaraju.py | algorithms.graph.strongly_connected_components_kosaraju.Kosaraju | class Kosaraju:
"""
Kosaraju's algorithm use depth first search approach to find strongly connected components in a directed graph.
Approach:
1. Make a DFS call to keep track of finish time of each vertex.
2. Tranpose the original graph. ie 1->2 transpose is 1<-2
3. Make another DFS ... | class Kosaraju:
'''
Kosaraju's algorithm use depth first search approach to find strongly connected components in a directed graph.
Approach:
1. Make a DFS call to keep track of finish time of each vertex.
2. Tranpose the original graph. ie 1->2 transpose is 1<-2
3. Make another DFS ... | 3 | 1 | 17 | 5 | 12 | 0 | 5 | 0.29 | 0 | 1 | 0 | 0 | 2 | 0 | 2 | 2 | 43 | 12 | 24 | 9 | 21 | 7 | 24 | 9 | 21 | 7 | 0 | 2 | 10 |
15,240 | keon/algorithms | keon_algorithms/algorithms/graph/tarjan.py | algorithms.graph.tarjan.Tarjan | from algorithms.graph.graph import DirectedGraph
class Tarjan:
"""
A directed graph used for finding strongly connected components
"""
def __init__(self, dict_graph):
self.graph = DirectedGraph(dict_graph)
self.index = 0
self.stack = []
for vertex in self.graph.nodes:
... |
class Tarjan:
'''
A directed graph used for finding strongly connected components
'''
def __init__(self, dict_graph):
pass
def strongconnect(self, vertex, sccs):
'''
Given a vertex, adds all successors of the given vertex to the same connected component
'''
... | 3 | 2 | 26 | 2 | 16 | 8 | 6 | 0.55 | 0 | 1 | 1 | 0 | 2 | 4 | 2 | 2 | 56 | 5 | 33 | 10 | 30 | 18 | 32 | 10 | 29 | 7 | 0 | 3 | 11 |
15,241 | keon/algorithms | keon_algorithms/algorithms/graph/transitive_closure_dfs.py | algorithms.graph.transitive_closure_dfs.Graph | class Graph:
"""
This class represents a directed graph using adjacency lists
"""
def __init__(self, vertices):
self.vertex_count = vertices
self.graph = {}
self.closure = [[0 for j in range(vertices)] for i in range(vertices)]
def add_edge(self, source, target):
""... | class Graph:
'''
This class represents a directed graph using adjacency lists
'''
def __init__(self, vertices):
pass
def add_edge(self, source, target):
'''
Adds a directed edge to the graph
'''
pass
def dfs_util(self, source, target):
'''
... | 5 | 4 | 11 | 2 | 5 | 5 | 2 | 1.11 | 0 | 1 | 0 | 0 | 4 | 3 | 4 | 4 | 49 | 9 | 19 | 10 | 14 | 21 | 18 | 10 | 13 | 3 | 0 | 2 | 8 |
15,242 | keon/algorithms | keon_algorithms/algorithms/heap/binary_heap.py | algorithms.heap.binary_heap.AbstractHeap | from abc import ABCMeta, abstractmethod
class AbstractHeap(metaclass=ABCMeta):
"""Abstract Class for Binary Heap."""
def __init__(self):
"""Pass."""
@abstractmethod
def perc_up(self, i):
"""Pass."""
@abstractmethod
def insert(self, val):
"""Pass."""
@abstractmeth... |
class AbstractHeap(metaclass=ABCMeta):
'''Abstract Class for Binary Heap.'''
def __init__(self):
'''Pass.'''
pass
@abstractmethod
def perc_up(self, i):
'''Pass.'''
pass
@abstractmethod
def insert(self, val):
'''Pass.'''
pass
@abstractmethod
... | 12 | 7 | 2 | 0 | 1 | 1 | 1 | 0.58 | 1 | 0 | 0 | 1 | 6 | 0 | 6 | 26 | 25 | 6 | 12 | 12 | 0 | 7 | 7 | 7 | 0 | 1 | 3 | 0 | 6 |
15,243 | keon/algorithms | keon_algorithms/algorithms/heap/binary_heap.py | algorithms.heap.binary_heap.BinaryHeap | class BinaryHeap(AbstractHeap):
"""Binary Heap Class"""
def __init__(self):
self.current_size = 0
self.heap = [0]
def perc_up(self, i):
while i // 2 > 0:
if self.heap[i] < self.heap[i // 2]:
self.heap[i], self.heap[i // 2] = (self.heap[i // 2], self.heap... | class BinaryHeap(AbstractHeap):
'''Binary Heap Class'''
def __init__(self):
pass
def perc_up(self, i):
pass
def insert(self, val):
'''
Method insert always start by inserting the element at the bottom.
It inserts rightmost spot so as to maintain the complete tr... | 7 | 2 | 8 | 0 | 5 | 3 | 2 | 0.75 | 1 | 0 | 0 | 0 | 6 | 2 | 6 | 32 | 61 | 7 | 32 | 11 | 25 | 24 | 32 | 11 | 25 | 3 | 4 | 2 | 12 |
15,244 | keon/algorithms | keon_algorithms/algorithms/heap/merge_sorted_k_lists.py | algorithms.heap.merge_sorted_k_lists.ListNode | class ListNode(object):
""" ListNode Class"""
def __init__(self, val):
self.val = val
self.next = None | class ListNode(object):
''' ListNode Class'''
def __init__(self, val):
pass | 2 | 1 | 3 | 0 | 3 | 0 | 1 | 0.25 | 1 | 0 | 0 | 0 | 1 | 2 | 1 | 1 | 6 | 1 | 4 | 4 | 2 | 1 | 4 | 4 | 2 | 1 | 1 | 0 | 1 |
15,245 | keon/algorithms | keon_algorithms/algorithms/linkedlist/copy_random_pointer.py | algorithms.linkedlist.copy_random_pointer.RandomListNode | class RandomListNode(object):
def __init__(self, label):
self.label = label
self.next = None
self.random = None | class RandomListNode(object):
def __init__(self, label):
pass | 2 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 3 | 1 | 1 | 5 | 0 | 5 | 5 | 3 | 0 | 5 | 5 | 3 | 1 | 1 | 0 | 1 |
15,246 | keon/algorithms | keon_algorithms/algorithms/linkedlist/intersection.py | algorithms.linkedlist.intersection.Node | class Node(object):
def __init__(self, val=None):
self.val = val
self.next = None | class Node(object):
def __init__(self, val=None):
pass | 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 2 | 1 | 1 | 4 | 0 | 4 | 4 | 2 | 0 | 4 | 4 | 2 | 1 | 1 | 0 | 1 |
15,247 | keon/algorithms | keon_algorithms/algorithms/linkedlist/linkedlist.py | algorithms.linkedlist.linkedlist.DoublyLinkedListNode | class DoublyLinkedListNode(object):
def __init__(self, value):
self.value = value
self.next = None
self.prev = None | class DoublyLinkedListNode(object):
def __init__(self, value):
pass | 2 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 3 | 1 | 1 | 5 | 0 | 5 | 5 | 3 | 0 | 5 | 5 | 3 | 1 | 1 | 0 | 1 |
15,248 | keon/algorithms | keon_algorithms/algorithms/linkedlist/linkedlist.py | algorithms.linkedlist.linkedlist.SinglyLinkedListNode | class SinglyLinkedListNode(object):
def __init__(self, value):
self.value = value
self.next = None | class SinglyLinkedListNode(object):
def __init__(self, value):
pass | 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 2 | 1 | 1 | 4 | 0 | 4 | 4 | 2 | 0 | 4 | 4 | 2 | 1 | 1 | 0 | 1 |
15,249 | keon/algorithms | keon_algorithms/algorithms/linkedlist/merge_two_list.py | algorithms.linkedlist.merge_two_list.Node | class Node:
def __init__(self, x):
self.val = x
self.next = None | class Node:
def __init__(self, x):
pass | 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 1 | 1 | 5 | 1 | 4 | 4 | 2 | 0 | 4 | 4 | 2 | 1 | 0 | 0 | 1 |
15,250 | keon/algorithms | keon_algorithms/algorithms/linkedlist/partition.py | algorithms.linkedlist.partition.Node | class Node:
def __init__(self, val=None):
self.val = int(val)
self.next = None | class Node:
def __init__(self, val=None):
pass | 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 2 | 1 | 1 | 4 | 0 | 4 | 4 | 2 | 0 | 4 | 4 | 2 | 1 | 0 | 0 | 1 |
15,251 | keon/algorithms | keon_algorithms/algorithms/linkedlist/remove_duplicates.py | algorithms.linkedlist.remove_duplicates.Node | class Node:
def __init__(self, val=None):
self.val = val
self.next = None | class Node:
def __init__(self, val=None):
pass | 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 1 | 1 | 4 | 0 | 4 | 4 | 2 | 0 | 4 | 4 | 2 | 1 | 0 | 0 | 1 |
15,252 | keon/algorithms | keon_algorithms/algorithms/map/hashtable.py | algorithms.map.hashtable.HashTable | class HashTable(object):
"""
HashMap Data Type
HashMap() Create a new, empty map. It returns an empty map collection.
put(key, val) Add a new key-value pair to the map. If the key is already in the map then replace
the old value with the new value.
get(key) Given a key, return th... | class HashTable(object):
'''
HashMap Data Type
HashMap() Create a new, empty map. It returns an empty map collection.
put(key, val) Add a new key-value pair to the map. If the key is already in the map then replace
the old value with the new value.
get(key) Given a key, return th... | 11 | 2 | 7 | 1 | 6 | 1 | 2 | 0.41 | 1 | 1 | 0 | 1 | 10 | 4 | 10 | 10 | 96 | 16 | 58 | 20 | 47 | 24 | 55 | 20 | 44 | 5 | 1 | 2 | 22 |
15,253 | keon/algorithms | keon_algorithms/algorithms/map/hashtable.py | algorithms.map.hashtable.ResizableHashTable | class ResizableHashTable(HashTable):
MIN_SIZE = 8
def __init__(self):
super().__init__(self.MIN_SIZE)
def put(self, key, value):
rv = super().put(key, value)
if len(self) >= self.size * 2 / 3:
self.__resize()
def __resize(self):
keys, values = (self._keys, ... | class ResizableHashTable(HashTable):
def __init__(self):
pass
def put(self, key, value):
pass
def __resize(self):
pass | 4 | 0 | 5 | 0 | 5 | 1 | 2 | 0.12 | 1 | 2 | 0 | 0 | 3 | 3 | 3 | 13 | 21 | 3 | 17 | 11 | 13 | 2 | 17 | 11 | 13 | 3 | 2 | 2 | 6 |
15,254 | keon/algorithms | keon_algorithms/algorithms/map/randomized_set.py | algorithms.map.randomized_set.RandomizedSet | import random
class RandomizedSet:
def __init__(self):
self.nums = []
self.idxs = {}
def insert(self, val):
if val not in self.idxs:
self.nums.append(val)
self.idxs[val] = len(self.nums) - 1
return True
return False
def remove(self, val... |
class RandomizedSet:
def __init__(self):
pass
def insert(self, val):
pass
def remove(self, val):
pass
def get_random(self):
pass | 5 | 0 | 5 | 0 | 5 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 4 | 2 | 4 | 4 | 24 | 3 | 21 | 9 | 16 | 0 | 21 | 9 | 16 | 2 | 0 | 1 | 6 |
15,255 | keon/algorithms | keon_algorithms/algorithms/map/separate_chaining_hashtable.py | algorithms.map.separate_chaining_hashtable.Node | class Node(object):
def __init__(self, key=None, value=None, next=None):
self.key = key
self.value = value
self.next = next | class Node(object):
def __init__(self, key=None, value=None, next=None):
pass | 2 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 3 | 1 | 1 | 5 | 0 | 5 | 5 | 3 | 0 | 5 | 5 | 3 | 1 | 1 | 0 | 1 |
15,256 | keon/algorithms | keon_algorithms/algorithms/map/separate_chaining_hashtable.py | algorithms.map.separate_chaining_hashtable.SeparateChainingHashTable | class SeparateChainingHashTable(object):
"""
HashTable Data Type:
By having each bucket contain a linked list of elements that are hashed to that bucket.
Usage:
>>> table = SeparateChainingHashTable() # Create a new, empty map.
>>> table.put('hello', 'world') # Add a new key-value pair.
>>>... | class SeparateChainingHashTable(object):
'''
HashTable Data Type:
By having each bucket contain a linked list of elements that are hashed to that bucket.
Usage:
>>> table = SeparateChainingHashTable() # Create a new, empty map.
>>> table.put('hello', 'world') # Add a new key-value pair.
>>> ... | 10 | 1 | 5 | 0 | 5 | 0 | 2 | 0.28 | 1 | 1 | 1 | 0 | 9 | 3 | 9 | 9 | 74 | 10 | 50 | 21 | 40 | 14 | 48 | 21 | 38 | 4 | 1 | 3 | 17 |
15,257 | keon/algorithms | keon_algorithms/algorithms/maths/polynomial.py | algorithms.maths.polynomial.Monomial | from fractions import Fraction
from typing import Dict, Union, Set, Iterable
from numbers import Rational
class Monomial:
"""
A simple Monomial class to
record the details of all variables
that a typical monomial is composed of.
"""
def __init__(self, variables: Dict[int, int], coeff: Union[in... |
class Monomial:
'''
A simple Monomial class to
record the details of all variables
that a typical monomial is composed of.
'''
def __init__(self, variables: Dict[int, int], coeff: Union[int, float, Fraction, None]=None) -> None:
'''
Create a monomial in the given variables:
... | 18 | 17 | 15 | 2 | 8 | 6 | 3 | 0.82 | 0 | 11 | 0 | 0 | 15 | 2 | 16 | 16 | 275 | 40 | 129 | 41 | 111 | 106 | 119 | 40 | 102 | 7 | 0 | 3 | 52 |
15,258 | keon/algorithms | keon_algorithms/algorithms/maths/polynomial.py | algorithms.maths.polynomial.Polynomial | from typing import Dict, Union, Set, Iterable
from functools import reduce
from numbers import Rational
from fractions import Fraction
class Polynomial:
"""
A simple implementation
of a polynomial class that
records the details about two polynomials
that are potentially comprised of multiple
va... |
class Polynomial:
'''
A simple implementation
of a polynomial class that
records the details about two polynomials
that are potentially comprised of multiple
variables.
'''
def __init__(self, monomials: Iterable[Union[int, float, Fraction, Monomial]]) -> None:
'''
Creat... | 16 | 15 | 17 | 1 | 11 | 5 | 4 | 0.51 | 0 | 12 | 1 | 0 | 12 | 1 | 13 | 13 | 247 | 34 | 141 | 46 | 126 | 72 | 121 | 45 | 107 | 8 | 0 | 3 | 50 |
15,259 | keon/algorithms | keon_algorithms/algorithms/matrix/bomb_enemy.py | algorithms.matrix.bomb_enemy.TestBombEnemy | import unittest
class TestBombEnemy(unittest.TestCase):
def test_3x4(self):
grid1 = [['0', 'E', '0', '0'], ['E', '0', 'W', 'E'], ['0', 'E', '0', '0']]
self.assertEqual(3, max_killed_enemies(grid1))
def test_4x4(self):
grid1 = [['0', 'E', '0', 'E'], ['E', 'E', 'E', '0'], ['E', '0', 'W'... |
class TestBombEnemy(unittest.TestCase):
def test_3x4(self):
pass
def test_4x4(self):
pass | 3 | 0 | 9 | 0 | 9 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 2 | 0 | 2 | 74 | 20 | 1 | 19 | 6 | 16 | 0 | 9 | 6 | 6 | 1 | 2 | 0 | 2 |
15,260 | keon/algorithms | keon_algorithms/algorithms/queues/moving_average.py | algorithms.queues.moving_average.MovingAverage | from collections import deque
class MovingAverage(object):
def __init__(self, size):
"""
Initialize your data structure here.
:type size: int
"""
self.queue = deque(maxlen=size)
def next(self, val):
"""
:type val: int
:rtype: float
"""
... |
class MovingAverage(object):
def __init__(self, size):
'''
Initialize your data structure here.
:type size: int
'''
pass
def next(self, val):
'''
:type val: int
:rtype: float
'''
pass | 3 | 2 | 7 | 0 | 3 | 4 | 1 | 1.33 | 1 | 0 | 0 | 0 | 2 | 1 | 2 | 2 | 15 | 1 | 6 | 4 | 3 | 8 | 6 | 4 | 3 | 1 | 1 | 0 | 2 |
15,261 | keon/algorithms | keon_algorithms/algorithms/queues/priority_queue.py | algorithms.queues.priority_queue.PriorityQueue | import itertools
class PriorityQueue:
def __init__(self, items=None, priorities=None):
"""Create a priority queue with items (list or iterable).
If items is not passed, create empty priority queue."""
self.priority_queue_list = []
if items is None:
return
if pri... | null | 6 | 4 | 7 | 0 | 4 | 2 | 2 | 0.48 | 0 | 4 | 1 | 0 | 5 | 1 | 5 | 5 | 38 | 4 | 23 | 10 | 17 | 11 | 23 | 10 | 17 | 4 | 0 | 2 | 11 |
15,262 | keon/algorithms | keon_algorithms/algorithms/queues/priority_queue.py | algorithms.queues.priority_queue.PriorityQueueNode | class PriorityQueueNode:
def __init__(self, data, priority):
self.data = data
self.priority = priority
def __repr__(self):
return '{}: {}'.format(self.data, self.priority) | class PriorityQueueNode:
def __init__(self, data, priority):
pass
def __repr__(self):
pass | 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 | 2 | 2 | 2 | 7 | 1 | 6 | 5 | 3 | 0 | 6 | 5 | 3 | 1 | 0 | 0 | 2 |
15,263 | keon/algorithms | keon_algorithms/algorithms/queues/queue.py | algorithms.queues.queue.AbstractQueue | from abc import ABCMeta, abstractmethod
class AbstractQueue(metaclass=ABCMeta):
def __init__(self):
self._size = 0
def __len__(self):
return self._size
def is_empty(self):
return self._size == 0
@abstractmethod
def enqueue(self, value):
pass
@abstractmethod
... |
class AbstractQueue(metaclass=ABCMeta):
def __init__(self):
pass
def __len__(self):
pass
def is_empty(self):
pass
@abstractmethod
def enqueue(self, value):
pass
@abstractmethod
def dequeue(self):
pass
@abstractmethod
def peek(self):
... | 12 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 2 | 7 | 1 | 7 | 27 | 26 | 7 | 19 | 13 | 7 | 0 | 15 | 9 | 7 | 1 | 3 | 0 | 7 |
15,264 | keon/algorithms | keon_algorithms/algorithms/queues/queue.py | algorithms.queues.queue.ArrayQueue | class ArrayQueue(AbstractQueue):
def __init__(self, capacity=10):
"""
Initialize python List with capacity of 10 or user given input.
Python List type is a dynamic array, so we have to restrict its
dynamic nature to make it work like a static array.
"""
super().__ini... | class ArrayQueue(AbstractQueue):
def __init__(self, capacity=10):
'''
Initialize python List with capacity of 10 or user given input.
Python List type is a dynamic array, so we have to restrict its
dynamic nature to make it work like a static array.
'''
pass
def... | 7 | 3 | 7 | 0 | 5 | 2 | 2 | 0.27 | 1 | 2 | 0 | 0 | 6 | 3 | 6 | 33 | 48 | 6 | 33 | 12 | 26 | 9 | 33 | 12 | 26 | 3 | 4 | 2 | 11 |
15,265 | keon/algorithms | keon_algorithms/algorithms/queues/queue.py | algorithms.queues.queue.LinkedListQueue | class LinkedListQueue(AbstractQueue):
def __init__(self):
super().__init__()
self._front = None
self._rear = None
def __iter__(self):
probe = self._front
while True:
if probe is None:
return
yield probe.value
probe = p... | class LinkedListQueue(AbstractQueue):
def __init__(self):
pass
def __iter__(self):
pass
def enqueue(self, value):
pass
def dequeue(self):
pass
def peek(self):
'''returns the front element of queue.'''
pass | 6 | 1 | 7 | 0 | 7 | 0 | 2 | 0.03 | 1 | 3 | 1 | 0 | 5 | 2 | 5 | 32 | 42 | 5 | 36 | 11 | 30 | 1 | 34 | 11 | 28 | 3 | 4 | 2 | 11 |
15,266 | keon/algorithms | keon_algorithms/algorithms/queues/queue.py | algorithms.queues.queue.QueueNode | class QueueNode:
def __init__(self, value):
self.value = value
self.next = None | class QueueNode:
def __init__(self, value):
pass | 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 1 | 1 | 4 | 0 | 4 | 4 | 2 | 0 | 4 | 4 | 2 | 1 | 0 | 0 | 1 |
15,267 | keon/algorithms | keon_algorithms/algorithms/queues/zigzagiterator.py | algorithms.queues.zigzagiterator.ZigZagIterator | class ZigZagIterator:
def __init__(self, v1, v2):
"""
Initialize your data structure here.
:type v1: List[int]
:type v2: List[int]
"""
self.queue = [_ for _ in (v1, v2) if _]
print(self.queue)
def next(self):
"""
:rtype: int
"""
... | class ZigZagIterator:
def __init__(self, v1, v2):
'''
Initialize your data structure here.
:type v1: List[int]
:type v2: List[int]
'''
pass
def next(self):
'''
:rtype: int
'''
pass
def has_next(self):
'''
:rty... | 4 | 3 | 8 | 0 | 4 | 4 | 2 | 0.79 | 0 | 0 | 0 | 0 | 3 | 1 | 3 | 3 | 27 | 2 | 14 | 7 | 10 | 11 | 14 | 7 | 10 | 2 | 0 | 1 | 5 |
15,268 | keon/algorithms | keon_algorithms/algorithms/set/randomized_set.py | algorithms.set.randomized_set.RandomizedSet | import random
class RandomizedSet:
"""
idea: shoot
"""
def __init__(self):
self.elements = []
self.index_map = {}
def insert(self, new_one):
if new_one in self.index_map:
return
self.index_map[new_one] = len(self.elements)
self.elements.append(n... |
class RandomizedSet:
'''
idea: shoot
'''
def __init__(self):
pass
def insert(self, new_one):
pass
def remove(self, old_one):
pass
def random_element(self):
pass | 5 | 1 | 5 | 0 | 5 | 0 | 2 | 0.19 | 0 | 0 | 0 | 0 | 4 | 2 | 4 | 4 | 28 | 4 | 21 | 9 | 16 | 4 | 21 | 9 | 16 | 3 | 0 | 1 | 7 |
15,269 | keon/algorithms | keon_algorithms/algorithms/stack/ordered_stack.py | algorithms.stack.ordered_stack.OrderedStack | class OrderedStack:
def __init__(self):
self.items = []
def is_empty(self):
return self.items == []
def push_t(self, item):
self.items.append(item)
def push(self, item):
temp_stack = OrderedStack()
if self.is_empty() or item > self.peek():
self.pus... | class OrderedStack:
def __init__(self):
pass
def is_empty(self):
pass
def push_t(self, item):
pass
def push_t(self, item):
pass
def pop(self):
pass
def peek(self):
pass
def size(self):
pass | 8 | 0 | 3 | 0 | 3 | 0 | 2 | 0.04 | 0 | 1 | 0 | 0 | 7 | 1 | 7 | 7 | 32 | 6 | 25 | 10 | 17 | 1 | 24 | 10 | 16 | 4 | 0 | 2 | 11 |
15,270 | keon/algorithms | keon_algorithms/algorithms/stack/stack.py | algorithms.stack.stack.AbstractStack | from abc import ABCMeta, abstractmethod
class AbstractStack(metaclass=ABCMeta):
"""Abstract Class for Stacks."""
def __init__(self):
self._top = -1
def __len__(self):
return self._top + 1
def __str__(self):
result = ' '.join(map(str, self))
return 'Top-> ' + result
... |
class AbstractStack(metaclass=ABCMeta):
'''Abstract Class for Stacks.'''
def __init__(self):
pass
def __len__(self):
pass
def __str__(self):
pass
def is_empty(self):
pass
@abstractmethod
def __iter__(self):
pass
@abstractmethod
def push(se... | 13 | 1 | 2 | 0 | 2 | 0 | 1 | 0.05 | 1 | 2 | 0 | 2 | 8 | 1 | 8 | 28 | 30 | 7 | 22 | 15 | 9 | 1 | 18 | 11 | 9 | 1 | 3 | 0 | 8 |
15,271 | keon/algorithms | keon_algorithms/algorithms/stack/stack.py | algorithms.stack.stack.ArrayStack | class ArrayStack(AbstractStack):
def __init__(self, size=10):
"""
Initialize python List with size of 10 or user given input.
Python List type is a dynamic array, so we have to restrict its
dynamic nature to make it work like a static array.
"""
super().__init__()
... | class ArrayStack(AbstractStack):
def __init__(self, size=10):
'''
Initialize python List with size of 10 or user given input.
Python List type is a dynamic array, so we have to restrict its
dynamic nature to make it work like a static array.
'''
pass
def __iter_... | 7 | 3 | 6 | 0 | 5 | 2 | 2 | 0.39 | 1 | 2 | 0 | 0 | 6 | 1 | 6 | 34 | 43 | 5 | 28 | 10 | 21 | 11 | 28 | 10 | 21 | 3 | 4 | 2 | 11 |
15,272 | keon/algorithms | keon_algorithms/algorithms/stack/stack.py | algorithms.stack.stack.LinkedListStack | class LinkedListStack(AbstractStack):
def __init__(self):
super().__init__()
self.head = None
def __iter__(self):
probe = self.head
while True:
if probe is None:
return
yield probe.value
probe = probe.next
def push(self, ... | class LinkedListStack(AbstractStack):
def __init__(self):
pass
def __iter__(self):
pass
def push(self, value):
pass
def pop(self):
pass
def peek(self):
pass | 6 | 0 | 5 | 0 | 5 | 0 | 2 | 0 | 1 | 3 | 1 | 0 | 5 | 1 | 5 | 33 | 32 | 5 | 27 | 10 | 21 | 0 | 27 | 10 | 21 | 3 | 4 | 2 | 9 |
15,273 | keon/algorithms | keon_algorithms/algorithms/stack/stack.py | algorithms.stack.stack.StackNode | class StackNode:
"""Represents a single stack node."""
def __init__(self, value):
self.value = value
self.next = None | class StackNode:
'''Represents a single stack node.'''
def __init__(self, value):
pass | 2 | 1 | 3 | 0 | 3 | 0 | 1 | 0.25 | 0 | 0 | 0 | 0 | 1 | 2 | 1 | 1 | 5 | 0 | 4 | 4 | 2 | 1 | 4 | 4 | 2 | 1 | 0 | 0 | 1 |
15,274 | keon/algorithms | keon_algorithms/algorithms/strings/breaking_bad.py | algorithms.strings.breaking_bad.TreeNode | class TreeNode:
def __init__(self):
self.c = dict()
self.sym = None | class TreeNode:
def __init__(self):
pass | 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 2 | 1 | 1 | 4 | 0 | 4 | 4 | 2 | 0 | 4 | 4 | 2 | 1 | 0 | 0 | 1 |
15,275 | keon/algorithms | keon_algorithms/algorithms/strings/rabin_karp.py | algorithms.strings.rabin_karp.RollingHash | class RollingHash:
def __init__(self, text, size_word):
self.text = text
self.hash = 0
self.size_word = size_word
for i in range(0, size_word):
self.hash += (ord(self.text[i]) - ord('a') + 1) * 26 ** (size_word - i - 1)
self.window_start = 0
self.window_e... | class RollingHash:
def __init__(self, text, size_word):
pass
def move_window(self):
pass
def window_text(self):
pass | 4 | 0 | 8 | 1 | 6 | 2 | 2 | 0.28 | 0 | 1 | 0 | 0 | 3 | 5 | 3 | 3 | 27 | 4 | 18 | 10 | 14 | 5 | 18 | 10 | 14 | 2 | 0 | 1 | 5 |
15,276 | keon/algorithms | keon_algorithms/algorithms/tree/avl/avl.py | algorithms.tree.avl.avl.AvlTree | from tree.tree import TreeNode
class AvlTree(object):
"""
An avl tree.
"""
def __init__(self):
self.node = None
self.height = -1
self.balance = 0
def insert(self, key):
"""
Insert new key into node
"""
node = TreeNode(key)
if not sel... |
class AvlTree(object):
'''
An avl tree.
'''
def __init__(self):
pass
def insert(self, key):
'''
Insert new key into node
'''
pass
def re_balance(self):
'''
Re balance tree. After inserting or deleting a node,
'''
pass
... | 9 | 8 | 14 | 1 | 10 | 3 | 3 | 0.33 | 1 | 1 | 1 | 0 | 8 | 3 | 8 | 8 | 122 | 17 | 79 | 20 | 70 | 26 | 74 | 20 | 65 | 6 | 1 | 3 | 25 |
15,277 | keon/algorithms | keon_algorithms/algorithms/tree/b_tree.py | algorithms.tree.b_tree.BTree | class BTree:
""" Class of BTree """
def __init__(self, t_val=2):
self.min_numbers_of_keys = t_val - 1
self.max_number_of_keys = 2 * t_val - 1
self.root = Node()
def _split_child(self, parent: Node, child_index: int):
new_right_child = Node()
half_max = self.max_numb... | class BTree:
''' Class of BTree '''
def __init__(self, t_val=2):
pass
def _split_child(self, parent: Node, child_index: int):
pass
def insert_key(self, key):
''' overflow, tree increases in height '''
pass
def _insert_to_nonfull_node(self, node: Node, key):
... | 17 | 5 | 12 | 1 | 10 | 2 | 3 | 0.16 | 0 | 5 | 1 | 0 | 16 | 3 | 16 | 16 | 214 | 32 | 160 | 50 | 143 | 26 | 141 | 50 | 124 | 6 | 0 | 3 | 45 |
15,278 | keon/algorithms | keon_algorithms/algorithms/tree/b_tree.py | algorithms.tree.b_tree.Node | class Node:
""" Class of Node"""
def __init__(self):
self.keys = []
self.children = []
def __repr__(self):
return '<id_node: {0}>'.format(self.keys)
@property
def is_leaf(self):
""" Return if it is a leaf"""
return len(self.children) == 0 | class Node:
''' Class of Node'''
def __init__(self):
pass
def __repr__(self):
pass
@property
def is_leaf(self):
''' Return if it is a leaf'''
pass | 5 | 2 | 3 | 0 | 2 | 1 | 1 | 0.33 | 0 | 0 | 0 | 0 | 3 | 2 | 3 | 3 | 15 | 3 | 9 | 7 | 4 | 3 | 8 | 6 | 4 | 1 | 0 | 0 | 3 |
15,279 | keon/algorithms | keon_algorithms/algorithms/tree/construct_tree_postorder_preorder.py | algorithms.tree.construct_tree_postorder_preorder.TreeNode | class TreeNode:
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right | class TreeNode:
def __init__(self, val, left=None, right=None):
pass | 2 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 3 | 1 | 1 | 6 | 1 | 5 | 5 | 3 | 0 | 5 | 5 | 3 | 1 | 0 | 0 | 1 |
15,280 | keon/algorithms | keon_algorithms/algorithms/tree/deepest_left.py | algorithms.tree.deepest_left.DeepestLeft | class DeepestLeft:
def __init__(self):
self.depth = 0
self.Node = None | class DeepestLeft:
def __init__(self):
pass | 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 1 | 1 | 4 | 0 | 4 | 4 | 2 | 0 | 4 | 4 | 2 | 1 | 0 | 0 | 1 |
15,281 | keon/algorithms | keon_algorithms/algorithms/tree/traversal/preorder.py | algorithms.tree.traversal.preorder.Node | class Node:
""" This is a class of Node """
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right | class Node:
''' This is a class of Node '''
def __init__(self, val, left=None, right=None):
pass | 2 | 1 | 4 | 0 | 4 | 0 | 1 | 0.2 | 0 | 0 | 0 | 0 | 1 | 3 | 1 | 1 | 7 | 1 | 5 | 5 | 3 | 1 | 5 | 5 | 3 | 1 | 0 | 0 | 1 |
15,282 | keon/algorithms | keon_algorithms/algorithms/tree/tree.py | algorithms.tree.tree.TreeNode | class TreeNode:
def __init__(self, val=0):
self.val = val
self.left = None
self.right = None | class TreeNode:
def __init__(self, val=0):
pass | 2 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 3 | 1 | 1 | 5 | 0 | 5 | 5 | 3 | 0 | 5 | 5 | 3 | 1 | 0 | 0 | 1 |
15,283 | keon/algorithms | keon_algorithms/algorithms/tree/bst/bst.py | bst.BST | class BST(object):
def __init__(self):
self.root = None
def get_root(self):
return self.root
'\n Get the number of elements\n Using recursion. Complexity O(logN)\n '
def size(self):
return self.recur_size(self.root)
def recur_size(self, root):
if ... | class BST(object):
def __init__(self):
pass
def get_root(self):
pass
def size(self):
pass
def recur_size(self, root):
pass
def search(self, data):
pass
def recur_search(self, root, data):
pass
def insert(self, data):
pass
de... | 12 | 0 | 5 | 0 | 5 | 1 | 2 | 0.39 | 1 | 2 | 1 | 0 | 11 | 1 | 11 | 11 | 84 | 10 | 59 | 13 | 47 | 23 | 51 | 13 | 39 | 5 | 1 | 2 | 23 |
15,284 | keon/algorithms | keon_algorithms/algorithms/tree/bst/bst.py | bst.Node | class Node(object):
def __init__(self, data):
self.data = data
self.left = None
self.right = None | class Node(object):
def __init__(self, data):
pass | 2 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 3 | 1 | 1 | 5 | 0 | 5 | 5 | 3 | 0 | 5 | 5 | 3 | 1 | 1 | 0 | 1 |
15,285 | keon/algorithms | keon_algorithms/algorithms/unionfind/count_islands.py | count_islands.Union | class Union:
"""
A Union-Find data structure.
Consider the following sequence of events:
Starting with the elements 1, 2, 3, and 4:
{1} {2} {3} {4}
Initally they all live in their own sets, which means that `root(1) !=
root(3)`, however, if we call `unite(1, 3)` we would then have the... | class Union:
'''
A Union-Find data structure.
Consider the following sequence of events:
Starting with the elements 1, 2, 3, and 4:
{1} {2} {3} {4}
Initally they all live in their own sets, which means that `root(1) !=
root(3)`, however, if we call `unite(1, 3)` we would then have the fo... | 5 | 4 | 9 | 1 | 6 | 3 | 2 | 1.17 | 0 | 0 | 0 | 0 | 4 | 3 | 4 | 4 | 67 | 17 | 23 | 9 | 18 | 27 | 23 | 9 | 18 | 3 | 0 | 1 | 7 |
15,286 | keon/algorithms | keon_algorithms/algorithms/tree/bst/delete_node.py | delete_node.Solution | class Solution(object):
def delete_node(self, root, key):
"""
:type root: TreeNode
:type key: int
:rtype: TreeNode
"""
if not root:
return None
if root.val == key:
if root.left:
left_right_most = root.left
... | class Solution(object):
def delete_node(self, root, key):
'''
:type root: TreeNode
:type key: int
:rtype: TreeNode
'''
pass | 2 | 1 | 26 | 1 | 16 | 9 | 6 | 0.53 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 27 | 1 | 17 | 3 | 15 | 9 | 15 | 3 | 13 | 6 | 1 | 3 | 6 |
15,287 | keon/algorithms | keon_algorithms/algorithms/tree/fenwick_tree/fenwick_tree.py | fenwick_tree.Fenwick_Tree | class Fenwick_Tree(object):
def __init__(self, freq):
self.arr = freq
self.n = len(freq)
def get_sum(self, bit_tree, i):
"""
Returns sum of arr[0..index]. This function assumes that the array is preprocessed and partial sums of array elements are stored in bit_tree[].
... | class Fenwick_Tree(object):
def __init__(self, freq):
pass
def get_sum(self, bit_tree, i):
'''
Returns sum of arr[0..index]. This function assumes that the array is preprocessed and partial sums of array elements are stored in bit_tree[].
'''
pass
def update_... | 5 | 3 | 13 | 3 | 5 | 5 | 2 | 0.9 | 1 | 1 | 0 | 0 | 4 | 2 | 4 | 4 | 56 | 16 | 21 | 10 | 16 | 19 | 21 | 10 | 16 | 2 | 1 | 1 | 7 |
15,288 | keon/algorithms | keon_algorithms/algorithms/tree/segment_tree/iterative_segment_tree.py | iterative_segment_tree.SegmentTree | class SegmentTree:
def __init__(self, arr, function):
self.tree = [None for _ in range(len(arr))] + arr
self.size = len(arr)
self.fn = function
self.build_tree()
def build_tree(self):
for i in range(self.size - 1, 0, -1):
self.tree[i] = self.fn(self.tree[i *... | class SegmentTree:
def __init__(self, arr, function):
pass
def build_tree(self):
pass
def update(self, p, v):
pass
def query(self, l, r):
pass | 5 | 0 | 6 | 0 | 6 | 0 | 3 | 0 | 0 | 1 | 0 | 0 | 4 | 3 | 4 | 4 | 28 | 3 | 25 | 10 | 20 | 0 | 25 | 10 | 20 | 6 | 0 | 2 | 11 |
15,289 | keon/algorithms | keon_algorithms/algorithms/tree/bst/kth_smallest.py | kth_smallest.Solution | class Solution(object):
def kth_smallest(self, root, k):
"""
:type root: TreeNode
:type k: int
:rtype: int
"""
count = []
self.helper(root, count)
return count[k - 1]
def helper(self, node, count):
if not node:
return
... | class Solution(object):
def kth_smallest(self, root, k):
'''
:type root: TreeNode
:type k: int
:rtype: int
'''
pass
def helper(self, node, count):
pass | 3 | 1 | 8 | 1 | 5 | 3 | 2 | 0.45 | 1 | 0 | 0 | 0 | 2 | 0 | 2 | 2 | 18 | 2 | 11 | 4 | 8 | 5 | 11 | 4 | 8 | 2 | 1 | 1 | 3 |
15,290 | keon/algorithms | keon_algorithms/algorithms/tree/red_black_tree/red_black_tree.py | red_black_tree.RBNode | class RBNode:
def __init__(self, val, is_red, parent=None, left=None, right=None):
self.val = val
self.parent = parent
self.left = left
self.right = right
self.color = is_red | class RBNode:
def __init__(self, val, is_red, parent=None, left=None, right=None):
pass | 2 | 0 | 6 | 0 | 6 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 5 | 1 | 1 | 7 | 0 | 7 | 7 | 5 | 0 | 7 | 7 | 5 | 1 | 0 | 0 | 1 |
15,291 | keon/algorithms | keon_algorithms/algorithms/tree/red_black_tree/red_black_tree.py | red_black_tree.RBTree | class RBTree:
def __init__(self):
self.root = None
def left_rotate(self, node):
right_node = node.right
if right_node is None:
return
else:
node.right = right_node.left
if right_node.left is not None:
right_node.left.parent = ... | class RBTree:
def __init__(self):
pass
def left_rotate(self, node):
pass
def right_rotate(self, node):
pass
def insert(self, node):
pass
def fix_insert(self, node):
pass
def transplant(self, node_u, node_v):
'''
replace u with v
... | 12 | 3 | 23 | 0 | 18 | 5 | 5 | 0.31 | 0 | 0 | 0 | 0 | 11 | 1 | 11 | 11 | 268 | 14 | 194 | 27 | 182 | 60 | 173 | 27 | 161 | 9 | 0 | 4 | 51 |
15,292 | keon/algorithms | keon_algorithms/algorithms/tree/segment_tree/segment_tree.py | segment_tree.SegmentTree | class SegmentTree:
def __init__(self, arr, function):
self.segment = [0 for x in range(3 * len(arr) + 3)]
self.arr = arr
self.fn = function
self.make_tree(0, 0, len(arr) - 1)
def make_tree(self, i, l, r):
if l == r:
self.segment[i] = self.arr[l]
elif... | class SegmentTree:
def __init__(self, arr, function):
pass
def make_tree(self, i, l, r):
pass
def __query(self, i, L, R, l, r):
pass
def query(self, L, R):
pass | 5 | 0 | 7 | 0 | 7 | 0 | 3 | 0 | 0 | 2 | 0 | 0 | 4 | 3 | 4 | 4 | 32 | 4 | 28 | 10 | 23 | 0 | 27 | 10 | 22 | 5 | 0 | 2 | 10 |
15,293 | keon/algorithms | keon_algorithms/algorithms/tree/bst/serialize_deserialize.py | serialize_deserialize.TreeNode | class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None | class TreeNode(object):
def __init__(self, x):
pass | 2 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 3 | 1 | 1 | 5 | 0 | 5 | 5 | 3 | 0 | 5 | 5 | 3 | 1 | 1 | 0 | 1 |
15,294 | keon/algorithms | keon_algorithms/algorithms/tree/trie/trie.py | trie.Trie | class Trie:
def __init__(self):
self.root = TrieNode()
def insert(self, word):
current = self.root
for letter in word:
current = current.children[letter]
current.is_word = True
def search(self, word):
current = self.root
for letter in word:
... | class Trie:
def __init__(self):
pass
def insert(self, word):
pass
def search(self, word):
pass
def starts_with(self, prefix):
pass | 5 | 0 | 5 | 0 | 5 | 0 | 2 | 0 | 0 | 1 | 1 | 0 | 4 | 1 | 4 | 4 | 25 | 3 | 22 | 12 | 17 | 0 | 22 | 12 | 17 | 3 | 0 | 2 | 9 |
15,295 | keon/algorithms | keon_algorithms/algorithms/tree/trie/trie.py | trie.TrieNode | import collections
class TrieNode:
def __init__(self):
self.children = collections.defaultdict(TrieNode)
self.is_word = False |
class TrieNode:
def __init__(self):
pass | 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 1 | 1 | 4 | 0 | 4 | 4 | 2 | 0 | 4 | 4 | 2 | 1 | 0 | 0 | 1 |
15,296 | slundberg/shap | slundberg_shap/shap/__init__.py | shap.UnsupportedModule | class UnsupportedModule:
def __getattribute__(self, item):
raise ImportError(_no_matplotlib_warning) | class UnsupportedModule:
def __getattribute__(self, item):
pass | 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 0 | 0 | 1 |
15,297 | slundberg/shap | slundberg_shap/shap/_explanation.py | shap._explanation.Cohorts | from typing import Any, Callable, cast
class Cohorts:
"""A collection of :class:`.Explanation` objects, typically each explaining a cluster of similar samples.
Examples
--------
A ``Cohorts`` object can be initialized in a variety of ways.
By explicitly specifying the cohorts:
>>> exp = Expl... |
class Cohorts:
'''A collection of :class:`.Explanation` objects, typically each explaining a cluster of similar samples.
Examples
--------
A ``Cohorts`` object can be initialized in a variety of ways.
By explicitly specifying the cohorts:
>>> exp = Explanation(
... values=np.random.unif... | 10 | 3 | 7 | 0 | 5 | 1 | 2 | 0.93 | 0 | 6 | 1 | 0 | 7 | 2 | 7 | 7 | 98 | 20 | 41 | 22 | 31 | 38 | 38 | 20 | 30 | 4 | 0 | 2 | 15 |
15,298 | slundberg/shap | slundberg_shap/shap/_explanation.py | shap._explanation.Explanation | from .utils._general import OpChain
import pandas as pd
from typing import Any, Callable, cast
import numpy as np
from slicer import Alias, Obj, Slicer
import operator
from .utils._clustering import hclust_ordering
from .utils._exceptions import DimensionError
import copy
class Explanation(metaclass=MetaExplanation):
... |
class Explanation(metaclass=MetaExplanation):
'''A sliceable set of parallel arrays representing a SHAP explanation.
Notes
-----
The *instance* methods such as `.max()` return new Explanation objects with the
operation applied.
The *class* methods such as `Explanation.max` return OpChain object... | 82 | 27 | 10 | 1 | 8 | 2 | 2 | 0.24 | 1 | 17 | 4 | 0 | 53 | 4 | 53 | 77 | 632 | 100 | 436 | 141 | 337 | 104 | 293 | 96 | 239 | 26 | 3 | 7 | 124 |
15,299 | slundberg/shap | slundberg_shap/shap/_explanation.py | shap._explanation.MetaExplanation | from .utils._general import OpChain
class MetaExplanation(type):
"""This metaclass exposes the Explanation object's class methods for creating template op chains."""
def __getitem__(cls, item):
return op_chain_root.__getitem__(item)
@property
def abs(cls) -> OpChain:
"""Element-wise a... |
class MetaExplanation(type):
'''This metaclass exposes the Explanation object's class methods for creating template op chains.'''
def __getitem__(cls, item):
pass
@property
def abs(cls) -> OpChain:
'''Element-wise absolute value op.'''
pass
@property
def identity(cls) -... | 22 | 11 | 3 | 0 | 2 | 1 | 1 | 0.33 | 1 | 1 | 1 | 1 | 11 | 0 | 11 | 24 | 55 | 11 | 33 | 22 | 11 | 11 | 23 | 12 | 11 | 1 | 2 | 0 | 11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.