HomeCHAPTER CLASS 12 Recursion || Type C || Sumita Arora || Class 12 || Computer science || Information practices || Solution || 0 Comments Facebook Twitter Recursion || Type C || Sumita Arora || Class 12 || Computer science || Information practices || Solution Q1 = Write a function that takes a number and tests if it is a prime number using recursion technique. Q2 = Implement a function product() to multiply 2 numbers recursively using + and - operators only. Q3 = The hailstone sequence starting at a positive integer n is generated by following two simple rules. If n even, the next number in the sequence is n/ 2. If n is odd, the next number in the sequence is 3*n+1 Repeating this process, the hailstone sequence gets generated. Write a recursive function hailstone ( n) Which prints the hailstone sequence beginning at 1. Stop when the sequence reaches the number 1 (since otherwise, we would loop forever 1, 4, 2, 1, 4, 2, ….) . Q 4 = A happy number is a number in which the eventual sum of the square of the digits of the number is equal to 1. Example : 12 = (1)2+(2)2 =1+4=5 Hence, 12 is not a happy number Example 100 = (1)2 + ( 0 )2 + ( 0 )2 = 1+ 0 + 0 = 1 Hence, 100 is a happy number. Write a program that takes a number and checks if it is a happy number by using following two functions in it : Sum_sq_digits :returns the sum of the square of the digits of the number x, using the recursive technique Ishappy() : checks if the given number is a happy number by calling the function sum_sq_digits and displays an appropriate message Q 5 = A list namely Adm stores admission numbers of 100 students in it, sorted in ascending order of admission numbers. Write a program that takes an admission number and looks for it in list Adm using binary search technique. The binary search function should use recursion in it.
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )