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

  • SEARCH
  • Home
  • 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 3355854
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:26:40+00:00 2026-05-18T02:26:40+00:00

I am given a string of characters, in which every consequent pair of characters

  • 0

I am given a string of characters, in which every consequent pair of characters comprises an edge. What I mean by that is this is the string: ABBCAD. Edges of the string are:

A->B
B->C
A->D

Shortest path distance is A->D

The task at hand is to build up a Directed Acyclic Graph in memory from the string using the above rule and find the shortest path staring at the root node(in the example given it’s A label) ending at terminal node.

NJKUUGHBNNJHYAPOYJHNRMNIKAIILFGJSNAICZQRNM

I gather one of the approaches that suites the task is to use the Depth First Search algo.

This is not homework…

  • 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-05-18T02:26:41+00:00Added an answer on May 18, 2026 at 2:26 am

    This is a job for Djikstra’s Algorithm. Once you build a representation of your graph it should be easy enough to produce the lowest cost traversal … since in your case it seems that all paths have an equal cost (1).

    You can look here on CodeProject for a reasonably decent implementation of Djikstra in C#.

    could you present me with a pseudo code of your version of the graph representation for this case?

    There are multiple ways to represent a graph in such a problem. If the number of vertices in your graph are likely to be small – it would be sufficient to use an adjacency matrix for the representation of edges. In which case, you could just use a .NET multidimensional array. The trick here is that you need to convert vertices labelled with characters to ordinal values. One approach would be to write a wrapper class that maps character codes to indices into the adjacency matrix:

    class AdjacencyMatrix
    {
        // representation of the adjacency matrix (AM)
        private readonly int[,] m_Matrix;
        // mapping of character codes to indices in the AM
        private readonly Dictionary<char,int> m_Mapping;
    
        public AdjacencyMatrix( string edgeVector )
        {
            // using LINQ we can identify and order the distinct characters
            char[] distinctChars = edgeVector.Distinct().OrderBy(x => x);
    
            m_Mapping = distinctChars.Select((c,i)=>new { Vertex = c, Index = i })
                                     .ToDictionary(x=>x.Vertex, x=>x.Index);
    
            // build the adjacency cost matrix here...
            // TODO: I leave this up to the reader to complete ... :-D
        }
    
        // retrieves an entry from within the adjacency matrix given two characters
        public int this[char v1, char v2]
        {
            get { return m_Matrix[m_Mapping[v1], m_Mapping[v2]];
            private set { m_Matrix[m_Mapping[v1], m_Mapping[v2]] = value; }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code that searches for a given string of characters ( _aff.tractionsCode
There's something very unsatisfactory about this code: /* Given a command string in which
I'm in need to modify a given string to contain only alpha numerical characters,
I've been looking for a way to hash a given string in C# that
Here is the problem: Remove specified characters from a given string. Input: The string
I am trying to figure out a regular expression which matches any string that
Given this string HELLO水 Legend: http://en.wikipedia.org/wiki/UTF-16 is 4 bytes 水 is 2 bytes Postgresql
I need to calculate how many times every character occurs in the given string.
Question Using XSLT 1.0, given a string with arbitrary characters how can I get
I was given to understand that calling print obj would call obj.__str__() which would

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.