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
3 answers

How to count how many words in a .txt file? in C

This is my first time posting a question. So I am working on a homework program and am a little stuck on a couple of things that I hope someone can chime in and help me with. Here is what I need to do in the program: Your program must read in a…
1
vote
0 answers

Sorting array of Strings in lexicographic order

I am trying to modify the merge sort algorithm to sort an array of strings in lexicographic order, I am not really advanced so I may be making some newbie mistakes. This is the main and the tester and the mergesorter. public class MergeSorter { …
Bart g
  • 587
  • 2
  • 13
  • 28
1
vote
2 answers

Get leading element for the lexicographical order

If M is a numeric matrix, I can order its rows with respect to the lexicographical order by running lexsort(M) where lexorder <- function(M) { do.call(order, lapply(seq_len(ncol(M)), function(i) M[, i])) } lexsort <- function(M) { M[lexorder(M),…
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225
1
vote
0 answers

Generate interleavings of two strings in lexicographical order in Python

How to generate interleavings of two strings in lexicograhical order in python? I was able to generate interleavings, but not in lexicographical order. The input given was, Input : 2 nkb gl bn zh Expected output: Case…
1
vote
3 answers

Rank in given order

I have been given an n length string and I need to find its rank in the alphabetical ordering of all the n length strings. Like for example, let's say I have been given, "ABC" then as n=4 then ordering will be as {ABCD, ABCE, ABCF ....} thus the…
user20284443
1
vote
0 answers

Faster algorithm for lexicographic comparison of DNA strings

I'm trying to find a faster way to do the following: Given a list of DNA strings x = ([s1, s2, s3, s4...]) (where the strings can only consist of the letters 'A', 'T', 'C', and 'G') and a list of index pairs y = ([[i, j], [i, j], [i, j]....]) find a…
1
vote
2 answers

Is there an efficient algorithm for outputting all strings stored in a sorted lexicographically list that are a permutation of an input string?

I would like to find the most efficient algorithm for this problem: Given a string str and a list of strings lst that consists of only lowercase English characters and is sorted lexicographically, find all the words in lst that are a permutation of…
1
vote
1 answer

How does Excel compare strings?

Expecting Excel to operate lexicographically, but it seems not to. "1"<"-1" evaluates TRUE despite "-" preceding "1" lexicographically. This also eliminates the possibility that Excel compares both strings as numbers. Alternatively, "1"<"-"…
1
vote
1 answer

z3py: Symmetry breaking constraint by lexicographic order

I have two arrays of integer variables (they represent 2D spatial coordinates) and one is a symmetric disposition of the other. To break simmetry I want to check that the found solution described by the first array (let's call it P) is in…
paolodidio
  • 15
  • 7
1
vote
0 answers

How does lexicographic comparison work internally in JavaScript?

I was recently learning about the sort() array method in JavaScript. When called without an argument, it sorts the given elements lexicographically. I know what does lexicographical comparison mean. But I am confused in one thing... I was wondering…
coderboy
  • 1,710
  • 1
  • 6
  • 16
1
vote
1 answer

What does lexicographically mean?

I saw a program in codeforces where it says, "Now Petya wants to compare those two strings lexicographically." I didn't understand it. What does lexicographically mean?
user15801453
1
vote
2 answers

Alternate way to find all lexicographic orderings of a string in Python

Problem: Find all the different ways to arrange a string E.G. 123 can be arranged--123, 132, 213, 231, 321, 312 So I honestly have no idea how to go about engineering the solution to this problem, as I have not done any official Data Structures and…
1
vote
1 answer

python: custom sort: not purely lexicographical but reverse and shortest common first

Background I want to sort reverse but not strict lexicographical and then it gets even more weird.. :P The reason is that a proprietary software parses directories exactly the way I describe here and I want to copy that behavior. Requirements (in…
1
vote
2 answers

How to apply a transform on two strings to reverse result of lexicographically compare?

For example, two integers a,b, if af(s2) and f(s1)==f(s1)? In python, this can be used to…
Voyager
  • 727
  • 8
  • 26
1
vote
1 answer

Glass beads - How does Suffix array applied here?

The problem statement for this problem can be found at this link - https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=660. When I first read the problem I just could not visualize how suffix…
isilia
  • 379
  • 1
  • 11