Distinct Binary Heaps

I have $ n$ elements out of $ n-1$ are distinct. The repeated element is either minimum or maximum element. I need to figure out how many distinct max heaps can be made from it.

My analysis : I started with $ n$ distinct elements. Since root is fixed( maximum element) we can choose $ l$ (found using deducting total elements from elements in penultimate level) from remaining $ n-1$ elements and recursively choose for Left Sub-tree and Right Sub-tree.

Recurrence Relation :

$ T(n)={n-1 \choose l} * T(l) * T(r)$

Now for $ n-1$ distinct elements(given), for root we have $ 2$ options i.e. maximum elements and we can recurse as above for left and right sub-tree. But since the repeated element is also there I am not able to figure out exact way to do so.

Eg: $ A=[2,6,6] =>$ There are 2 distinct max heaps $ => [6,2,6] , [6,6,2]$

I am unable to think of the way to find out the number of max heaps in this case. Can someone think of algorithm/recurrence relation to find so ?

SQL server Suma mas Distinct

Necesito sumar el campo (CantidadIngresa) para cada producto diferente, la suma se realiza correctamente, por ejemplo en el producto “GAZ” si sumo (4+5+2) = 11, esto es correcto, sin embargo necesito que me muestre cada producto una sola vez, pero a pesar de que uso la instrucción Distinct para que me muestre solo una linea por cada producto, me sigue mostrando los productos tantas veces como se repita. En el caso del ejemplo del GAZ, debería mostrarse solo 1 vez. Que es lo que estoy haciendo mal?

Instrucción SQL:

select Distinct (NombreProd), CantidadAnterior, sum(CantidadIngresa) over(partition by NombreProd) as resultado from TBHistoricoProductos

Agradeceria cualquier sugerencia!

introducir la descripción de la imagen aquí

PowerApps How to get Distinct values of a SharePoint list which is a datasource of dropdown

I am building an app in SharePoint online using PowerApp, I have a dropdown which its data source is from a SharePoint list, it has duplicate data, so I need to get distinct values for the dropdown.

I check PowerApps documentation it has a formula like bellow

Distinct(Employees, Department) 

It works if your data connection is from Excel, but if your data connection is from a SharePoint list, I could not figure it out, any help is appreciated

Number of distinct BFS, DFS trees in a complete graph

What is the number of distinct BFS, DFS in a complete graph?


My approach is like this–>

For DFS take a node, we have (n-1) possible tree edges, next we have all possible (n-2) tree edges,…….finally 1 possible tree edge. and we can choos any of n nodes as rooot node. hence no of distinct DFS trees= n*(n-1)(n-2)….1= n!

For BFS tree if we take a node as root, we have to explore all its neighbors , so the number distinct of BFS trees =no of nodes we can choose as root ie. n .

Is this approach correct?

Magneto 1.x multiple and distinct messages on same page

Is it possible in Magento 1.x to have two distinct messages on a page. For my use case I want a main full width message at the top of the page and a smaller message in div lower down on the page.

At the moment when I set, for example, an error message I see the message rendered twice, but ideally I want to target one of the messages only.

This will happen on my checkout page, so at the moment I am using:

Mage::getSingleton('checkout/session')->addError('Please enter all required information'); 

I was thinking that perhaps I could make use of the customer session:

Mage::getSingleton('customer/session')->addError('Please enter all required information'); 

Would this enable me to have two distinct messages? I know the use case isn’t ideal but I am adding this to an existing project so the user journey cannot be fixed form the bottom up!

Count for specific column how much it has distinct values in different column

I have columns app_id,http_host composed of the below rows: a-aa, a-bb, a-cc, b-hh. I want to calculate how much distinct values i have in column app_id for each distinct http_host. I want to get a-3, b-1

select app_id, http_host, ROW_NUMBER() over (PARTITION by app_id order by app_id desc) as rowNum  FROM "public"."bus_request"  group by app_id, http_host 

I was thinking it will partition by app_id, it will have 1 for a and 2 for b but this is incorrect.

Efficent deterministic algorithm to sort n numbers with many duplicates ( distinct integers $O(\log n)$)

I seek to sort a sequence S of n integers with many duplications, such that the number of distinct integers in S is $ O(\log n)$ . Give an $ O(n \log \log n)$ worst-case time algorithm to sort such sequences. I tried quick-sort, Merge-sort, selection-sort but not getting the required running time. So the question is to design a deterministic algorithm for the problem described.

It is from the book Algorithm Design Manual by Steven Skiena (2nd Ed) problem no 4-23, page no- 154 with some modification.

What is the deterministic time complexity of obtaining the set of distinct elements?

Consider a sequence $ s$ of $ n$ integers (let’s ignore the specifics of their representation and just suppose we can read, write and compare them in O(1) time with arbitrary positions). What’s known about the worst-case time complexity of producing a sequence of all distinct elements in $ s$ , in any order?

By randomized hashing, one can do this in expected $ O(n)$ . On the upper bound side, one may sort the elements, then produce the output in a single pass by only copying elements which differ from their predecessors to the output – for a total time of $ O(n \log(n))$ .

But can one do better than $ O(n \log(n) )$ deterministically?

Note: This is sort-of a “remove duplicates” problem, but since the order is not preserved I’m not sure it should be called that.

Why is this code not working with distinct

Why is this code not working it always give me multiple filds at the lf_work_task_info :/

— CREATE OR REPLACE FORCE EDITIONABLE VIEW “KXGUI”.”V_LF_DISPATCH_VAS_TEXT” (“LOADING_UNIT_ID”, “LOADING_UNIT_CODE”, “LF_WORK_TASK_INFO”) AS SELECT DISTINCT org.order_id, STRAGG( disp_vas_txt.lf_work_task_info || ‘ || ‘ ) as lf_work_task_info
FROM ( SELECT DISTINCT owt.lf_work_task_info, owt.order_id, owt.loading_unit_id, ogia_sub.group_order_id AS out_del_ord_id FROM klassx.loading_unit lou JOIN klassx.orders ord_classic ON ( ord_classic.loading_unit_id = lou.loading_unit_id AND ord_classic.order_type_id = wmw_type.ort_classic ) JOIN klassx.order_work_task owt ON ( owt.order_id = ord_classic.order_id OR owt.loading_unit_id = lou.loading_unit_id ) JOIN klassx.v_order_group_item_all ogia_cla ON ( ogia_cla.order_id = ord_classic.order_id AND ogia_cla.group_type_id = wmw_type.ogt_master_orders ) JOIN klassx.v_order_group_item_all ogia_sub ON ( ogia_cla.group_order_id = ogia_sub.order_id AND ogia_sub.group_type_id = wmw_type.ogt_delivery_order ) JOIN klassx.orders ord_classic ON ( owt.order_id = ord_classic.order_id ) WHERE owt.work_task_type_id = wmw_type.wtt_vas AND owt.work_task_status_id = wmw_type.wts_open AND owt.work_task_reason_id = wmw_type.wtr_vas_dispatch AND lou.deleted = util_bool.no ) disp_vas_txt JOIN klassx.order_group org ON ( org.order_id = disp_vas_txt.out_del_ord_id ) —outbound_del GROUP BY org.order_id, disp_vas_txt.lf_work_task_info ;