#include<bits/stdc++.h>
using namespace std;
bool visit[10]={false};
int jump[10][10];
int DFS(int start,int len,int count,int m,int n)
{
if(len >= m)
count++;
len++;
if(len > n)
return count;
visit[start]=true;
for(int next=1; next<=9;next++)
{
int jump_through=jump[start][next];
if(visit[next]==false && (jump_through==0  visit[jump_through]==true))
{
count =DFS(next,len ,count,m,n);
}
}
visit[start]=false;
return count;
}
int main()
{
int m=4,n=6;
memset(jump,0,sizeof(jump));
jump[1][3] = jump[3][1] = 2;
jump[7][9] = jump[9][7] = 8;
// 4 lies between 1 and 7
jump[1][7] = jump[7][1] = 4;
// 6 lies between 3 and 9
jump[3][9] = jump[9][3] = 6;
// 5 lies between 1, 9 2, 8 3, 7 and 4, 6
jump[1][9] = jump[9][1] = jump[2][8] = jump[8][2]
= jump[3][7] = jump[7][3] = jump[4][6] = jump[6][4] = 5;
int count=0;
count+=DFS(1,1,0,m,n)*4;
count+=DFS(2,1,0,m,n)*4;
count+=DFS(5,1,0,m,n);
cout<<count;
}
badalgupta9911103602
@badalgupta9911103602
Posts made by badalgupta9911103602

Number of possible mobile lock patterns with min m keys and Max n keys

RE: Given a Binary Search Tree, Find the distance between 2 nodes
dist(a,b) = Dist(root , a)+Dist(root,b)  2* Dist(root , lca)
int find_dist(Node *root,int a) { if(root==NULL) return 1; int dist=1; if(root>data==a  (dist=find_dist(root>left,a)) >=0 (dist=find_dist(root>right,a))>=0 ) return dist+1; return dist; } Node *lca(Node * root, int a,int b) { if(root==NULL) return root; if(root>data==a  root>data==b) return root; Node *L=lca(root>left,a,b); Node *R=lca(root>right,a,b); if(L!=NULL && R!=NULL) return root; if(L==NULL) return R; else return L; } int findDist(Node* root, int a, int b) { int n1=find_dist(root , a); int n2=find_dist(root,b); Node *temp=lca(root,a,b); int n3=find_dist(root,temp>data); return n1+n22*(n3); }

Design a Snake Ladder game
Data structure you can use to Design a Snake Ladder game

RE: My simple c++ solution
Awesome Simple and Clear Implementation Easy to Understand :)

RE: what is different of Logical address and Physical address between father process and child process？？
@WenhuiZhang I don't thing so their is concept of demand paging , In which pages are bring to memory on demand .

RE: Context Switch in Round Robin Scheduling ?
Even when we have 1 process still context switch will happen in Round Robin .
Round Robin is a scheduling Algorithm in which process share CPU in time sharing mode. So when the time quantum expires, process need to be context switch irrespective of number of process as process executes in running state and available processes are present in ready state. 
RE: what is different of Logical address and Physical address between father process and child process？？
@WenhuiZhang I didn't understand your question
Sharing same logical address space mean that both will have exact copy of address space but in actual they are at different physical location.
And Regarding your shuffling point , mapping between physical and logical address doesn't change.