# Progress bar for unknown number of items

I am working on a survey-based feature in our application and the survey has branching points at any given question depending on the answer given. Each path that a branch can take may not have the same number of questions. So if we evaluated each possible path that can be taken, you may end up with a different number of total questions answered each time.

I've been told a progress bar is required for the survey, however I can't imagine how a progress bar could provide meaningful data in this context. We do not know how many questions must be answered until the survey ends without hindsight. Can anyone recommend a good logical solution to implementing a progress bar for such a feature?

I don't need specifics. The UI system I'm using, the language I'm using, all of that is irrelevant. I want a strictly mathematical solution to this problem, should one exist. If not, then using things like estimations, averaging, or other "guesstimates" are also good but last resorts.

## Approach 1: Subdivide sections.

You've got four sections, each section is thus 25% of the total survey in this model. If you answer a question at the start of section 1 that leads to the path of "skip all the rest of section 1" that then has you 25% done.

Within each section, you have some questions and maybe other branching paths. If section 1 has 5 questions, each question in section 1 is then 5% of the total survey... no matter how many questions are in section 2.

• easy to calculate
• questions have different values

## Approach 2: Based on the long case

Lets say you have 100 questions that could be asked. Each question is 1% of the total.

If you answer question #5 in such a way that it skips to question #10 you go from 5% complete to 10% complete.

• easyish to calculate
• still possible to have jumps
• smoother transitions for each unit done

Note that if you have two paths:

• Answer A (5%) -> 3 questions -> C (10%)
• Answer B (5%) -> 5 questions -> C (10%)

You've got the situation where while the questions on path A are worth 1%, you will either have non-unit increment questions or a skip (5%, 6%, 7%, 8%, 10%)

Given that it's a feature designed to provide the user with an estimate of time until completion I would suggest determining the 'progress' level by the longest possible number of questions remaining. Unless you have an infinite loop possible in the survey, this will provide reasonable and useful feedback for your users.

If the survey can be up to 100 questions then your progress would be

`100-(current_question.longest_dist_to_finish())`

At the start this will always be an empty bar and it should get more and more accurate as choices start disappearing.

• Good answer. A depth first search or variant would be good. Maybe adding some UI flourishes would help. It shouldn't be too obvious that the bar is inaccurate at the beginning (unless that is a firm requirement). Unless you need to know then it is just confusing information. – Encaitar Mar 14 '14 at 23:42