Tagged: arrays

Linear Search

Linear Search is the simplest and easiest searching algorithm. Linear search algorithm works by simply finding the desired element from start to end of the list.  Linear search algorithm returns the index position of the element, if found in the list, else, returns false or invalid index position (i.e., -1)....

Count All Occurrences of an Element in an Array

“Count All Occurrences of an Element in an Array” is a basic problem of array data structure. Here, we are given an array of size ‘n’ and an element ‘x’. Our task is to write a program to count all occurrences of an element in an array. Example (Count All...

Find Smallest and Largest Element in an Array

“Find Smallest and Largest Element in an Array” is an elementary problem of an Array data structure for beginners. Here, we are given an array of size ‘n’ and our task is to find the largest and smallest element of the array. Example (Find smallest and Largest Element in an...

blank

Count Even and Odd numbers in an Array

“Count Even and Odd numbers in an Array” is an elementary problem of array data structure for beginners. Here, we are given an array of size ‘n’ and our task is to count the number of even elements and number of odd elements of an array. Example: INPUT: Enter the...

blank

Reverse an Array

“Reverse an Array” is an elementary problem for beginners based on array data structure. Here, we are given an array containing ‘n’ elements and our task is to reverse given array. Example: INPUT ARRAY: Array[5] = {1, 2, 3, 4, 5} OUTPUT ARRAY: Array[5] = {5, 4, 3, 2, 1}...

blank

Find most Frequent Character in String

“Find most Frequent Character in String” is a problem of string data structure. Here, we are given a string of length ‘n’ and our task is to write a program to find the most frequent character of the string.  If there are more than one character which have same highest...

blank

Next Greater Element

“Next Greater Element” is a classic interview problem based on stack data structure. Here, we have given an array with ‘n’ elements. Our task is to print next greater element of each element of an array. If there is no greater element for any element in an array, simply print...