Skip to main content

All Questions

8 votes
2 answers
1k views

Selection Sort Algorithm (Python)

Selection Sort The selection sort algorithm sorts a list by finding the minimum element from the right unsorted part of the list and putting it at the left sorted part of the list. The algorithm ...
Emma's user avatar
  • 3,592
2 votes
1 answer
2k views

Fast Prime Sieve (Python Implementation)

A modified version of the prime sieve. I actually doubt it could be implemented any faster, but I might be wrong: ...
Tobi Alafin's user avatar
  • 1,792
14 votes
4 answers
3k views

Shell Sort, Insertion Sort, Bubble Sort, Selection Sort Algorithms (Python)

There is a follow-up question available: shell-sort-insertion-sort-bubble-sort-selection-sort-algorithms-python. Selection Sort The selection sort algorithm sorts a list (array) by finding the ...
Emma's user avatar
  • 3,592
2 votes
1 answer
301 views

Sorting Algorithms (Python)

Selection Sort The selection sort algorithm sorts a list (array) by finding the minimum element from the right (unsorted part) of the list and putting it at the left (sorted part) of the list. The ...
Emma's user avatar
  • 3,592
12 votes
3 answers
3k views

A simple encryption program using Python

I made this encryption program in Python. I don't have much experience (or any experience at all) about encryption (since I just gave my 9th grade finals), but I had this idea about an algorithm some ...
Rajdeep Sindhu's user avatar
11 votes
3 answers
2k views

Producing and comparing maximum sub array sum algorithms

This is an exercise in implementing the maximum sub-array sum problem. It asks for several solutions of complexity: \$O(n)\$ \$O(n \log n)\$ \$O(n^2)\$ \$O(n^3)\$ For an additional challenge I ...
Legato's user avatar
  • 9,839
7 votes
2 answers
3k views

Magic Square (Python)

Problem Write a method to return a boolean if an input grid is magic square. A magic square is a \$NxN\$ square grid (where N is the number of cells on each side) filled with distinct positive ...
Emma's user avatar
  • 3,592
6 votes
4 answers
16k views

Longest substring in alphabetical order

The code is meant to find the longest substring that is in alphabetical order. I would like to know if I can do it more efficiently than I have done here. I am in my first week of my first ...
Turluf's user avatar
  • 61
5 votes
3 answers
5k views

Binary Tree Sort Algorithm (Python)

A Binary Tree Sort is an algorithm that builds a binary search tree from the elements to be sorted, and then traverses the tree (in-order) so that the elements come out in sorted order. Average Case ...
Emma's user avatar
  • 3,592
5 votes
1 answer
5k views

Find if one list is a subsequence of another

So the problem of verifying if a list is a subsequence of another came up in a discussion, and I wrote code that seems to work (I haven't rigorously tested it). IsSubequence.py ...
Tobi Alafin's user avatar
  • 1,792
5 votes
3 answers
1k views

LeetCode 65: Valid Number (Python)

Problem Validate if a given string can be interpreted as a decimal or scientific number. Some examples: ...
Emma's user avatar
  • 3,592
4 votes
2 answers
161 views

Return a minimum number of ranges from a collection of ranges

I'm new to Python and SWE in general so excuse the simple questions. I was given the following coding challenge by an interviewer. And I came up with the following solution. But I was passed over ...
Andrew Parmar's user avatar
3 votes
1 answer
109 views

Python: Quick Sort

How to improve this code? In C++ we use templates to write function for all data types. How to write such code in python? ...
coder's user avatar
  • 2,461
2 votes
1 answer
2k views

Shell Sort, Insertion Sort, Bubble Sort, Selection Sort Algorithms

There are seven sorting algorithms in the code copied below. The first five algorithms have been previously reviewed in this link. Selection Sort The Selection Sort algorithm sorts a list by ...
Emma's user avatar
  • 3,592
2 votes
1 answer
80 views

Merging Two Bubble Sorted Linked Lists (Python)

I'm following a tutorial on merging two bubble-sorted Single Linked Lists in Python. merge1 creates a new list and does the merging. Other than naming conventions ...
Emma's user avatar
  • 3,592

15 30 50 per page