Ongeveer 80.500 resultaten
Koppelingen in nieuw tabblad openen
  1. Algorithms are step-by-step procedures for solving problems, and Python offers a clean syntax to implement them efficiently. They can be sorting, searching, graph traversal, dynamic programming, or greedy approaches depending on the problem type.

    Below is a practical example of Merge Sort, a classic divide-and-conquer sorting algorithm that splits a list into halves, sorts each half, and merges them back together.

    def merge_sort(arr):
    if len(arr) <= 1:
    return arr

    # Divide the array into two halves
    mid = len(arr) // 2
    left_half = merge_sort(arr[:mid])
    right_half = merge_sort(arr[mid:])

    return merge(left_half, right_half)

    def merge(left, right):
    result = []
    i = j = 0

    # Merge two sorted halves
    while i < len(left) and j < len(right):
    if left[i] <= right[j]:
    result.append(left[i])
    i += 1
    else:
    result.append(right[j])
    j += 1

    # Append remaining elements
    result.extend(left[i:])
    result.extend(right[j:])
    return result

    # Example usage
    arr = [38, 27, 43, 3, 9, 82, 10]
    sorted_arr = merge_sort(arr)
    print("Sorted array:", sorted_arr)
    Gekopieerd.
    Feedback
  2. Algorithms Tutorials – Real Python

    11 jul. 2025 · Build your algorithm skills in Python with hands-on tutorials that cover sorting, searching, graphs, greedy techniques, and dynamic programming. You will learn to think in Big O, pick the right …

  3. Einführung in Algorithmen und Datenstrukturen in Python

    9 feb. 2024 · Dieses Tutorial bietet einen einsteigerfreundlichen Überblick über grundlegende Algorithmen und Datenstrukturen in Python. Wir haben …