## programming challenge – GeeksForGeeks: C # extraterrestrial dictionary

https://www.geeksforgeeks.org/given-sorted-dictionary-find-precedence-characters/

please check the performance, the adjacency list is the problematic part for me.

Given a sorted dictionary (word table) of a foreign language, find
order of characters in the language. Examples:

Input: words () = {"baa", "abcd", "abca", "cab", "cad"} Exit: Order
of characters is & # 39; b & # 39 ;, & # 39; d & # 39 ;, & # 39; a & # 39 ;, & # 39; c & # 39; Note that the words are sorted and
the given language "baa" comes before "abcd", so & # 39; b & # 39; is before
& # 39; a & # 39; output. Likewise, we can find other orders.

Input: words () = {"caa", "aaa", "aab"} Output: The order of the characters is
& # 39; taxi & # 39;

``````using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GraphsQuestions.Properties
{
///
/// https://www.geeksforgeeks.org/given-sorted-dictionary-find-precedence-characters/
///
(TestClass)
public class AlienDictionaryTest
{
(TestMethod)
public void ExampleTest1()
{
string() words = {"baa", "abcd", "abca", "cab", "cad"};
int numOfChars = 4;
var expected = new List{'b', 'd', 'a', 'c'};
Solution solution = new Solution(numOfChars, words);
List res = solution.Sort();
CollectionAssert.AreEqual(expected,res );
}

(TestMethod)
public void ExampleTest2()
{
string() words = { "caa", "aaa", "aab" };
int numOfChars = 3;
var expected = new List { 'c','a','b' };
Solution solution = new Solution(numOfChars, words);
List res = solution.Sort();
CollectionAssert.AreEqual(expected, res);
}
}

public class Solution
{
private Graph _graph;
public Solution(int numOfChars, string() words)
{
_graph = new Graph(numOfChars);
for (int i = 0; i < words.Length-1; i++)
{
string word1 = words(i);
string word2 = words(i + 1);
for (int j = 0; j < Math.Min(word1.Length, word2.Length); j++)
{
if (word1(j) != word2(j))
{
_graph.AddEdge(word1(j) - 'a', word2(j) - 'a');
break;
}
}
}
}

public List Sort()
{
return _graph.TopologicalSort();
}

}

public class Graph
{
// for each letter we create a vertex
public Graph(int numOfchars)
{
for (int i = 0; i < numOfchars; i++)
{
}
}
///
/// run through the entire adj list
/// and run DFS from each node to their neighbors
///
///
public List TopologicalSort()
{
var stack = new Stack();
for (int i = 0; i < _adjList.Count; i++)
{
if (!visited(i))
{
DFS(i, visited, stack);
}
}

var res = new List();
while (stack.Count > 0)
{
}

return res;
}

///
/// mark the current node as visited and recurs to the adj nodes
///
///
///
///
private void DFS(int index, bool() visited, Stack stack)
{
visited(index) = true;
{
if (!visited(node))
{
DFS(node, visited, stack);
}
}
stack.Push(index);
}

///
/// add an edge between char1 to char2
///  this will mark the adj between them
///
///
///
public void AddEdge(int char1, int char2)
{
}
}
}
``````

Posted on

## 100 word essay on the robot for the moment

BlackHatKings: General Discussion on PPC
Posted by: GalenEa
Post time: February 5, 2019 at 4:46.

Posted on

## Why not believe in extraterrestrial life?

There is a problem with this word "believe".

I would say that it is statistically unlikely that life does not exist elsewhere in the universe. I've personally calculated the odds at 10 ^ (10 ^ -18). In other words, a decimal point followed by a quintillion of zeros followed by a 1. Of course, this figure corresponds to life of any kind, but the chances that the Earth has the only technological life in the world. Universes are not so completely ridiculous, but always at a distance.

I have my own solution to the Fermi paradox.

.

Posted on