Write a code to implement stack program in C using linked list. In this tutorial, You are going to learn how to implement stack data structure using linked list.
In my previous post, I have explained Stack program in c using array.
Write a code to implement stack program in C using linked list. In this tutorial, You are going to learn how to implement stack data structure using linked list.
In my previous post, I have explained Stack program in c using array.
Recursion is the most important concept in computer science. In this tutorial, You’ll find lot of practice questions related to recursion which will help you to grasp the concept.
In my previous posts, i have written about binary search implementation using recursion and difference between recursion and iteration.
These MCQ helps you to understand the concept of Recursion. These are some of the tricky questions on recursion which i collected for practice.
1) Which Data Structure is mainly used for implementing the recursive algorithm?
Write a program to implement binary search using recursion in c.
Given a sorted array, write a code to search an element in an array.
For example –
Example1 : arr[] = {1, 3, 5, 6, 7} target = 5
The element 5 is found at index 2.
We have given a sorted array, we can use binary search algorithm to search an element efficiently.
Binary Search is a searching algorithm that search an element in a sorted array in O(logN) time complexity.
In binary search, we first calculate the mid. In next step, we compare element present at mid index to the target value. If target value is found, we return the mid index. Else If the search value is less than or greater than the middle element, the search continues in the lower or upper half of the array.
Important Points
i) A Binary search algorithm is applicable only for sorted values. An array should be sorted either in ascending or descending order.
ii) The time complexity of binary search is O(log(n)).
In my previous post, I have discussed Binary search program in c using iterative approach. In this post, I am going to explain how to implement a binary search program in c using recursion.