Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8410433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:10:29+00:00 2026-06-10T00:10:29+00:00

This should be a simple logic problem but for some reason I’ve been struggling

  • 0

This should be a simple logic problem but for some reason I’ve been struggling with it for hours trying to come up with a semi-clean algorithm to implement this. I’m using MVC3 with a SQL Server background, but even if you don’t know about MVC you might still be able to help me with the algorithm.

I’m writing an application that makes use of a wizard-like interface. For now, the navigation between those wizard screens is very linear (the next button goes to the page immediately after, previous button goes to page immediately before). Due to scope change (fun, I know) I’ve now been told to make this less linear.

For the first run-through, the user has to visit all pages in linear order, like so:

Step 1
Step 2
Step 3
    SubStep 1
        Sub-SubStep 1
        Sub-SubStep 2
    SubStep 2
        Sub-SubStep 1
        Sub-SubStep 2
    ...
    SubStep *n*
        Sub-SubStep 1
        Sub-SubStep 2
Submission

Where n is variable based on something that was entered in Step 2.

After the wizard is submitted it is reviewed by an administrator. If they find information missing they can unlock certain pages. When the user goes back to enter that information they should only be able to view those certain pages. For example, navigation might be like so:

Step 2
Step 3
    SubStep 1
        Sub-SubStep2
Submission

My current implementation consists of a table in the database that keeps track of the unlocked pages. When the “Next” button is clicked it calls a method to determine what the next page is. Because of the strange and variable navigation that takes place in Step 3 this method is an if-else branching nightmare which is easily broken.

Any suggestions on simplifying this would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:10:32+00:00Added an answer on June 10, 2026 at 12:10 am

    If you create a tree structure that represents the navigation hierarchy, a preorder traversal of the tree will hit the pages in the desired linear order. You can run such a traversal, and when you hit the current page, you can continue the traversal until you find an unlocked page, which will be the desired next page.

    Pseudocode:

    class TreeNode:
        string name
        List<TreeNode> children
    
    string findNextPage(TreeNode node, Set<string> unlockedPageNames, 
                        string currentPageName, ref bool currentPageFound):
        if currentPageFound && unlockedPageNames.Contains(node.name):
            return node.name
        if node.name == currentPageName:
            currentPageFound = true
        foreach child in children:
            result = findNextPage(child, unlockedPageNames, 
                                  currentPageName, currentPageFound)
            if result != null:
                return result
        return null
    
    string findNextPage(TreeNode node, Set<string> unlockedPageNames, 
                        string currentPageName):
        bool currentPageFound = false
        return findNextPage(node, unlockedPageNames, 
                            currentPageName, currentPageFound)
    

    Note that you need a root node, whose children must be Step 1, Step 2, and Step 3. Pass this root node to the last findNextPage() function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This should be simple task but i am not been able to find the
I think this should be simple but I am having some difficulty implementing it.
this should be a simple question, but the answer has eluded me for some
This should be simple, but I'm getting confused. I have a parent/child tables -
This should be simple, but the answer is eluding me. If I've got a
This should seem simple enough, but can't figure it out. I was porting a
This should be simple, but I am still lost. There is a very similar
Seems like this should be simple, but powershell is winning another battle with me.
I think this should be simple, but im having a real hard time finding
since I'm trying to solve this problem for some days, I thought about giving

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.