For example, if it is a $ O(2^n) $ algorithm that loops through 0 to $ 2^n – 1 $ and check whether the number of 1 bits is divisible by 3, 5, 7, 9, 11, does quantum computing reduce it to non-exponential time and how?

# Tag: algorithm

## When do we would like to use array as the data structure in Dijkstra’s algorithm instead of heap for perfmance

When do we would like to use array as the data structure in Dijkstra’s algorithm instead of heap for performance gain ?

## Which sor algorithm to choose given two specific arrays?

**Interview question:**

Given array A which contains only odd numbers and array B which contains only even numbers, explain which sort algorithm would you choose.

I said merge sort and was asked if the numbers were not even or odd would I have chosen merge sort still? Yes I said.

## Why maximum-matching algorithm falls into the category of fill-reducing algorithms?

My understanding is that “maximum matching” (or “maximum transversal”) are algorithms to pre-order matrix to increase the numerical stability. In Timothy Davis’ book *Direct Methods for Sparse Linear Systems, 2006*, however, this algorithm is put in Chapter 7 which is titled “Fill-reducing ordering”. In his more recent paper *A survey of direct methods for sparse linear systems, 2016*, maximum matching was also placed in section 8 which is titled “Fill-reducing orderings”.

So far, my had an impression that reordering algorithms can be categorized into 3 classes:

- for numerical stability: maximum transversal, etc
- for fill-reducing: AMD, etc
- for work-reducing or parallelism-increasing: BTF, BBD, etc

I have problems in understanding putting above 3 classes into a single category called fill-reducing…

## How to code an algorithm to generate a random but valid train track layout?

I am wondering if I have quantity C of curved tracks and quantity S of straight tracks, how I could write a computer program to design a “random” layout using all of those tracks, such that the following rules are satisfied:

1) The tracks, when all connected, form a closed (continuous) loop for the train to go around.

2) Ramps, bending of tracks, bumping of tracks, crossing of tracks are all not allowed.

So would the computer program have to create a geometric model and remember the exact positions of each track or is there some simpler way to code this? I want to be able to “push a button” and the computer “spits out” a valid “new” layout for me.

Do I need to give the exact measurements of the 2 types of tracks? If so, I can provide those.

I have some coding skills but I need to know an algorithm first before I can code something meaningful (other than just testing a few parts of a candidate algorithm)

## What’s the correct algorithm to filter accumulating string concatenations?

I have a function that is receiving messages with the following pattern:

(In this picture, “string” and “message” are synonymous.)

I’m only interested in the largest messages, such as these:

over a particular window.

Is there an algorithm that can appropriately filter the messages in the desired manner over a specified window?

## I want to publish my new sorting algorithm

I have made a new sorting algorithm that is working in O(N log N) in every case. I want to publish this sort under the supervision of a professor as I am a newbie on the research side and also a professor can look to the algorithm from every perspective. I have contacted some professors worldwide but none of them reply to me yet and I have compared my runtime analysis with other sorting algorithms it is efficient than other divide and conquer based algorithms the time complexity is the same like merge sort but my algorithm is taking fewer operations when the size of the input increases. If anyone knows someone’s who can review my work or want to know more about my work then please let me know. LinkedIn

## Converting non-deterministic algorithm to deterministic

I was thinking about an non-deterministic algorithm to generate all the subsets of the $ \{1..n\}$ set.

`Subsets(n) S' = null for i = 1..n u = choice(1..n) if u in S' fail S' = S' + u for_each u in S' print u `

How would I convert this algorithm into a deterministic form? I know that it is a lot more complicated to convert the `choice`

statement in a deterministic manner but I want to get a general idea about maybe representing it in a deterministic manner.

## Induction proof given recurrence of algorithm

I am having trouble starting this proof and wanted some clarification. Here are the details given:

`ArrayList<T> sort (ArrayList<T> A) { if (A.size() <= THRESHOLD) { ArrayList<T> B = copy(A) insertionSort(B) returnB } else { ArrayList<T> B1 = new ArrayList<T>() ArrayList<T> B2 = new ArrayList<T>() split(A, B1, B2) ArrayList<T> C1 = sort(B1) ArrayList<T> C2 = sort(B2) return merge(C1, C2) } } `

Let $ T_{THRESHOLD}(n)$ be the maximum number of steps executed by the algorithm when executed on an input array with a positive length $ n$ . All of the constants used in the equations are all greater than 0.

\begin{equation} T_{THRESHOLD} (n) \leq \begin{cases} \alpha n^2 + \beta n + \delta & \text{if $ n \leq \mathrm{THRESHOLD}$ }\ T_{THRESHOLD}(\lceil n/2 \rceil,k) + T_{THRESHOLD}(\lfloor n/2 \rfloor,k) + \gamma n + \zeta & \text{if $ n > \mathrm{THRESHOLD}$ }\ \end{cases} \end{equation}

and for positive integers $ n$ and $ k$ :

\begin{equation} T(n,k) = \begin{cases} \alpha n^2 + \beta n + \delta & \text{if $ n \leq k$ }\ T(\lceil n/2 \rceil,k) + T(\lfloor n/2 \rfloor,k) + \gamma n + \zeta & \text{if $ n > k$ }\ \end{cases} \end{equation}

Then it is asked to prove that if THRESHOLD is a positive integer then $ T_{\mathrm{THRESHOLD}}(n) \leq T(n, \mathrm{THRESHOLD})$ for every positive integer $ n$ .

I was then wondering if it is required to use Constructive Induction for a question like this since the recurrence equations have been provided. As well, how would you go about doing the induction with two variables (THRESHOLD and $ n$ ). Anything helps, thank you.

## Grover’s algorithm on probabilistic classical machines

My understanding is that polynomial-time quantum algorithms can be simulated by classical polynomial-time probabilistic algorithms, by simulating the quantum gates individually.

However, implementing an algorithm such as Grover’s with that construction is some sense unsatisfyingly “unnatural” – we have to set up a radically different computation environment and do the calculations inside, rather than directly expressing what we want in classical operations.

Has anyone constructed an algorithm with the same characteristics as Grover’s (i.e. search a list of $ N$ for a marked item in $ O(\sqrt N)$ time with success probability $ \geq 0.5$ ) more directly in classical probabilistic manipulations? Obviously it being “more natural” does not imply anything must exist, but it seems counterintuitive for this to *only* be possible by the roundabout method of building a quantum environment to do the calculation in.