Outputs : - Number of Possibilities that i can have for given n
if a[n][i] exists, then return a[n][i]
if n equals 1 then return 1
a) if i equals 0 then save StairRecursion((i + 1), (n - 1)) % 1000000000 to arr[n][i] then return arr[n][i]
b) if i equals 9 then return save StairRecursion((i - 1), (n - 1)) % 1000000000 to arr[n][i] then return arr[n][i]
c) if i equals (1 to 8) then return save (StairRecursion((i - 1), (n - 1)) + StairRecursion((i + 1), (n - 1))) % 1000000000 to arr[n][i] then return arr[n][i]
this will hopefully sum up all the values being returned recursively
Procedure findMaxH(long[] a, long p, long r, Long m)
Inputs : - a : the array to search in - p : the value we are searching for in a(min) m의 촤소값 - r : the value we are searching for in a(max) m의 최대값 - m : the value we are searching for in a(equal) 잘라야하는 나무의 값
Outputs : - 잘라야하는 나무 산출량의 최대 높이
최소값을 0, 최대값을 나무의 최대크기로 정한다.
최소값 + 최대값의 평균값인 q를 구한다.
q 값일때 나무 산출량을 H를 ValueOfTreeOutput을 통해 구한다. a) H가 m 보다 크면 최소값을 q+1로 수정한다 b) H가 m 보다 작으면 최대값을 q-1로 수정한다 c) H와m이 같다면 q를 반환한다.
// allocate next number sn = newNode.previous.data_row;
// delete corresponding Node // when newNode is last if(newNode == last){ newNode.next.previous = newNode.previous; newNode.previous.next = newNode.next; last = newNode.previous; }else { newNode.next.previous = newNode.previous; }
// when newNode is first if(newNode == first){ newNode.next.previous = newNode.previous; newNode.previous.next = newNode.next; first = newNode.next; }else { newNode.previous.next = newNode.next; } return sn;
} }
publicstaticvoidmain(String[] args)throws Exception { CustomLinkedList cll = new CustomLinkedList();
Scanner sc = new Scanner(System.in);
// Number of Elements in the list int N = sc.nextInt();
// Directional Data int [] paperNumbers = newint[N+1];
// Initialize List with consecutive order for (int i = 1; i <= N; i++) {
// Directional Data paperNumbers[i] = sc.nextInt(); cll.InsertFirst(i); }
// show all elements // cll.DisplayAll();
// Starting number int sn = 1;
//balloon Problem for (int i = 0; i<N; i++){ //System.out.println(); //cll.DisplayAll(); //System.out.println(); //System.out.println("sn :" + sn); sn = cll.Balloon(sn, paperNumbers[ValueBeingRemoved]); if (i == N-1)break; System.out.print(" "); }
while (newNode.data != sn){ newNode = newNode.previous; }
// find data with d distance away while (counter != d){ newNode = newNode.previous; ++counter; }
// print number being deleted System.out.print(newNode.data);
// allocate next number sn = newNode.previous.data;
// delete corresponding Node // when newNode is last if(newNode == last){ newNode.next.previous = newNode.previous; newNode.previous.next = newNode.next; last = newNode.previous; }else { newNode.next.previous = newNode.previous; }
// when newNode is first if(newNode == first){ newNode.next.previous = newNode.previous; newNode.previous.next = newNode.next; first = newNode.next; }else { newNode.previous.next = newNode.next; }
return sn;
} }
publicstaticvoidmain(String[] args)throws Exception { CustomLinkedList cll = new CustomLinkedList();
Scanner sc = new Scanner(System.in);
// Number of Elements in the list int N = sc.nextInt();
// Number of Elements to be jumped int K = sc.nextInt();
// Initialize List with consecutive order for (int i = 1; i <= N; i++) { cll.InsertFirst(i); }
// show all elements //cll.DisplayAll();
// Starting number int sn = 1;
//Josephus Problem
System.out.print("<"); for (int i = 0; i<N; i++){ //cll.DisplayAll(); //System.out.println(); sn = cll.Josephus(sn, K); if (i == N-1)break; System.out.print(", "); } System.out.print(">");
public Node DeleteFirstNode(){ Node temp = first; if(first.next == null){ last = null; }else { first.next.previous = null; } first = first.next; return temp;
}
publicbooleanIsEmpty(){ return (first == null); }
//앞쪽 부터 몇번 리스트를 움직여야 해당 숫자를 없애는지 체크크 publicintStepsFromFirst(int data){ int k = 0; Node Current = first; while (Current != null) { if(Current.data == data) { return k; } Current = Current.next; k++; } return k; }
//given List is not empty; publicvoidRearrangeListToHaveDataFirst(int data){ Node Current = first; while (Current != null){ if(Current.data == data){ break; } // DeleteFirstNode if(first.next == null){ last = null; }else { first.next.previous = null; } first = first.next;