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
2
votes
1 answer

Python Generate a lexicographic ordered output from array of strings

I'm working on a Python(3) program in which I have to write a function to generate an output which will be a list of strings in lexicographically order. Here's an example: if we pass a string like: ??2??00 which i called a pattern then it has to…
Abdul Rehman
  • 5,326
  • 9
  • 77
  • 150
2
votes
1 answer

Floating point serialization, lexicographical comparison == floating point comparison

I'm looking for a way to serialize floating points so that in their serialized form a lexicographical comparison is the same as a floating point comparison. I think it is possible by storing it in the form: | signed bit (1 for positive) | exponent |…
dan_waterworth
  • 6,261
  • 1
  • 30
  • 41
2
votes
1 answer

Create a List of string in ascending Order in lexicographically order

I want to generate a algorithm in which I want to get the next string in lexicographically order. Suppose I want to generate a list of length 26 then it is ['a','b'....'z'] Now suppose I want to generate a list of length 260 then it is…
abhaygarg12493
  • 1,565
  • 2
  • 20
  • 40
2
votes
1 answer

Get permutations in lexicographic order using Haskell

I'm working on problem 24 from Project Euler which is as follows: A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically…
dsaxton
  • 995
  • 2
  • 10
  • 23
2
votes
1 answer

Case agnostic lexicographical ordering in redis sorted set

I have a large list of strings (contains usernames, approx 350K records). I need to store it sorted by lexicographical ordering, and ought to be able to retrieve member existence* and member likeness** efficiently. Redis sorted sets look like the…
Hassan Baig
  • 15,055
  • 27
  • 102
  • 205
2
votes
2 answers

Fast way to do lexicographical comparing 2 numbers

I'm trying to sort a vector of unsigned int in lexicographical order. The std::lexicographical_compare function only supports iterators so I'm not sure how to compare two numbers. This is the code I'm trying to…
SuperMurloc
  • 189
  • 1
  • 3
  • 13
2
votes
3 answers

Lazy evaluation of variables

I want to lexicographically compare two lists, but the values inside the list should be computed when needed. For instance, for these two lists a = list([1, 3, 3]) b = list([1, 2, 2]) (a < b) == False (b < a) == True I'd like the values in the…
orange
  • 7,755
  • 14
  • 75
  • 139
2
votes
1 answer

rotate a string and print out the lexicographically largest rotation

s = raw_input() n = len(s) el = [] z = n - 1 while z >= 0: x = s[z:] + s[:z] z = z - 1 el.append(x) print max(el) The code is working fine but it is very inefficient. Is there a more time efficient method to solve the problem?
2
votes
1 answer

AngularJS orderBy using lexicographical ordering even with numbers

I have a value function which is passed into my orderBy as: function getValue(item){ return [parseInt(item.approx_value_usd) || -1]; } This definitely always returns a number array, but for some reason on the front-end AngularJS always orders…
Tito
  • 832
  • 10
  • 24
2
votes
2 answers

Iterator for all lexicographically ordered variable strings up to length n

I'm trying to create an iterator/generator of all variable length strings given an alphabet and a maximum string length, sorted in lexicographic order. Currently, I have a naive method that uses nested itertools product(), then proceeds to sort.…
user2875414
2
votes
1 answer

Lexicographically larger strings

I'm trying to understand the concept of lexicographically larger or smaller strings. My book gives some examples of strings that are lexicographically larger or smaller than each other and an intermediary string that is between the two in…
JIL
  • 21
  • 1
  • 3
2
votes
1 answer

Generating all lexicographical permutations without comparisons of elements

I came into the problem when I have a given sequence s=(a,b,c,d,e...) - sorted in non-decreasing order. My job is to develop an algorithm that is going to generate all possible permutations in lexicographical order - ending on the reversed s…
maciek
  • 1,807
  • 2
  • 18
  • 30
2
votes
5 answers

Java: Three strings, lexicographic order

beginner Java programmer here. I am trying to compare three strings to each other, and have the system spit out the second/middle word in lexicographic order. import java.util.*; public class Ordered2 { public static void main(String[] args) { …
TGautier
  • 47
  • 1
  • 1
  • 8
2
votes
1 answer

Generating lexicographic permutations: Segmentation fault

I have this code to generate lexicographic permutations. The following logic is used: Start from the increasing order arrangement of the chars in a given test string. To generate next lexicographic permutation: a) find the rightmost character…
psiyumm
  • 6,437
  • 3
  • 29
  • 50
2
votes
2 answers

C++: Lexicographic comparing strings using operators

As I understand it if I compare two strings using the operators like the lesser-than (<) C++ will compare them Lexicographically. I´d like to take advantage of this searching through a array and return the smallest lexicographic value. And for than…
Tom Lilletveit
  • 1,872
  • 3
  • 31
  • 57