I am wondering if this is the most efficient way to find the nth highest number in an unsorted array. What I did was sort it with mergeSort then find the index of the nth highest number. I think this is more efficient than most searches but I am not quite sure.....  import java.util.Arrays; public class ThirdHighest {  public static void main(String[] args) {     // TODO Auto-generated method stub     int [] a = new int[]{3,5,6,7,8,2,1,10,9};     System.out.print(Arrays.toString(a));     mergeSort(a);     System.out.print(Arrays.toString(a));     System.out.print(nHighestValue(a, 3));  } public static void mergeSort(int[] arr) {     if(arr.length &gt; 1) {         int lengthLeft = arr.length / 2;          int [] left = Arrays.copyOfRange(arr, 0, lengthLeft);         int [] right = Arrays.copyOfRange(arr, lengthLeft, arr.length);         mergeSort(left);         mergeSort(right);         merge(arr, left, right);     } } public static void merge(int[] result, int[] left, int[] right){     int l1 = 0;     int r2 = 0;     while(l1 &lt; left.length || r2 &lt; right.length) {         if(l1 == left.length) {             result[l1+r2] = right[r2];             r2 += 1;         } else if(r2 == right.length){             result[l1+r2] = left[l1];             l1 += 1;         } else if(left[l1] &lt; right[r2]) {             result[l1 + r2] = left[l1];             l1 += 1;         } else {             result[l1+r2] = right[r2];             r2 += 1;         }     } } public static int nHighestValue(int[] a, int n) {     int index = a.length - n;     return a[index];  }  }
I believe there's a way to find the kth largest element in an unsorted array of length n in O(n).  Or perhaps it's "expected" O(n) or something.  How can we do this?
My girlfriend is Russian. Last night we tried to fly her to the US on a valid tourist visa. She was stopped at DME and told she would be required to have $2700 USD to get back home immediately even though she had a return ticket. She said this was an "unwritten" rule because of the nonsense i keep seeing on CNN , Anybody else know anything? She is literally trapped and scared to death. Who's the random kid standing in the gathering at the end? My &quot;hat&quot; is shown twice in my answer, once in my sig, and again above. MacOS 10.14.6; Safari Version 14.0.2 (14610.3.7.1.10) We know that if a finite field $F$ has characteristic $p$ (prime), then $F$ has cardinality $p^r$ where $r = [F:\mathbb{F}_p]$.   I'm now trying to say something about the possible cardinalities of subfields of $F$. I can see that there is a subfield of cardinality $p^s$ for each $s$ that divides $r$, given by the fixed field of the group generated by $\phi^s$, where $\phi$ is the Frobenius automorphism.  Now suppose $K$ is a subfield of $F$. Then (since both are additive groups), Lagrange gives us that $|K|$ divides $|F|$, so $|K| = p^t$ for some $1 \leq t \leq r $ (alternatively, $K$ contains $\mathbb{F}_p$ and so is a vector space over $\mathbb{F}_p$ and is thus isomorphic to $\mathbb{F}_p^t$, where $t = [K:\mathbb{F}_p]$). By considering the multiplicative group of units of $K$ and $F$ respectively, we get that $ p^t - 1$ divides $p^r -1$. I want to make the leap to $t|r$, but I'm failing to see why this needs to be true. Any help would be appreciated. Do I need a transit visa for waiting 23 hours in Dubai airport? I am an Indian citizen living in Ukraine. I will be traveling to India but I need to wait in Dubai airport 23 hours for my next flight to India. I will not be leaving Dubai airport.  So in this case do I need a transit visa? Creating additional Virtual Host Ubuntu Server Monotonicity in argmin function I have the following equation $$f(a)=\text{argmin}_{t\in\mathbb{R}} \sum_{i=1}^n\frac{1}{2}(1-a)(b_i-t)^2+a| b_i-t |, a\in[0,1]$$  How does one prove that the function is monotone in a? Prove that for every $a\in A$ $\exists$ $q\in M,s\in A$ s.t. $a=sba+qa$ where $M$ is maximal ideal in $A$. Let A be a commutative ring with unity ring, M be a maximal ideal and $b\notin M$ . Show that there exists $q \in M, s\in A$ such that for every $a \in A$ we have $a=sba+qa$. Show that this is true only when $M$ is a maximal ideal.   Suppose if we take $A=2\mathbb Z$ and $M=4\mathbb Z$, $a=6.$ Then by the given statement $\exists$ $s\in A$, $q\in M$ s.t. $6=6(2s+q)$ $\implies$$s=\frac{1-q}{2}\implies q \text { is odd}$. But $q \in 4\mathbb Z.$  Please someone give some hints. how can solve this.  Thank you.. I have read the Rules of a competition. The text of the Rules include a sentence as follows:     As per stated in the Rules the entrants will be notified by May 30th 2010.   Does the sentence above mean that May 30th is included in the term of notification or not? May $y=e^x$ be satisfied with both $x$ and $y$ be positive integers?  I think it is not possible as $e$ ,a transcendental number, when multiplied by itself would never result in rational number.  Am I right? What is the difference between “within” and “inside”? Here is the definition of the word within from Oxford Dictionary:     inside (something)   So does that mean the two words have no difference, and can be used exchangingly? Is there any connotation that one word can be used but not the other? How to disable copy in shared folder I am trying to make folder that everyone can view and can't copy,modify.    For all answers.I thinking about specially ms office files. I tried following methods  Software  - copy protect    - anti copy    This method can't protect save as and upload  MS office macro    Users can enable,disable macros.  MS office restriction    This is best choice but can't protect from file uploading.   Almost I found the solution. Way is combination of MS office restriction and restrict access from browsers using firewall or antivirus. But I don't exact how to do this. Comparison of backup tools Let us consider the following code and the algorithm corresponding to it    \documentclass{article}   \usepackage[utf8]{inputenc}    \usepackage[]{algorithm2e}     \begin{document}     \begin{center}    \begin{algorithm}[H]     \KwData{this text}     \KwResult{how to write algorithm with \LaTeX2e }     initialization\;     \While{not at end of this document}{      read current\;      \eIf{understand}{              go to next section\;       current section becomes this one\;       }{       go back to the beginning of current section\;      }     }     \caption{How to write algorithms}    \end{algorithm}    \end{center}    \end{document}   Which gives the following     I want to add running times for each step to my algorithm as shown below (for example)    So, I need to make my algorithm as a column in the table and one more column for running times of each step, how can I make my algorithm as a column inside a table? How do I get rid of eggs? How to prove the following expression does not depend on x? I'm not sure how to approach this question, but I know it has something to do with taking the derivative of this. Can anyone please help me out?  Let x > 0. Prove that the value of the following expression does not depend on x: $$\int_{0}^{x}\frac{1}{1+t^4} dt + \frac{1}{3}\int_{0}^\frac{1}{x^3} \frac{1}{1+t^\frac{4}{3}} dt$$ How can we disable triggers, Validation Rules and workflow rules in salesforce org. [on off - switch] How can we disable triggers, Validation Rules and workflow rules in salesforce org.  This becomes really needed and important when we are doing data migration(data imports) in salesforce.  The way I handled this is create a custom label and include it in workflow and validation rule logic.   example - Custom label 'Disable workflow' = True then do not fire workflows.            if its False then fire workflow  But wanted to understand if there is any more efficient way to handle these scenarios. RegEx for Javascript to allow only alphanumeric It is usually said that existence of discrete spacetime violates Lorentz symmetry. What quantity is used to quantify such violation? I mean could someone points a reference for a derivation that shows such analysis.  My other question is: if Lorentz symmetry is violated, does that imply space-time is discrete? or not necessarily?) Using Fingerprint reader in 16.04 I have a Dell laptop with fingerprint reader inbuilt. I just ran lsusb on terminal and got the following result:   Bus 002 Device 003: ID 138a:0011 Validity Sensors, Inc. VFS5011 Fingerprint Reader Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 002: ID 046d:c077 Logitech, Inc. M105 Optical Mouse Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 004: ID 05ca:1820 Ricoh Co., Ltd Integrated Webcam Bus 001 Device 003: ID 0a5c:21bc Broadcom Corp. BCM2070 Bluetooth 2.1 + EDR Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub   Is it possible to use fingerprint scanning instead of traditional login with 16.04 and Unity ? Thanks.