EMIS HEALTH – Fresher Interview Questions
Here in this blog we explain about EMIS HEALTH – Fresher Interview Questions . Some of the questions are discussed below for better understanding .
_______________________________________________________________________________
- Explain briefly about Palindrome with an example .
PALINDROME
An integer is a palindrome if the reverse of that number is equal to the original number.
Example: Program to Check Palindrome
#include <stdio.h>
int main()
{
int n, reversedInteger = 0, remainder, originalInteger;
printf(“Enter an integer: “);
scanf(“%d”, &n);
originalInteger = n;
// reversed integer is stored in variable
while( n!=0 )
{
remainder = n%10;
reversedInteger = reversedInteger*10 + remainder;
n /= 10;
}
// palindrome if orignalInteger and reversedInteger are equal
if (originalInteger == reversedInteger)
printf(“%d is a palindrome.”, originalInteger);
else
printf(“%d is not a palindrome.”, originalInteger);
return 0;
}
Output
Enter an integer: 1001
1001 is a palindrome.
_______________________________________________________________________________
2 . Explain briefly about maximum sum sub arrays from array .
Input : arr[] = {1, 3, -4, 5, -2}
Query 1: start = 0, end = 4
Query 2: start = 0, end = 2
Output : 5
4
Explanation:
For Query 1, [1, 3, -4, 5] or ( [5] )
represent the maximum sum sub arrays
with sum = 5.
For Query 2, [1, 3] represents the
maximum sum subarray in the query range
with sum = 4
______________________________________________________________________________
3 . Explain briefly about Binary Search ?
Binary Search:
Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.
// C program to implement recursive Binary Search
#include <stdio.h>
// A recursive binary search function. It returns // location of x in given array arr[l..r] is present, // otherwise -1 int binarySearch(int arr[], int l, int r, int x) { if (r >= l) { int mid = l + (r – l)/2;
// If the element is present at the middle // itself if (arr[mid] == x) return mid;
// If element is smaller than mid, then // it can only be present in left subarray if (arr[mid] > x) return binarySearch(arr, l, mid-1, x);
// Else the element can only be present // in right subarray return binarySearch(arr, mid+1, r, x); }
// We reach here when element is not // present in array return -1; }
int main(void) { int arr[] = {2, 3, 4, 10, 40}; int n = sizeof(arr)/ sizeof(arr[0]); int x = 10; int result = binarySearch(arr, 0, n-1, x); (result == -1)? printf(“Element is not present in array”) : printf(“Element is present at index %d”, result); return 0; } |
Output :
Element is present at index 3
______________________________________________________________________________