Concatenate multiple integer arrays such that number of inversions in resulting array is minimal

Given N arrays of variable length.

Find a way to concatenate the arrays in such a way that the number of inversions is minimum

An inversion for an array Arr can be defined as,

a pair of indices (i,j) such that,

i != j  i < j  Arr[i]>Arr[j] 

I tried to concatenate the arrays on the basis of sum, such that the one with minimal sum goes first and one with maximal sum goes last.

It didn’t work out though.


[14, 18, 18, 20, 16, 6, 11] SUM:- 103  [2, 4, 11, 40, 20, 14, 19] SUM:- 110  [14, 18, 18, 20, 16, 6, 11, 2, 4, 11, 40, 20, 14, 19] Inversions:- 42  [2, 4, 11, 40, 20, 14, 19, 14, 18, 18, 20, 16, 6, 11] Inversions:- 40 

Determine the number of self-crossings for an irregular orientation of an n-pointed star, whose vertices lie on the boundary of a circle

I need to create an algorithm that will output the number of self-crossings for an irregular orientation of an n-pointed star, whose vertices lie on the boundary of a circle. The sample input is as follows:

5 24.0 168.0 312.0 96.0 240.0 

Where the first integer is n (the number of vertices), proceeded with n lines, each describing the positions of the vertices, taken in order, which form the star. Each vertex is in a unique position on the boundary of the unit circle, specified in degrees from the normal axis. All degree measures will be in the range [0,360).

The sample output for the sample input would be:

5 crossings 

To tackle this problem, I was thinking of maybe separating the unit circle into quadrants and determine whether there are crossings depending on the positions of the vertices in their respective quadrants. However, I haven’t been able to think of a way to implement this.

I was wondering if anyone could provide perhaps a high-level idea or a push in the right direction which could help me think of an algorithm.

Thank you.

Why are cryptographically secure random number generators required for shared keys?

As I understand, key exchange for secure communications like TLS has a client take a server’s public key, generate a random AES key and send that as a shared key for further communication. The key is generated using a cryptographically secure random number generator where the seed is obtained via system entropy.

I assume a random generator is used to create the key rather than purely from system entropy because it’s faster/easier, but why does the generator have to be cryptographically secure? The benefits of being so are that given any state of the generator, it’s infeasible to predict the next bit, or any of the previously generated ones. However, if an attacker can see the output of the number generator, don’t they already have the AES key anyway? In what scenario would they only ever have part of the key, which they could then exploit the number generator to recover the rest?

I assume I’m misunderstanding it’s purpose.

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??

Image Processing (Encryption/Decryption) system using Residue Number System

I’m preparing for my final year project in school and i plan on working on the implementation of Residue Number System in Image Processing. I found this thesis online by Pallab Maji here:

and i checked on Pages 29 – 41, he explained the algorithm in which i’m not to familiar with some of the concepts:

  • I: Input image and block size m and n.
  • II: Break image into m x n blocks and Zigzag Scan the intermediate blocks.
  • III: Z = m x n x 8 bits. Generate a moduli set P, where P = {p1, p2 … pk} corresponding to Z bits.
  • IV: Convert the intermediate zigzag scanned block into one word and scale to avoid overflow.
  • V: Use the set P to convert the word into RNS.
  • VI: Regroup the RNS number to form a word and further break them into m x n blocks.
  • VII: Map the encrypted block to image.

I would be very grateful if anyone could help put me through.

Warning or error when incorrect number of checkboxes are selected

Good morning. I have a SharePoint list with a custom InfoPath form. One of the fields within that InfoPath form is a Choice field with checkboxes (multi-select). This field is not required, selecting none of the checkboxes is allowed. Selecting multiple checkboxes is also allowed, but selecting just one of the checkboxes is not allowed. How can we display an error or warning to the user completing the form that they must select more than one checkbox (or none at all)? If only one is selected a message should display that the field requires multiple items.

50 CRORE DATABASE With Name, Number, Email, Location and many more for $5

This is a brand new database Screenshots of 20 crore data This is a full set of more than 6 GB of data. Consists of all the data in 7 zip files for you to download. Can’t be sold loose There is no demo, as it is not feasible to share numbers to all the interested people. However, I can guarantee authenticity. After you make the payment, in 2 minutes you will receive an email from CLOUDG5 with the link to download the data. I will give you 3 months to download this data. You will also receive a free gift, many useful software for marketing and increasing your business.

by: jayantodey
Created: —
Category: Other
Viewed: 271

Repeat elements in list, but the number of times each element is repeated is provided by a separate list

I’m trying to repeat each element of a list x number of times, where x is the corresponding element of the same position in another list.

For example, I have list A = {1,2,3,4} and another list B = {3,1,4,2} and I’m trying to get C = {1,1,1,2,3,3,3,3,4,4}.

How do I get C from A and B?


Magicjack Customer Service Number +1855 892-0514 Magicjack Customer Service

Magicjack Contact Number -: Since it is a specialized gadget so conceivable outcomes for disappointment couldn't be saved. There are various issues which may limit you to receive the rewards of this machine. Never get stressed on any term if any normal or uncommon circumstance makes you awkward on any term. There are trustworthy restorative advances effectively accessible to determine the issues on quick premise. Next, we are giving insights regarding a portion of the serious issues and…

Magicjack Customer Service Number +1855 892-0514 Magicjack Customer Service