# Questions tagged [algorithms]

An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem. Use this tag when your issue is related to design and analysis of algorithms.

10,499 questions
Filter by
Sorted by
Tagged with
44 views

### Make maximum number of numbers with $n$ digits

Let $A=[1..n]$ be an array of $n$ decimal digits. $A[i]$ contains one number from $\{0,1,\dots,9\}$. We can put adjacent elements of $A$ beside them to form a number in which, created number should ...
34 views

### Finding longest subsequence in a given sequence

Suppose given a sequence $X$ of numbers. We want to find the longest subsequence $X′$ of $X$ in which, for each $i$,$$2X′[i]<X′[i−1]+X′[i+1].$$ I think this problem is related to the longest ...
1 vote
57 views

### Are there invariants in text processing problems?

I have read that when programming it is good to identify relations -- invariants -- that should hold true throughout the program, and it is good to insert assertions throughout the code to check that ...
44 views

### Performant way to find all leaf nodes in a undirected graph

I am trying to find a better way to find all leaf nodes in my undirected waypoint graph. This is how I define a leaf node: A leaf node is a node that is never part of a cycle and so has to meet one of ...
63 views

1 vote
17 views

### Deterministic Algorithm for searching for object $d$ units down one road in a $k$ road intersection

Suppose we are at the centre of a $k$ road intersection (i.e, there are $k$ different roads radiating out from where we are standing, infinitely). Suppose along one of these roads is a treasure. This ...
54 views

### NP-completeness of some problems on assigning candidates to departments

Suppose we have $n$ candidates from a candidate pool $\{1,2, .., n\}$ and we have $m$ departments. A candidate can be assigned to at most one department (so not being assigned is possible). Each ...
59 views

45 views

### What is the BigO of a C# function when runtime is 3n - logn + 1

I am trying to learn notations for a course and I am stuck on how to even start. I need to figure out the BigO for this function. Question is there's a C# function bool isPalindrome(string S) which ...
1 vote
37 views

### Use induction to prove the correctness of shortest path algorithm

Suppose given a directed graph $G=(V,E)$ with positive weights and we try to find shortest path $d(s,t,\ell)$ from $s$ to $t$ such that we traverse at most $\ell$ edges ($\ell$ is even). Let $w(u,v)$ ...
1 vote