public static SingleNode partition1(SingleNode head, int x){
		SingleNode node=head;
		SingleNode beforeStart=null;
		SingleNode beforeEnd=null;
		SingleNode afterStart=null;
		SingleNode afterEnd=null;
		while(node!=null){
			SingleNode next=node.next;
			node.next=null;
			if((int)node.data<x){
				if(beforeStart==null){
					beforeStart=node;
					beforeEnd=beforeStart;
				}
				else{
					beforeEnd.next=node;
					beforeEnd=node;
				}
			}else{
				if(afterStart==null){
					afterStart=node;
					afterEnd=afterStart;
				}
				else{
					afterEnd.next=node;
					afterEnd=node;
				}
			}
			node=next;
		}
		if(beforeStart==null) return afterStart;
		beforeEnd.next=afterStart;
		return beforeStart;
	}