I am trying to achieve a reversed link list. The new fresh list  must be created recursively.  I am creating the first node in the reversed list and I am trying to create a sublist Next which has the next element as next.next and finally to assign this sublist as next to the node. The issue is that the next node remains NIL although I recreated it in the for loop.  Edit:  The function must not change (add arguments) because some tests are running upon it.  class Node {     private Object item;     private Node next,current;      public Node(Object o, Node n) {         this.item = o;         this.next = n;     }       public Node(Node n) {     }      public static final Node NIL = new Node(Node.NIL, Node.NIL);      public Object getItem() {         return this.item;     }      public Node getNext() {         return this.next;     }      public void setItem(Object o) {         this.item = o;     }      public void setNext(Node n) {         this.next = n;     }      // this method returns the item with index number i     public Object nthItem(int i) {         Node p = this;         while (p!=null){             for (int k=1;k&lt;=i;k++){                 p=p.next;              }             return p.item;         }         return null;       }      // this method returns the the next item of the node     public Node nthNext(int i) {         Node p = this;         while (p!=null){             for (int k=1;k&lt;=i;k++){                 p=p.next;              }             return p.getNext();         }         return null;     }      public Node nthNode(int i) {         Node p = this;         while (p!=null){             for (int k=1;k&lt;=i;k++){                 p=p.next;              }             return p;         }         return NIL;       }      public int length(){         if (this == NIL) return 0;         else return 1 + next.length();     }      public Node remove(Object o){         Node p = this;         if (p == NIL) return NIL;         else if(p.item == o) {             p = p.next;             return p.remove(o);         }          else return new Node(p.item, p.next.remove(o));      }      public Node reverse() {         int i = this.length()-1;         if(this == NIL) return NIL;          Node node = new Node(Node.NIL, Node.NIL);          Node next = NIL;          //create the first node in the reversed list         if(i &gt;= 1) node = new Node(nthItem(i), next);         else node = new Node(nthItem(i), Node.NIL);          //iterate through the original list and create a next node         if (i&gt;0) {             for (int k=i; k&gt;=0; k--){                 if (k&lt;=0)  {                     next = NIL;                 }                 else {                     next = new Node(nthItem(k-1),next);                 }                            }         }          //debugging in console         System.out.println("final node = " + next.item+" ");         return node;     } }  class Test{      public static void main(String[] string){         Node n = new Node(1, Node.NIL);         Node nn = new Node(2, n);          Node r = nn.reverse();          System.out.println("\t item " + r.getItem()+ " " + r.getNext().getItem() + " length " + r.length());     } }
I have been working on a Java project for a class for a while now. It is an implementation of a linked list (here called AddressList, containing simple nodes called ListNode). The catch is that everything would have to be done with recursive algorithms. I was able to do everything fine sans one method: public AddressList reverse()      ListNode:    public class ListNode{   public String data;   public ListNode next; }   Right now my reverse function just calls a helper function that takes an argument to allow recursion.  public AddressList reverse(){   return new AddressList(this.reverse(this.head)); }   With my helper function having the signature of private ListNode reverse(ListNode current).  At the moment, I have it working iteratively using a stack, but this is not what the specification requires. I had found an algorithm in C that recursively reversed and converted it to Java code by hand, and it worked, but I had no understanding of it.  Edit: Nevermind, I figured it out in the meantime.  private AddressList reverse(ListNode current, AddressList reversedList){   if(current == null)        return reversedList;   reversedList.addToFront(current.getData());   return this.reverse(current.getNext(), reversedList); }   While I'm here, does anyone see any problems with this route?
How can I add new autostart programs in Lubuntu? In Lubuntu, there's no 'Add New Program...' button in Desktop Session Settings. Is there an easy way to add new autostart programs in Lubuntu? How to find and replace using sed on records starting with Specific number Stone-Weierstrass theorem with $p(1/x)$ I am trying to prove that for a continuous $f\colon[1,\infty)\rightarrow\mathbb R$ and $f(x)\to a$ as $x\to\infty$ it could be approximated by $g(x)=p(1/x)$ where $p$ is a polynomial. Why are lamps and mesh lights not illuminating anything? Prove that a subset of a separable set is itself separable How could I define function with function such as Coefficient? Making your Windows 7 a WIFI hotspot for Android? I use a broadband dongle on my Windows 7. I want to expose my laptop as a wifi hotspot so that i can use internet on my samsung galaxy ace.  I have tried Connectify but my chipset is not supported so it simply make the adhoc network. Tried Bzeek. My phone get connected, but no browsing.  Any solution that you guys have?  PS: I am in no mood to root my device. An exciting new feature is described in the :        There is a new NPC housing interface that can be used to assign living areas to NPC’s. This interface will also tell you if a room is missing any requirements.      How can this interface be accessed? I'm experimenting with VPNs, so I wanted to install pptpd.  john@desktop:~$ sudo apt-get install pptpd [sudo] password for john:  &lt;snip&gt; The following extra packages will be installed:   bcrelay The following NEW packages will be installed:   bcrelay pptpd 0 upgraded, 2 newly installed, 0 to remove and 11 not upgraded. Need to get 90.5 kB of archives. After this operation, 442 kB of additional disk space will be used. Do you want to continue [Y/n]? y   And everything runs fine until I get down to here:  WARNING: The following packages cannot be authenticated!   bcrelay pptpd Install these packages without verification [y/N]? n E: Some packages could not be authenticated   No authentication?  I'm no security expert, but I'm fairly sure that's a bad thing.  So I .  john@desktop:~$ apt-cache policy pptpd pptpd:   Installed: (none)   Candidate: 1.3.4-3ubuntu1   Version table:      1.3.4-3ubuntu1 0         500 http://us.archive.ubuntu.com/ubuntu/ natty/main i386 Packages john@desktop:~$ apt-cache policy bcrelay bcrelay:   Installed: (none)   Candidate: 1.3.4-3ubuntu1   Version table:      1.3.4-3ubuntu1 0         500 http://us.archive.ubuntu.com/ubuntu/ natty/main i386 Packages   They're coming from Ubuntu.com and not being properly authenticated?  What's going on here? SSH failed to start - Missing privilege separation directory: /var/run/sshd Arrow keys, Home, End, tab-complete keys not working in shell I have installed ubuntu minimal(mini.iso) on my vm. I then used recovery mode to login as root and create an account with useradd -m admin and then set a password with passwd admin.  When I login on the new account, instead of the normal prompt I only see a $ sign. If I try to tab-complete a command or file name it prints a normal tab. If I try to use the arrow keys it prints ^[[A, ^[[B, ^[[C or ^[[D. Also, ls no longer adds colors.  None of these problems were in recovery mode. How can I fix this? Is it possible to change the line style in a tikz figure in the same \draw command?  I am looking for something like:  \documentclass[tikz]{standalone} \begin{document}     \begin{tikzpicture}         \draw[style1] (0,0) -- ++(1,0)  **CHANGE STYLE** -- ++(1,0);     \end{tikzpicture} \end{document}   The main motivation is that I don't want to loose the relative coordinate as I go on with a long \draw command. "Nikki's and Alice's X" vs. "Nikki and Alice's X" Input file1 is:  dog 123 4335 cat 13123 23424  deer 2131 213132 bear 2313 21313   I give the match the  pattern from in other file ( like dog 123 4335 from   file2).  I match the pattern of the line is dog 123 4335 and after printing all lines without match line my output is:   cat 13123 23424 deer 2131 213132 bear 2313 21313   If only use without address of line only use the pattern, for example 1s how to  match and  print the lines? Set Snap Mode with PyQGIS I am trying to set snap mode within QGIS plugin.  So far, I have tried:  QgsSnappingUtils().setSnapToMapMode(QgsSnappingUtils.SnapAdvanced)   and  QgsSnappingUtils().setSnapToMapMode(2)   without success.  QGIS Snapping options (Settings>>Snapping Options...) continue with:  Snapping mode = Current layer  Any hint? (Using v 2.14.0) I want to setup a new virtual machine with some specified packages (name and version), that are provided.  For example apache2 in version 2.2.20-1ubuntu1 with all dependencies. Even if there is a new version of this package on the servers this one should be installed.  The solution has to work/scale with multiple (n) "setups". Another virtual machine might need an older version of apache2.  I currently know of some possibilities that install the exact packages, but do not scale that good:   Copy all required *.deb to every virtual machine manually and enter: dpkg -i ... -> Could work, but it is very error prone. (Manual scripts etc.) Create and use a new Ubuntu repository for each setup. -> Does not work because I would need n repositories. Setup the machine once and copy the VM / create a snapshot. -> Does not work because I would need to store n VMs.   My problem could be labeled as patch management, but I do not want to update my packages to the current version. My goal is to install old packages. Non-existence of $\lim \limits_{(x, y) \to (0,0)} \frac{x^3 + y^3}{x - y} $ How to show that $\lim \limits_{(x, y) \to (0,0)} f(x, y)$ does not   exist where,         $$f(x, y) =  \begin{cases} \dfrac{x^3 + y^3}{x - y} \; ; &amp; x \neq y \\  0 \; \;\;\;\;\;\;\;\;\;\;\; ; &amp; x = y  \end{cases}  $$   I tried bounding the value of the function as $(x, y)$ approaches $(0,0)$ but was not successful. I graphed the function and saw that it was actually approaching $0$ but Microsoft Math failed to render some points around the $x = y$ plane. So I imagine I need to find points $(x, y)$ such that $x$ is extremely close to $y$ but $(x, y)$ is not as close to $(0,0)$ to show that the function does not approach $0$ around the origin. But was unable to think of any.   Hints or suggestions would be awesome. Any help is appreciated. Variance of a linear combination of vectors Let $A$ and $B$ be two constant matrices and let $x$ and $ y$ be two random vectors, what is the general formula for $Var(Ax+By)$? I know the formula for when $x$ and $y$ are scalar random variables and $A$ and $B$ are constants, but what about the matrix case? Let $t\in \mathbb R$. Prove that $\displaystyle{\sum_{n=1}^{\infty}n^{3}\sin\left(\frac{1}{n}\right)-n^{2}+t}$ converges iff $t=\frac{1}{6}$.  While the $(\Rightarrow)$ direction was fairly easy (as $a_n$ should converge to $0$, forcing $t=\frac{1}{6}$), i'm facing some hard time trying to prove the second direction, that is $\displaystyle{\sum_{n=1}^{\infty}(n^{3}\sin\left(\frac{1}{n}\right)-n^{2}+\frac{1}{6})}$ converges. I did notice that $a_n=a_{-n}$ and tried to write this series as a Leibnitz series, but had no luck since the sequence doesn't decrease. I also tried to prove absolute convergence but then again, no luck. Thanks. How do I prove or disprove $X \times (Y \cup Z)= (X \times Y) \cup(X\times Z)$  for all sets $X$, $Y$, and $Z$? I'm lost on the steps here.