Explain the functionality of following functions.
Answer: The function fun() calculates and returns ((1 + 2 … + x-1 + x) +y) which is x(x+1)/2 + y. For example if x is 5 and y is 2, then fun should return 15 + 2 = 17.
Answer: The function fun2() is a recursive implementation of Selection Sort.
Please write comments if you find any of the answers/codes incorrect, or you want to share more information about the topics discussed above.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Practice Questions for Recursion | Set 7
- Practice Questions for Recursion | Set 6
- Practice Questions for Recursion | Set 5
- Practice Questions for Recursion | Set 4
- Practice Questions for Recursion | Set 2
- Practice Questions for Recursion | Set 3
- Practice questions for Linked List and Recursion
- Recursive Practice Problems with Solutions
- Sum of the series 1^1 + 2^2 + 3^3 + ..... + n^n using recursion
- Tail Recursion
- Find the value of ln(N!) using Recursion
- Traverse a given Matrix using Recursion
- Product of 2 numbers using recursion | Set 2
- Generating all possible Subsequences using Recursion
- Generating subarrays using recursion
- Sum of even elements of an Array using Recursion
- Program to Calculate e^x by Recursion
- Sort the Queue using Recursion
- Reversing a queue using recursion
Improved By : NikSta