int func(int start, int end){ int length=end+1-start; if((length<1)||(start<0)||(end<0)){ return(0); } if(length%3==0){ return(func(start+1, end)); } else if(length%3==1){ return(1+func(start, end-1)); } else { return(func(start+2, end)); } }
#include <stdio.h> int main(){ int *ptr, a, b, c; a=5; b=11; c=20; ptr=&a; *ptr=c; ptr=&c; a=*(&b); c=*ptr-a; printf("%d",c); return(0); }
head
struct node{ int elt; struct node *next; }; int getListSize (struct node *head) { if( E1 ) return 1; return E2; }
#include <stdio.h> void func(int i, int j) { if (i < j) { int i = 0; while (i < 10) { j += 2; i++; } } printf("%d", i); } int main() { int i = 9, j = 10; func(i, j); return 0; }
int bar(int n){ if (n == 1) return 0; else return 1 + bar(n/2); } int foo(int n){ if (n == 1) return 1; else return 1 + foo(bar(n)); }
Consider game trees Tree-1 and Tree-2 as shown. The first level is a MAX agent and the second level is a MIN agent. The value in the square node is the output of the utility function.
For what ranges of \( x \) and \( y \), the right child of node B and the right child of node E will be pruned by the alpha-beta pruning algorithm?
def f(a, b): if (a == 0): return b if (a % 2 == 1): return 2 * f((a - 1) / 2, b) return b + f(a - 1, b) print(f(15, 10))
Consider the following Python code snippet.
The value printed by the code snippet is 160 (Answer in integer).
fun(int A[0, ..., n-1]) { for i = 0 to n-2 for j = 0 to n - i - 2 if (A[j] > A[j+1]) then swap A[j] and A[j+1] }