Professional Documents
Culture Documents
Dsa Tutorial: Miscellaneous: (a) - Σ x=n (n+1) /2 x>=1
Dsa Tutorial: Miscellaneous: (a) - Σ x=n (n+1) /2 x>=1
Solution:-
Step 1:- “the check” for n=1, x=1(2)/2 = 1
Step 2:- “the induction step” assuming the result is true for n=k; i.e.,
assuming Σ x=k(k+1)/2 (Σ from 1 to k)
Σx(for1tok+1)= Σx(for1tok)+(k+1)
= k(k+1)/2 + (k+1)
= (k+1)( k/2 + 1)
= (k+1)(k+2)/2
Solution:-
Step 1:- “the check” for n=1, x=1(2)(3)/6 = 1
Step 2:- ‘the induction step” assuming the result is true for n=k; i.e.,
assuming
Σ x^2=k(k+1)(2k+1)/6 (Σ from 1 to k)
Σ x^2(for 1 to k+1)
= Σ x^2(for 1 to k) + (k+1)^2
= k(k+1)(2k+1)/6 + (k+1)^2
= (k+1)(k(2k+1)/6 +(k+1))
= (k+1)(2k^2+k+6k+6)/6
Solution:-
Step 1:-”the check” for n=1, x=(1(2))^2/4 = 1
Step 2:- “the induction step” assuming the result is true for n=k; i.e.,
assuming
Σ x^3(for 1 to k+1)
= Σ x^3(for 1 to k) + (k+1)^3
= (k(k+1))^2/4 + (k+1)^3
= (k+1)^2(k^2/4 +(k+1))
= (k+1)^2(k^2+4k+4)/4
=(k+1)^2(k+2)^2/4
=((k+1)(k+2))^2/4
Step 2:- (the induction step) assuming the result is true for k=n; i.e.,
assuming
=(x^(n+2)-1)/(x-1)
If(n==1)
return 1;
return n*factorial(n-1);
}
Int q = factorial(r);
Int j=factorial(n-r);
If(s[0]==’\0’)
return 0;
return 1;
int j = 0;
for(int i=0;s[i]!=’\0’;i++)
j++;
return ans + j;
}
int n = str.length();
if(index==n)
cout<<curr<<"\n"; }
else{
LHS=⌊-x⌋=-⌊x⌋-1 (GIFproperty)
LHS = RHS
Hence proved.
⌈x⌉ - ⌊x⌋ = 1
⌈−x⌉ - ⌊-x⌋ = 1
⌈−x⌉ = ⌊-x⌋ + 1.
⌈−x⌉ = -1 - ⌊x⌋ +1
⌈−x⌉ = −⌊x⌋
⌊−x ⌋ = -x
And, ⌊x⌋ = x
= ⌊−N-F⌋
= -N – 1
And,
⌊x ⌋ = N
⌊−x⌋+⌊x⌋=-N–1+N= -1,
hence proved.
⌈-x⌉ = -x
And, ⌈x⌉ = x
⌈-x⌉ = ⌈-(N+F) ⌉
= ⌈-N -F ⌉
= -N
And,
⌈x⌉ = N + 1
⌈-x⌉ + ⌈x⌉ = -N + N + 1 = 1,
hence proved.
e) ⌊x+n⌋=⌊x⌋+n
Solution:-
Here x = integer + fraction and n is an integer
⌊x+n⌋ = ⌊p + q +n⌋
Now ⌊(p + n) + q⌋ = p + n
Now in rhs
⌊p + q⌋ + n
p+ n
f) ⌈x+n⌉=⌈x⌉+n
Solution:-
Since n is an integer and x = p + q
⌈p + q + n⌉ = ⌈( p + n )+ q⌉ = p + n +1
In RHS,
⌈p+q⌉+n. (⌈p+q⌉returnsp+1sincepisintegerandqisfractional)
p+ 1 + n
LHS = RHS
Hence proved.
g) ⌈x/2⌉+⌊x/2⌋=x given x€Z
Solution:-
Case 1:- Let x be an even integer
=> RHS = X
= (2)⌊x/2⌋ + 1
= (2) ⌊(x-1)/2 + 1/2⌋ + 1 (since x is odd, therefore (x-1) will be an even no.)
= (2)((x-1)/2 ) + 1
=> x-1+1=x
=> RHS = X
hence proved.
#include<stdio.h>
int main(){
scanf("%d", °);
n=deg+1;
j=deg;
scanf("%d", &x);
result=arr[0]*x + arr[1];
return 0;
}
Solution:-
#include<stdio.h>
#include<math.h>
float factorial(int);
int main(){
int x;
scanf("%d", &x);
sin_value(radian, &result);
return 0;
n +=1;
sign *= -1;
int count;
float fact = 1;
fact *= count;
return(fact);