Questions tagged [lexicographic]

lexicographic or lexicographical order is a generalization of the way the alphabetical order of words is based on the alphabetical order of their component letters.

Definition:

Given two partially ordered sets A and B, the lexicographical order on the Cartesian product A × B is defined as

(a,b) ≤ (a′,b′) if and only if a < a′ or (a = a′ and b ≤ b′).

The result is a partial order. If A and B are totally ordered, then the result is a total order as well. More generally, one can define the lexicographic order on the Cartesian product of n ordered sets, on the Cartesian product of a countably infinite family of ordered sets, and on the union of such sets.

Read more

238 questions
0
votes
2 answers

System.Text.Json: Sort by key Hashtable?

I am serializing my object using a simple: var options = new JsonSerializerOptions { WriteIndented = true, IncludeFields = true}; string jsonString = JsonSerializer.Serialize(obj, options); File.WriteAllText("output.json", jsonString); However my…
malat
  • 12,152
  • 13
  • 89
  • 158
0
votes
1 answer

Comparison approximation in c++

Is there a way to change the precision of the predefined <= and < in the comparison between std::vector vectors lexicographically ? I am comparing between std::vector vectors lexicographically in many places in my code, the scale…
Emy John
  • 1
  • 1
0
votes
1 answer

c sort input by Lexicographic order without knowing the number of words in advance

i would like to solve this problem: the user gives an input of words, separated by ', '. i don't know how many words he would give. the output should be: all words are sorted by a Lexicographic order. i also need to have an access to this output for…
yarden
  • 31
  • 3
0
votes
2 answers

Is there a way to jump over specific strings on an iteration of a list of strings that is sorted lexicographically in Java?

I have a list of strings lst that is sorted lexicographically and I want to iterate over the list in a way that each iteration, I jump to a string that starts with the following letter of the first letter of the previous string. For example,…
0
votes
1 answer

R Code package markovchain doesn't properly recognize numbers as states

I have checked the documentation of the package and found an example of how they fitted a DTMC on data.frame objects using the following code: library(holson) data(holson) singleMc<-markovchainFit(data=holson[,2:12],name="holson") The data I apply…
0
votes
1 answer

Java: Invert the lexicographic order of a string

Consider this example of inverting the order of numbers from 0 to 10: x -> 10-x This inverts the order in a bijective way. If I put in 100 numbers from 0 to 10 and it holds a < b for some a and b, then after applying the above formula, it holds a >…
mathematics-and-caffeine
  • 1,664
  • 2
  • 15
  • 19
0
votes
1 answer

Sorting a list of frozensets?

Is it possible to lexicographically sort a list of frozensets as in the following example: sort_frozensets(frozenset(['d','b']), frozenset(['a','b']), frozenset(['z','a']), frozenset(['l',''m])) #result = frozenset(['a','b']), frozenset(['z','a']),…
0
votes
2 answers

Floating point comparison broken by locale change between bash 3.2 and 4.3

$ echo $BASH_VERSION 3.2.57(1)-release $ [[ "1.9" < "11.0" ]] && echo yes yes $ $ echo $BASH_VERSION 4.3.11(1)-release $ [[ "1.9" < "11.0" ]] && echo yes $ Here is "why" it doesn't work since 4.1: Within double brackets, the > and < string…
Michael Chen
  • 631
  • 5
  • 12
0
votes
2 answers

Assign a unique value to a string s based on its lexicographic order

I want to come up with a function that assigns unique values to a string based on it's lexicographic order. For instance if my function is labelled as get_key(s), the function should take as input a string s and return a unique integer which will…
0
votes
1 answer

Pythonic Way of Lexicographically Sorting Keys of an OrderedDict On Insert

I have the following class that keeps track of an OrderedDict: class LexDict: def __init__(self): self.m_map = OrderedDict() # maps string which is case-sensitive to int def set(self,id,seqNo): self.m_map[id] = seqNo …
0
votes
2 answers

Given n and a particular permutation s, find the next permutation in lexicographic order of elements 1-n (python)

For example, suppose we have NextInOrder(10,(1,2,4,7)), then with these two as inputs for the function, I wish to write a python function that returns (1,2,4,8) by finding the next permutation in lexicographic order where elements of the permutation…
0
votes
1 answer

Arranging columns in a matrix lexicographically

I've been trying to sort columns in a matrix (the dimensions are m,n <= 10) via the lexicographical order (if the columns share the same element, then we compare the elements in the row beneath etc.) with some additional conditions. I need to use…
0
votes
1 answer

Recursively printing only lexicographically larger substrings

I was writing a code for printing only the lexicographically larger substrings of a string recursively. static ArrayList getPermutations(String str) { if (str.length() == 0) { ArrayList tempArrayList = new…
Nitish
  • 13
  • 4
0
votes
1 answer

is there any way of sorting an array of string in lexicographically in O(N)?

there is an approach using strcmp() and strcpy() but it is O(n^2) but is there any faster method?
sahil pant
  • 15
  • 1
  • 4
0
votes
3 answers

List of increasing lists

Given integers n >= m, I want to build the list of all increasing lists of length m with elements the set {1,...,n}. For instance, if n= 4 and m=2, I want [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]. Is there a nice way to do that with very few…
Julien
  • 125
  • 9