Skip to content

zeroones

  • Home
  • Verilog
  • Python
  • Arduino
  • C
  • Contact

python qna

Python Program to Implement Shell Sorting

10 December 2022 by zeroones.org

01. Example: def gaps(size): length = size.bit_length() for k in range(length – 1, 0, -1): yield 2**k – 1 def shellSorting(data): def insertionSortingWithGap(gap): for i in range(gap, len(data)): temp = …

Read more

Python Program to Implement Counting Sorting

9 December 2022 by zeroones.org

01. Example: def countingSorting(data, largest): c = [0]*(largest + 1) for i in range(len(data)): c[data[i]] = c[data[i]] + 1 c[0] = c[0] – 1 for i in range(1, largest + …

Read more

Python Program to Implement Gnome Sorting

8 December 2022 by zeroones.org

01. Example: def gnomeSorting(data): for i in range(1, len(data)): while (i != 0 and data[i] < data[i – 1]): data[i], data[i – 1] = data[i – 1], data[i] i = …

Read more

Python Program to Implement Selection Sorting

7 December 2022 by zeroones.org

01. Example: def selectionSorting(data): for i in range(0, len(data) – 1): smallest = i for j in range(i + 1, len(data)): if data[j] < data[smallest]: smallest = j data[i], data[smallest] …

Read more

Python Program to Implement Bucket Sorting

6 December 2022 by zeroones.org

01. Example: def bucketSorting(data): largest = max(data) length = len(data) size = largest / length buckets = [[] for _ in range(length)] for i in range(length): j = int(data[i] / …

Read more

Python Program to Implement Insertion Sorting

5 December 2022 by zeroones.org

01. Example: def insertionSorting(data): for i in range(1, len(data)): temp = data[i] j = i – 1 while j >= 0 and temp < data[j]: data[j + 1] = data[j] …

Read more

Python Program to Implement Binary Insertion Sort

4 December 2022 by zeroones.org

01. Example: def binaryInsertionSort(data): for i in range(1, len(data)): temp = data[i] pos = binarySearch(data, temp, 0, i) + 1 for k in range(i, pos, -1): data[k] = data[k – …

Read more

Python Program to Implement Binary Search Without Using Recursion

3 December 2022 by zeroones.org

01. Example: def binarySearch(data, start, end, key): start = 0 end = len(data) while start < end: mid = (start + end)//2 if data[mid] > key: end = mid elif …

Read more

Python Program to Implement Binary Search Using Recursion

2 December 2022 by zeroones.org

01. Example: def binarySearch(data, start, end, key): if not start < end: return -1 mid = (start + end) // 2 if data[mid] < key: return binarySearch(data, mid + 1, …

Read more

Python Program To Sort Dictionary

12 November 2022 by zeroones.org

01. Example Using the key of dictionary. data = { "One": 1, "Two" : 2 , "Three" : 3, "Four" : 4 } for key in sorted(data.keys()) : print(key, "t …

Read more

Older posts
Newer posts
← Previous Page1 Page2 Page3 … Page10 Next →

Recent Posts

  • Top 50+ Python String Functions
  • The Next-Gen PCIe 7.0: What It Means for Computing
  • Open-Source EDA Tools for VLSI Design
  • NULL and nullptr in C++
  • Developing and Testing RISC-V SystemVerilog RTL with Open-Source Tools
© 2025 zeroones, All Rights Reserved.