Binary Search Program in C

Write a code to implement binary search program in c. Given a sorted array, we have to write a code to search an element in an array using binary search.

Binary Search

A Binary Search is used to search an element in a sorted array.  In binary search, we first calculate the mid position of an array.  Then, After that we compare element to be search to the middle element an array. If a value matches with the middle element then the index is returned otherwise the algorithm repeats if the value is less than or greater than the middle element.

A Binary search algorithm is efficient than the linear search algorithm. The time complexity of binary search is O(log(n)). 

Stack Program in C using an Array – Stack Tutorial Part – I

Write a stack program in C using an array. Implement a stack data structure using an Array. In this tutorial, You are going to learn about stack data structure and it’s implementation in C using an array.

C Program to Implement a Stack using Linked List

Subscribe Our Tutorials

Get Latest Updates on Facebook

What is a Stack Data Structure?

A Stack is a Data Structure, in which insertion and deletion operations are allowed only at one end. It worked on LIFO (Last In First Out) Principle. In LIFO, an element which inserted last must be the first element to be removed.

Selection Sort Program in C

Write a selection sort program in C. Given an unsorted array, write a c code to sort an array using selection sort.

For example :

Input : {9, 8, 19, 2, 3 }
Output : { 2, 3, 8, 9, 19}

What is Selection Sort?

Selection sort is an in-place comparison technique. In selection sort, we pick minimum element and move an element to it’s correct position. We repeat this process until all the elements are sorted.

The time complexity of selection sort is O(n^2). It is not suitable for large data sets.

Bubble Sort Program in Java