Parallel Merge Sort – No memory allocation

I am implementing a parallel merge sort in C++ that is based off P-Merge-Sort algorithm from Introduction to Algorithms, CLRS on page 803. Here’s the algorithm: P-Merge-Sort

And the associated algorithms:



And my problem is that I am trying avoid creating a $ T[1 \, ..\, n]$ for each invocation of P-Merge-Sort. I am told that it should be done via global arrays. So I have tried utilizing a single array for working which is the same size as the array being sorted where it would be used as ‘B’ in P-Merge-Sort.

How can I make this work without dynamically allocating memory during Merge Sorting?

How to sort file from one position to another in Nano Text editor

am very new to ubuntu, i was using windows now am using ubuntu server. i have web application i need to set up and some of the instruction instruct me to open DIRECT.CONFIG file in nano text editor, i was able to open the file and when i open the file it opens with this file ordering

directoryindex index.html index.cgi index.php index.xhtml index.htm

now i want to move the index.php file above to the first position after the Directoryindex, so just after DIRECTORYINDEX it must be followed by index.php like this:

directoryindex index.php index.html index.cgi index.xhtml index.htm

what should i do if its shortcuts or whatever because in below of NANO editor i just see the shortcuts for replace, justify, cut etc. any help will be appreciated.

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

Desarrolla el programa 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) 

Sort by for woocommerce

I added custom shop page, and on this page i need add Sort by dropdown filter, when i try add:

<form class="woocommerce-ordering" method="get">     <select name="orderby" class="orderby" aria-label="<?php esc_attr_e( 'Shop order', 'woocommerce' ); ?>">         <?php foreach ( $  catalog_orderby_options as $  id => $  name ) : ?>             <option value="<?php echo esc_attr( $  id ); ?>" <?php selected( $  orderby, $  id ); ?>><?php echo esc_html( $  name ); ?></option>         <?php endforeach; ?>     </select>     <input type="hidden" name="paged" value="1" />     <?php wc_query_string_form_fields( null, array( 'orderby', 'submit', 'paged', 'product-page' ) ); ?> </form> 

this not working in custom shop page! how i can display this?

DP for Weighted Interval Scheduling: Can we sort start time in ascending order instead of the finish time?

Problem In the weighted interval scheduling problem, we want to find the maximum-weight subset of nonoverlapping jobs, given a set $ J$ of jobs that have weights associated with them. Job $ i \in J$ has a start time $ s_i$ , a finish time $ f_i$ , and a weight $ w_i > 0$ . We seek to find an optimal schedule — a subset $ \cal{O}$ of non-overlapping jobs in $ J$ with the maximum possible sum of weights.

Dynamic Programming Solution In almost all textbooks or materials I could get access to, a DP algorithm is given as follows: First all jobs are sorted in order of ascending finish time: $ f_1\le f_2 \le \dots \le f_n$ . Let $ OPT(i)$ be the maximum total weight of non-overlapping jobs in $ \{1,2, \cdots ,i\}$ , $ p_i$ be the largest index $ j < i$ such that job $ j$ and $ i$ are compatible. Then we see that $ $ OPT(i) = \max\{{w_i + OPT(p_i), OPT(i-1)}\}$ $

My question I think I could understand why this DP algorithm works. However I didn’t see the necessasity for the sorting step. What if we sort the finish time in ascending order instead? As far as I can see, it’s also correct.

Plz help me find the time complexity of this sort

I wrote a program of a sort that is based on mergesort but can also be done with linked list with ease. I am a beginner in evaluating time complexity so I am not being able to find the complexity here. One of my friends suggested that it is a divide and conquer algorithm but I don’t know yet. Here is the algorithm

  1. There will be a loop of n-1 iterations here. On each iteration an element will be compared with its succeeding element.
  2. If the element is lesser than its succeeding element, then the loop will add the element in an array or linked list. (let it be called arr1)
  3. But if the element is greater than the next elemwnt, then the arr1 will be pushed to a stack. the elements will be stored in another array, arr2 from the next iterations
  4. When the loop reaches the end of the array or it encounters another step 3 then the arr2 will also be pushed in the stack 4 Whenever the stack will have 2 elements, it will be merged by the merge() function of mergesort and the resulting array will be stored in the stack as arr1, then storing will again be done on arr2. Eg: Suppose the array or linked list has: 9, 10, 1, 8, 2, 0
    1. Then 9 and 10 will be stored in arr1 at first.
    2. 1 and 8 will be stored in arr2.
    3. The stack has 2 elements now. So a merge operation will be done. The updated arr1 is: 1, 8, 9, 10.
    4. Arr2 will store only 2 as 0 is less. So the stack will again have 2 elements.
    5. The same thing will happen. The updated arr1 is 1, 2, 8, 9, 10.
    6. Arr2 will then store 0 and merge function will begin again. So the array is: 0, 1, 2, 8, 9, 10. Tell the time complexity plz. I can’t find it.

Use up or down arrow to represent “sort ascending” at table header

To represent “sort ascending” (a -> b -> c -> …) , my first sense told me that, I should use ↓ to represent it. This is because if I lay my data

a b c 

It seems like thing is moving naturally toward downwards.

However, for the table header under Windows, the thing I saw is, they are mostly using up arrow.

enter image description here

Hence, I was wondering, which symbol is more suitable? up arrow or down arrow?

From, I can see they mostly use up arrow.

But, from end user point of view, if I saw a up arrow at table header, I would thought the largest value (says z) nearest to the top table, and smallest value (says a) at the bottom of table.