How to get sorted Gnome usability issues in Desktop?

I’ve instaled Ubuntu 19.04 from scratch after an issue with my old ubuntu installation.

I’ve found that now it uses Gnome instead of Unity. I like gnome, but I have a couple od important usability issues that I assume are easily configurable, and I just don’t know how to.

1. The full name of each file used to appear in Desktop icons, and if it were too long, when I clicked on the icon the full name would appear, even in long names.

Not now, as you can see:

1. Besides that, as you can see in the image attached, if I click on an image, the preview won’t appear either.

2. When doing anything in dektop before, like deleting a icon or moving it, I could easily press CTRL + Z and it would undo the action. How may I do that now?

Please note that I’ve installed Gnome Tweaks.

Problema con listas en Python sin el uso de sort o sorted

Desarrolla el programa mezcla_ordena_listas.py que permitirá obtener de una lista ordenada de números enteros de menor a mayor a partir de dos listas de números enteros. Los valores individuales de las listas de entrada los captura el usuario uno por uno y posteriormente se unirán ambas listas para luego ordenarlas en forma ascendente (de menor a mayor valor). Tu programa deberá permitir la captura de los valores enteros de las listas sin hacer uso de mensajes (leyendas) al usuario y mostrará el resultado en la forma en que se indica más adelante.

Para ordenar:

No puedes usar la función sort o sorted ni ninguna función que ya ordene. Tendrás que escribirla tú. Si usas alguna función de estas no tendrás puntos extras.

Te recomiendo hacer una función llamada ordena(lista) que recibe una lista y regresa una lista ordenada.

El algoritmo para ordenar sería mas o menos así:

``Por cada elemento en la lista, se hará una pasada a la lista  En cada pasada, se irá checando el elemento i con el i+1 y si el elemento en i es mayor al elemento que esta en i+1, intercambiarlos, seguir revisando hasta uno antes del final (para que en i+1 no te salga un index out of range. De esta forma,  el número mayor se irá 'empujando' hasta el final y no es necesario volver a revisar ese elemento (tu rango puede ir disminuyendo cada pasada).  Si no hubo intercambios, quiere decir que ya todo esta en orden y no es necesario hacer mas pasadas (puedes usar una variable booleana para saber si hiciste un intercambio o no) ``

Creating a priority search tree to find the number of points in the range [-inf, qx] X [qy, qy’] from a set of points sorted on y-coordinates

A priority search tree can be constructed on a set of points P in O(n log(n)) time but if the points are sorted on the y co-ordinates then it takes O(n) time. I find algorithms for constructing the tree when the points are not sorted.

I figured out a way to do this as follows:

1. Construct a BST on the points. Since the points are sorted then it will take O(n) time

2. Min-Heapify the BST on the x-coordinates This will take theta(n) time

So total time complexity will be O(n)

Is this a valid approach to construct a Priority Search Tree in O(n) time??

How to push items to the top or bottom of the list in alphabetically sorted lists?

This question is not related to any specific scenario, platform or product, and it’s more of an end-user UX rather than a design of UX. It applies to various use cases and platforms. One specific example which prompted me to ask this question is the notebooks list in Evernote – I’d like to push my notebook called “Archives” to the bottom of the list – it’s right at the top otherwise. Another cases are naming the files and folders on a computer.

There are certain lists which are sorted alphabetically and there’s no way to re-arrange them. In general, this is quite practical as it makes it easier to find the items when there are plenty of them and there’s no need to arrange them manually.

However, sometimes you want to push certain items on the list to the top or to the bottom. And the only way to do that is to prefix the item with a certain symbol.

So:

• For pulling items to the top, the most common I’ve used is `!`, so your `Requirements` item becomes `! Requirements`. Other nice options are `~` or `-`.
• For pushing to the bottom however, one obvious symbol is “z”, so if the item is named `Archives`, you name it `zzz-Archives` or `zzz Archives`.

While the exclamation mark and other non-alpha symbols seem OK, I find `zzz` knocks off the visual “tidiness” of a list.

I am wondering if anyone used or seen more elegant solutions to pushing and pulling?

Time complexity of finding predecessor for a dictionary implemented as a sorted array

I’m currently reading “The Algorithm Design Manual” by Steven Skiena. On page 73, he discusses the time complexity of implementing $$Predecessor(D, k)$$ and $$Successor(D, k)$$ and suggests that it takes O(1) time.

If the data structure looks something like

``[(k0, x), (k1, x), ...] ``

where the keys `k0` to `kn` are sorted, given `k`, I thought the `successor(D, k)` would first have to search the sorted array for `k` ( $$O(log n)$$ ) and then get the successor ( $$O(1)$$ ) since the array is sorted, and hence the overall time complexity should be $$O(log n)$$ instead of $$O(1)$$ as mentioned in the book. This should also apply for `predecessor(D, k)`.

For an unsorted array, the time complexity for predecessor and successor remain as $$O(n)$$ since searching the unsorted array also takes $$O(n)$$.

Did I misunderstand something?

Complexity of Inserting an element in a sorted matrix [duplicate]

• Find an element in sorted 2D-array (matrix) 1 answer

If in a matrix (m*n) having sorted rows and sorted columns then time complexity to insert new element?

Any array takes at least log(n!) compairs to be sorted

I have to prove that there is no comparison based algorithem that can sort a randomly given array in less than log(n!) steps. Lets say the array has 5 elements, it is impossible to sort it (using comparison based algorithem) in just 6 steps. Can you guys help me out with this?

Returning sorted lowest k elements in a binary heap

Given a binary heap of size $$n$$ and a number $$k\le n$$. How can I return an array with size $$k$$, which contains the $$k$$ lowest elements in the binary heap, so that it will be sorted in the end?

The problem is that the time-complexity needs to be $$\Theta(k \log(k))$$.

Leetcode 4: Median of Two Sorted Arrays

There are two sorted arrays nums1 and nums2 of size m and n respectively.

Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).

