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

Creating lexicographicaly sorted pairs in data.table

How can I efficiently bind two keyed columns into a single column of pairs that will preserve the lexicographic order of the two keys? I am interested in using 'loc' as a single (sorted) variable dt = data.table( loc.x = as.integer(c(1, 1, 3, 1,…
Amitai
  • 871
  • 1
  • 8
  • 21
0
votes
4 answers

Select lexicographical smallest string after duplicates removed

Remove all duplicates from a string and select the lexicographical smallest string possible. For example, the string cbacdcbc would return acdb, not adcb. So this has a relatively simple solution if we don't have to select the string that's…
gdagger
  • 69
  • 1
  • 7
0
votes
1 answer

Am I comparing strings lexicographically correctly?

I am creating a method compareTo(AltString altStr2) that sorts strings by their length (shortest to longest). However, I would like to go the extra mile and check for strings that are of the same length. In that case, I figure it is best to sort…
Omar N
  • 1,720
  • 2
  • 21
  • 33
0
votes
1 answer

how can i read class properties (members) in lexicographic order on java?

im trying to build input dialog using swt. i want to read my class properties and make the dialog window on specified order or even lexicographic order. i'll keep my class properties in linkedhahmap\treemap. example: public class MazeProperties { …
Zlil Korman
  • 195
  • 1
  • 10
0
votes
0 answers

Complexity of lexicographically ordering a Matrix

Given a matrix with m rows and n columns, where each entry consists of a pair (a,b) of integers. No pair appears twice in the matrix. We would now like to order these pairs, such that for two pairs (a,b) and (c,d) which are in the same row, we have…
0
votes
1 answer

Printing a trie lexicographically in c

So I'm implementing a trie to store words in a dictionary file. I've implemented the insert operation; now I'm trying to print lexicograpically. I'm close to getting it, but I have a small problem that I'm not sure how to fix. I'm also trying to…
Sara
  • 121
  • 7
0
votes
0 answers

Lexicographical order of an array of integers

How to find lexicographical order of an array of N integers(i.e. 1,2,3,...,n) in its permutations in O(n) time? Ex:- lexicographical order of {2,3,1,4} is 9 in its permutations
weedfarmer
  • 51
  • 1
  • 1
  • 6
0
votes
1 answer

Java Displaying output of string comparison

The assignment asks for three strings of alphabetical input (that is, letters and no numbers), then compare lexicographically and draw the middle one. I found a similar concern here (Java: Three strings, lexicographic order), but can't comment to…
Wraith11B
  • 1
  • 1
0
votes
1 answer

Find if a String is in Ascending order (Lexicographically)

I have a problem where I need to read an unknown amount of lines from a text file, and determine whether or not the lines are in ascending order. Any help would be much appreciated.
Syrint
  • 29
  • 4
0
votes
1 answer

Turing Machine Design

I recently encountered the following problem: Give a Turing machine diagram for a Turing machine that on input a string x ∈ {0, 1}∗ halts (accepts) with its head on the left end of the tape containing the string x′ ∈ {0, 1}∗ at the left end (and…
Ian
  • 3,605
  • 4
  • 31
  • 66
0
votes
4 answers

lexicographical comparison of two arrays in java

I would like to implement a method that takes 2 arrays and returns the one that is lexicographically smaller than the other. I tried to do it according to the definition of lexicographic order, but it does not work. Here is my code: public boolean…
Rozion
  • 21
  • 1
  • 4
0
votes
2 answers

JAVA: Lexicographically comparing two Strings

I am attending an IT school and we just started studying JAVA and we had to do a project that sort of simulated simple "messages" being passed around a network of Nodes that had IP Addresses. The whole project does not matter for purposes of this…
user1966576
  • 83
  • 1
  • 10
0
votes
2 answers

Efficiently calculate index of specific element in lexicographical ordering

I have four elements: A B C D I can arrange all permutations of n elements in lexicographical ordering, so for n=2: 0=AA 1=AB 2=AC 3=AD ... 15=DD How can I, without resorting to counting, calculate the index in this ordering for a specific…
kunterbunt
  • 614
  • 1
  • 7
  • 19
0
votes
1 answer

Lexicographic rank of a string Java

I am trying to write a program that takes in a 'word' from the user and prints out its lexicographic rank among all of its permutations. I have the functions for getting the rank and the calculating factorials (iteratively for complexity reasons)…
0
votes
2 answers

Is it possible to have a nonlexicographic order

I searched it up but I couldn't find anything since I don't know the actual name to it. Is it possible to have a nonlexicographic order for example the Alphabet comes first before then numbers then symbols? I know in java compareTo statement does it…
Wolf
  • 311
  • 1
  • 3
  • 12