MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / find

Method find

data_structures/linked_list/skip_list.py:226–246  ·  view source on GitHub ↗

:param key: Search key. :return: Value associated with given key or None if given key is not present. >>> skip_list = SkipList() >>> skip_list.find(2) >>> skip_list.insert(2, "Two") >>> skip_list.find(2) 'Two' >>> skip_list.insert(2,

(self, key: VT)

Source from the content-addressed store, hash-verified

224 update_node.forward[i] = new_node
225
226 def find(self, key: VT) -> VT | None:
227 """
228 :param key: Search key.
229 :return: Value associated with given key or None if given key is not present.
230
231 >>> skip_list = SkipList()
232 >>> skip_list.find(2)
233 >>> skip_list.insert(2, "Two")
234 >>> skip_list.find(2)
235 'Two'
236 >>> skip_list.insert(2, "Three")
237 >>> skip_list.find(2)
238 'Three'
239 """
240
241 node, _ = self._locate_node(key)
242
243 if node is not None:
244 return node.value
245
246 return None
247
248
249def test_insert():

Calls 1

_locate_nodeMethod · 0.95