(In C language) Implement Shellsort and count the number of moves on input in a given file data.
Please provide the answer in text format please.
#include <stdio.h>
int shellsort(int arr[], int num)
{
int i, j, k, tmp,count=0;
for (i = num / 2; i > 0; i = i / 2)
{
for (j = i; j < num; j++)
{
for(k = j - i; k >= 0; k = k - i)
{
if (arr[k+i] >= arr[k])
break;
else
{
tmp = arr[k];
arr[k] = arr[k+i];
arr[k+i] = tmp;
count++;
}
}
}
}
return count;
}
int getData(int arr[],int count)
{
FILE *myFile;
myFile = fopen("C:/Users/temp-01968/Desktop/arrayV3.txt", "r");
//read file into array
int i=0;
while(fscanf(myFile, "%d", &arr[i])!=EOF)
{
i++;
if(i==100)
{
return i;
}
}
return i;
}
int main()
{
int arr[100];
int k, num=-1,temp=0;
num=getData(arr,100);
printf("\nArray is: \n");
for (k = 0; k < num; k++)
{
printf("%d ", arr[k]);
}
temp=shellsort(arr, num);
printf("\n Sorted array is: \n");
for (k = 0; k < num; k++)
{
printf("%d ", arr[k]);
}
printf("\nIt took %d steps to sort the
array.",temp);
return 0;
}
(In C language) Implement Shellsort and count the number of moves on input in a given...
Create an algorithm to count the number of 1’s in a 32-bit number. Implement the program in a high level language like C or Java. It does not need to run for me, but the code should be included in a text document called FirstnameLastnameHLA3.txt along with your assignment submission. Implement the program in MIPSzy Assembly language. Use the high level code as comments to the right of the Assembly code as the textbook does. If you write that MIPSzy...
C++ LANGUAGE /** * Given an input string, count the number of words ending * in 'y' or 'z' -so the 'y' in "heavy" and the 'z' in "fez" * count, but not the 'y' in "yellow". Make sure that your * comparison is not case sensitive. We'll say that a y * or z is at the end of a word if there is not an alphabetic * letter immediately following it. * * Do not use any string...
I need help building a program on microsoft visual studio using c++ language. implement a program called "charword_freq.cpp" to determine the number of words and the number of occurrences of each letter in a block of text stored in a data file called “mytext.dat”. Define a word to be any string of letters that is delimited at each end by either whitespace, a period, a comma, or the beginning or end of a line. You can assume that the input...
In the language c using the isspace() function: Write a program to count the number of words, lines, and characters in its input. A word is any sequence of non-white-space characters. Have your program continue until end-of-file. Make sure that your program works for the case of several white space characters in a row. The character count should also include white space characters. Run your program using the following three sets of input: 1. You're traveling through another...
Design and implement a C Language program that measures the
performance of given processors.
There are several metrics that measure the performance of a
processor. We will be using the following 3 measures:
1.CPI (clock cycles per instruction) = #clock cycles
/#instructions
2.CPU execution time = #instructions x CPI x clock cycle time
.
cylce time = 1/CPU clock rate in hertz units
3.MIPS (mega instructions per second)= #instrucrions/ CPU X
1000000
Typically, processors’ performance is measured using a wide...
C++ Data Structures TREES You are to write a C++ program to count the frequency (number of occurrences) of n-grams in a text file. Definition of n-gram is simple: it is the number of consecutive letters in a given text. For example, for the word bilkent the 2-grams (bigrams) are bi, il, lk, ke, en, nt. You may ignore any capitalizations and assume that the text file contains only English letters 'a'...'z', 'A'…'Z', and the blank space to separate words....
//I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...
Write a C program which computes the count of the prime and perfect numbers within a given limit Land U, representing the lower and upper limit respectively. Prime numbers are numbers that have only 2 factors: 1 and themselves (1 is not prime). An integer number is said to be perfect number if its factors, including 1 (but not the number itself), sum to the number. Sample Inputi: 1 100 Sample Outputs: Prime: 25 Perfect: 2 Sample Input2: 101 10000...
(a) Implement Counting Inversions algorithm in C++. Provide the complete program here which returns the count and the array. (b) Test your code using this input: a = [2, 6, 1, 5, 4, 3] where array a is the list of your ranking for the given 6 songs.
Using C++ language, write a code to implement the "evaluate
function" described below using the given poly.cpp file and poly.h
header file. (ignore the other 3 functions if asked)
poly.cpp file:
poly.h header file:
You are asked to implement four functions for a data structure
used to store polynomials. The data structure used for polynomials
is a linked list that consists of terms where each term consists of
a coefficient, an exponent and a pointer to the next term. A...