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
4
votes
2 answers

How does one organize the coefficients of PolynomialFeatures in Lexicographical order so that they match sympy for a multivariate polynomial?

I had a set of parameters that I manually (I want it manual) fitted with the pseudo-inverse using PolynomialFeatures: poly_feat = PolynomialFeatures(degree=Degree_mdl) Kern_train = poly_feat.fit_transform(X_train) c_pinv = np.dot(np.linalg.pinv(…
Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
4
votes
6 answers

How to sort set of numbers both lexicographically and numerically?

I currently have a set of strings that are both just numbers and number with + or -. Such as follows : 1 , 1+, 1-, 2, 2+, 2-, 10 Which when I sort using JavaScript's sort functions gives out: 1, 1+ , 1-, 10, 2, 2+, 2- which is lexicographically…
oneCoderToRuleThemAll
  • 834
  • 2
  • 12
  • 33
4
votes
3 answers

awk / gawk asorti() problem

I've got following problem with gawk's asorti function: gawk 'BEGIN{ \ a[1]=6; \ a[2]=7; \ a[3]=8; \ a[21]=9; \ a[123]=10; \ t=asorti(a, o); \ for (i=1; i<=t; i++) { \ print i,o[i]; \ } \ }' The result is: 1 1 2…
GiM
  • 460
  • 4
  • 13
4
votes
2 answers

Does Java String.getBytes("UTF-8") preserve lexicograhpical order?

If I have a lexicographical sorted list of Java Strings [s1,s2,s3,s4, ...., sn], and then convert each String into a byte array using UTF-8 encoding bx = sx.getBytes("UTF-8"), is the list of byte arrays [b1,b2,b3,...bn] also lexicographical sorted?
Carsten
  • 4,204
  • 4
  • 32
  • 49
4
votes
1 answer

C++: Comparing strings lexicographical

Are strings compared lexicographical when using the overriden bool operator<(const std::string & rhs) operator? In example: std::string str1 = "aabbcc" std::string str2 = "bbaacc" (str1 < str2) ==…
Sebastian Hoffmann
  • 11,127
  • 7
  • 49
  • 77
3
votes
3 answers

NumPy - np.searchsorted for 2-D arrays

np.searchsorted only for 1D arrays. I have a lexicographically sorted 2D array, meaning that 0-th row is sorted, then for same values of 0-th row corresponding elements of 1-th row are sorted too, for same values of 1-th row values of 2-th row are…
Arty
  • 14,883
  • 6
  • 36
  • 69
3
votes
1 answer

Weight for weight from CodeWars

The question is: "My friend John and I are members of the "Fat to Fit Club (FFC)". John is worried because each month a list with the weights of members is published and each month he is the last on the list which means he is the heaviest. I am the…
Nadav Julius
  • 301
  • 2
  • 16
3
votes
1 answer

Find the lexicographically smallest sequence achievable

Here's the problem statement Given a sequence of n integers arr, determine the lexicographically smallest sequence which may be obtained from it after performing at most k element swaps, each involving a pair of consecutive elements in the…
user6123723
  • 10,546
  • 18
  • 67
  • 109
3
votes
1 answer

Why HBase rows are said to be stored as lexicographically sorted?

Based on the HBase documentation, again following the reference from the Google BigTable paper, the rows are said to be stored with lexicographic sorting of the row key. It is evident that the rows are sorted lexicographically when we have a string…
Betta
  • 416
  • 5
  • 17
3
votes
5 answers

Sorting list of strings in lexicographic order

I want to print the words in lexicographic order. I thought sorted() arranges the words in this way. I have also tried .sort() which returns the same order. Or am I missing something with what lexicographic order really is? Code: a_list =…
Wizard
  • 1,533
  • 4
  • 19
  • 32
3
votes
2 answers

How to sort a struct of a pair of integers using quicksort?

Suppose I have the following struct: struct Pair { int x; int y; } I want to sort the array by the first element in the pair, i.e. x and then by the second element so if we are given the following: input: [(1,2), (1,0), (2,3), (1,4),…
user6005857
  • 631
  • 9
  • 25
3
votes
1 answer

Recursive language

"if a language is recursive, then there exists a method by which the strings in language can be written in some sequence" I am also told that "if a language can be enumerated in a lexicographic order by some Turing machine, then such a language is…
3
votes
1 answer

Lexicographic sort float array python

Okay, so, I have a 4x2 numpy ndarray, and I want to sort it lexicographically. That is, if I have the array [[0,0], [1,1], [0,1], [1,0]] I want it to become [[0,0], [0,1], [1,0], [1,1]] How do I do this?
Pedro Carvalho
  • 565
  • 1
  • 6
  • 26
3
votes
1 answer

Generating permutations using Bitmasking

I was answering some programming problems in the internet and this problem interests me. The problem is defined as follows: This code prints all the permutations of the string lexicographically. Something is wrong with it. Find and fix it by…
kalev25
  • 43
  • 1
  • 5
3
votes
2 answers

How to open new tab with "ctrl+click" instead of redirect current tab, in jQuery?

Table contain digital values, each cell has each own href. If I'm apply hrefs like this: nTd.click(function(e){ $(this).css("font-weight","bold"); e.stopPropagation(); location.href = 'http://google.com'; }); Each click on cell redirect…
1 2
3
15 16