You may assume nums1 and nums2 cannot be both empty.

``nums1 = [1, 2] nums2 = [3, 4]  The median is (2 + 3)/2 = 2.5 ``

Solution

``class Solution:     def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:         total_len = len(nums1) + len(nums2)         multiple = total_len % 2 == 0                            # Is the median made up of two numbers?         median_index = (total_len // 2) - (1 if multiple else 0) # The first median number           i1 = 0         i2 = 0          len1 = len(nums1)         len2 = len(nums2)          median_sum = 0          for i in range(total_len):             if i1 >= len1:                 cur = nums2[i2]                 i2 += 1             elif i2 >= len2:                 cur = nums1[i1]                 i1 += 1             else:                 n1 = nums1[i1]                 n2 = nums2[i2]                  if n1 <= n2:                     cur = nums1[i1]                     i1 += 1                 elif n2 < n1:                     cur = nums2[i2]                     i2 += 1              if i == median_index:                 if multiple:                     median_sum += cur                 else:                     return float(cur)             if i == median_index + 1:                 return (median_sum + cur) / 2 ``

The code runs as expected, but can I improve its performance or make it more readable?

Union and Intersection and Diff of two sorted arrays c#

this is the original question https://www.geeksforgeeks.org/union-and-intersection-of-two-sorted-arrays-2/

Given two sorted arrays, find their union and intersection.

``Example:  Input : arr1[] = {1, 3, 4, 5, 7}         arr2[] = {2, 3, 5, 6}   Output : Union : {1, 2, 3, 4, 5, 6, 7}           Intersection : {3, 5}  Input : arr1[] = {2, 5, 6}         arr2[] = {4, 6, 8, 10}   Output : Union : {2, 4, 5, 6, 8, 10}           Intersection : {6} ``

I also added one more case of finding items which are only if one of the two array and called it Diff.

``using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting;  namespace ArrayQuestions {     /// <summary>     /// https://www.geeksforgeeks.org/union-and-intersection-of-two-sorted-arrays-2/     /// </summary>      [TestClass]     public class UnionAndIntersectionOfTwoSortedArrays2     {         [TestMethod]         public void UnionTest()         {             int[] arr1 = { 1, 3, 4, 5, 7 };             int[] arr2 = { 2, 3, 5, 6 };             int[] union = { 1, 2, 3, 4, 5, 6, 7 };             CollectionAssert.AreEqual(union, Union(arr1, arr2));         }          [TestMethod]         public void IntersectionTest()         {             int[] arr1 = { 1, 3, 4, 5, 7 };             int[] arr2 = { 2, 3, 5, 6 };              int[] intersection = { 3, 5 };             CollectionAssert.AreEqual(intersection, Intersection(arr1, arr2));         }          [TestMethod]         public void DiffTest()         {             int[] arr1 = { 1, 3, 4, 5, 7 };             int[] arr2 = { 2, 3, 5, 6 };              int[] diff = { 1, 2, 4, 6, 7 };             CollectionAssert.AreEqual(diff, Diff(arr1, arr2));         }          private int[] Diff(int[] arr1, int[] arr2)         {             int i = 0;             int j = 0;             int n = arr1.Length;             int m = arr2.Length;             List<int> list = new List<int>();             while (i < n && j < m)             {                 if (arr1[i] == arr2[j])                 {                     i++;                     j++;                 }                  else if (arr1[i] < arr2[j])                 {                     list.Add(arr1[i]);                     i++;                 }                 else                 {                     list.Add(arr2[j]);                     j++;                  }             }              while (i < n)             {                 list.Add(arr1[i]);                 i++;             }             while (j < m)             {                 list.Add(arr2[j]);                 j++;             }             return list.ToArray();         }           private int[] Intersection(int[] arr1, int[] arr2)         {             int i = 0;             int j = 0;             int n = arr1.Length;             int m = arr2.Length;             List<int> list = new List<int>();             while (i < n && j < m)             {                 if (arr1[i] == arr2[j])                 {                     list.Add(arr1[i]);                     i++;                     j++;                 }                 else if (arr1[i] < arr2[j])                 {                     i++;                 }                 else                 {                     j++;                 }             }              return list.ToArray();         }          public int[] Union(int[] arr1, int[] arr2)         {             int i = 0;             int j = 0;             int n = arr1.Length;             int m = arr2.Length;             List<int> list = new List<int>();             while (i < n && j < m)             {                 if (arr1[i] < arr2[j])                 {                     list.Add(arr1[i]);                     i++;                 }                 else if (arr2[j] < arr1[i])                 {                     list.Add(arr2[j]);                     j++;                 }                 else // equals                 {                     list.Add(arr1[i]);                     i++;                     j++;                  }             }             //handle the rest             for (; i < n; i++)             {                 list.Add(arr1[i]);             }             for (; j < m; j++)             {                 list.Add(arr2[j]);             }              return list.ToArray();         }     } } ``