Facebook

arrays

Binary Search

Binary Search The binary search technique works only on sorted array.It works by comparing the input element to the middle element of array.The comparison determines whether the element is less than.greater than or equal to middle element.Subsequent steps to be followed are written and explained by the following program. Program #include <stdio.h> int main() {… read more »

Merge Sort

Merge sort is the divide and conquer method to arrange elements in the order.The steps followed in merge sort are : Divide the sequence of n elements into two sub-sequences of n/2 elements each. Sort the sub-sequences using merge sort.If the size of sequence is 1,nothing more can be done. Merge the sub-sequences to form… read more »

Bubble Sort

Bubble Sort is a sorting technique which arranges elements in the increasing order by moving across the array and swapping the adjacent elements that are out of order. The complexity of bubble sort is O(n2). The steps followed are : Move from first to the last element of array. Swap the element if it is… read more »

Quicksort

Sorting is a technique to arrange the sequence of elements either in ascending or descending order. Quicksort is an efficient way to sort elements of array.The average running time of quicksort is O(nlogn).The steps followed in quicksort are : Choose the pivot element(Say we choose the pivot element in the beginning of array).  Scan from… read more »

Deletion of element from array

Deleting  an  element means to remove element from the array. It is quite easy to delete the element from the end of array. On the controversial side,what is needed to delete the element from our  desired location  like somewhere in the middle of array . Deleting an element requires that all the subsequent elements must be moved one… read more »

Insertion of element in an array

Inserting an element means to embed element in the array.It is quite easy to insert the element in the end of array provided sufficient memory locations are present to accommodate the additional element.On the controversial side,what is needed to insert the element at our desired location like somewhere in the middle of array .All the… read more »

Linear Search

Searching in an array refers to finding the location of a particular element in the given array. It can be done in two ways : Linear Search Binary Search Linear Search It is done by comparing each and every element of array with the data item for which index needs to be found.The data item… read more »

Traversing an Array

The various operations that are performed on arrays are : Traversal Searching Insertion Deletion Sorting and Merging Traversing in array This article explains about how to traverse in an array. Traversing means to visit/to go/travel across each and every element of an array. Program #include<stdio.h> int main() { int rank[5] = {10,20,30,13,15}; int i; printf(“\nThe… read more »

Two Dimensional Arrays

Whether it be playing a tic tac toe game(Fig 1) , storing data in a spreadsheet(Fig 2) or a Rating chart of movie by reviewers(Fig 3), a single dimensional or 1D array cannot store the data. Instead, it needs to be stored in 2 dimensional or multi-dimensional array. Types of Arrays Single Dimensional Array Two… read more »

Introduction to Arrays

Well, we all know what a multiplication table does(Fig 1). We pick any number and multiply with Series from 1-10,and hence we get the resultant series. For example If we want to store this result sequence 5 10 15 20 in computer memory using any programming language, what would we do? To store this or… read more »

Sidebar