Assignment 1
Assignment 1
#include <stdio.h>
#include <string.h>
int main()
{
char str1[100],str2[100];
int i=0,j;
}
printf("NO, the word is not in sentence\n");
return 0;
}
(b) Pointer
#include <stdio.h>
#include<string.h>
int funct(char *str1,char *str2, int n, int m)
{
int i=0,j,k=0;
{
while(i<n)
{
int count=0;
j=0;
while(i<n&&j<m&&str1[i]==str2[j])
{
k=i;
i++;
j++;
count++;
}
if(count==m)
{
printf("YES, the word is in the sentence\n");
return 0;
}
i++;
}
printf("NO, the word is not in sentence\n");
return 0;
}
}
int main()
{
char str1[100],str2[100];
int i=0,j;
#include <stdio.h>
int main() {
print(&arr[0], n);
insertion(&arr[0], n);
print(&arr[0], n);
APPLICATION
1. If you know your lists are never going to contain more than say 25 elements, then
insertion sort is an excellent choice. It is very simple and it’s going to be more
efficient than any more complicated sort like quick-sort.
2. great for small or mostly-sorted arrays
3. Real time application
You have a shopping list, and your wife is telling you to grab them in 15 minutes.
She gives you also priorities, so you need to grab them first. You gotta rush!
1. Eggs (4)
2. Bread (2)
3. Milk (6)
4. Water (3)
5. Meat (1)
6. Detergent (5)