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

Finding duplicate elements in an arraylist

I was wondering if there was a way to find duplicate elements in an arraylist. For more context of what I'm trying to do, I have an arraylist of strings. The strings each contain information about an MP3 file. They have a title, composer, and…
Jigglypuff
  • 1,433
  • 6
  • 24
  • 38
0
votes
0 answers

String ordering in Python

I noticed that in Python we have: '0' < 'A' < 'a' '0' < '00' As far as I understand, there are multiple possible lexicographical orderings of characters and strings, so I assume this is one type specifically. Does this lexicographic ordering have…
Josh
  • 11,979
  • 17
  • 60
  • 96
0
votes
1 answer

print the lexicographically smallest and largest substring of a given size k from a string s

Its a program to print the Lexicographically smallest and largest substring of size k. There´s a part in this solution I don´t really understand. Maybe someone can explain it to me. public static String getSmallestAndLargest(String s, int k) { …
0
votes
1 answer

Lexicographical sorting for non-ascii characters

I have done lexicographical sorting for ascii characters by the following code: std::ifstream infile; std::string line, new_line; std::vector v; while(std::getline(infile, line)) { // If line is empty, ignore…
Hector Ta
  • 81
  • 2
  • 14
0
votes
1 answer

Objective function per week - help writing the code - CPLEX

( The OPL model and the Lindo model are in the code box ) I need some help with this problem. My goal is to organize which trucks will be shipped from origin to destination each week (week 1, 2, 3 and 4). In this example, there are a total of 6…
0
votes
1 answer

How do I sort an ArrayList of strings in alpabetical order using a compareTo method?

I'm an amateur programmer and I've created a program that contains an arraylist that holds different phone book contacts and I'm trying to sort the arraylist lexicographically using a compareTo method. I don't know how to properly call the method in…
0
votes
1 answer

How to loop over all possible vectors of certain length in lexicographic order?

Let's say we have a vector of length 4, where every element can be a number from 0 to 9. For example: <1, 8, 0, 3> Instead of simply looping over all 10^4 possible vectors, I want to loop in an specific order. So I want to start from <0, 0, 0, 0>,…
Vicarious
  • 131
  • 18
0
votes
0 answers

chromosomes are sorted lexicographically when using sort in bedtools

In python when you use the bedtools sorting function, chromosomes are sorted lexicographically, so chr12 will come before chr9. There are some ways to solve it when you are using bash such as - k1,1 - k2,2n which many sites described but none of…
Shrm
  • 426
  • 4
  • 8
0
votes
2 answers

How does Duval's algorithm handle odd-length strings?

Finding the Lexicographically minimal string rotation is a well known problem, for which a linear time algorithm was proposed by Jean Pierre Duval in 1983. This blog post is probably the only publicly available resource that talks about the…
Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219
0
votes
1 answer

Finding lexicographically numbers with a defined amount

I am struggling to achieve a solution for the following problem. Imagine that I have 6 candies, and i have to give these candies amount 6 children where none of them can have more than 2 candies. Example: 000222 121020 What i need to achieve is find…
Garoto Guibas
  • 33
  • 1
  • 4
0
votes
0 answers

lexicographic sort of a big file of words with limited memory

I have a 1GB file with random words with length 1 to 256 and I have just 2GB RAM for sorting that(if ram usage goes above 2GB the process will be killed). What's the most efficient way to sort the words in the file in lexicographical order with C++…
0
votes
3 answers

Lexicographical order - two char array as parameters, looking for a better solution

I have to write a function that takes 2 char[]s and returns: -1 if the the first word comes before the second in a lexicographical order 0 if they are the same word 1 if it comes after I'm aware of compareTo() method but this is an assignment, I…
Blebhebhe
  • 83
  • 1
  • 9
0
votes
2 answers

Lexicographically smallest palindrome in python

I found this question to be interesting and I would like to share this here and find reasonably good codes, specific to py : Given a string S having characters from English alphabets ['a' - 'z'] and '.' as the special character (without quotes).…
0
votes
4 answers

Printing list of list (containing integers) in lexicographic order

Task:You are given three integers x,y and z along with an integer n. You have to print a list of all possible coordinates where the sum of is not equal to n. Print Print the list in lexicographic increasing order. Below is my code. Works fine…
Sel_Python
  • 191
  • 2
  • 7
  • 16
0
votes
1 answer

Sorting a String in lexicographical order

The question provides an input String and an integer, it asks us to convert the string into all the possible combinations of sub-strings of length as specified by the input integer provided. Then we have to find the maximum and minimum from those…