Convert the Convergent-Pointer Algorithm pseudo code to C code. Use exact variables and make no modifications.

Hey,
Below is the answer to your question
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
int main()
{
int n;//define n
printf("Enter n: ");//print
scanf("%d",&n);// input n
printf("Enter n data items\n");
int data[n];
int i;
for(i=0;i<n;i++)
{
scanf("%d",&data[i]);////input data itemss
}
int legit=n,left=1,right=n;// define legit, left and right
while(left<right)// loop while left is less than right
{
if(data[left]!=0)// element at left is not 0
left=left+1;// increment left
else
{
legit--;// reduce legit by 1
data[left]=data[right];// copy right to left
right--;// reduce right by 1
}
}
if(data[left]==0)// if element at left is zero
legit--;// reduce legit by 1
return 0;
}

Kindly revert for any queries, will be waiting for your positive feedback.:)
Thanks.
Convert the Convergent-Pointer Algorithm pseudo code to C code. Use exact variables and make no modifications....
Question 1. Below is the pseudo code for a divide and conquer algorithm that finds the minimum value in an array. Suppose that the input array, A, is of size n, analyze the computational cost of this algorithm in the form of Tin) and prove your conclusion findMin (A, left, right) if (left == right) return Alleft) center - (left + right) / 2 return min (findMin (A, left, center), findMin (A, center + 1, right)
Title Algorithms Functional Requirements and Marks using c++ Write a pseudo-code algorithm for the following problems: Detect if three angles can make a triangle. (1) Hint: In a triangle, the sum of all angles is 180. Switch the value of two numbers (1) If a=2 and b=5, we want to have a=5 and b=2 at the end. Remember that a=b will result in the old value to of a to get lost. Receive a set of numbers and find...
The following gives the backtracking algorithm in pseudo-code for a constraint satisfaction problem, where U is a set of unassigned variables, and A is the current partial assignment search(U,A) if (U) return A; remove a variable X from U; for (each value a in X's domain) if (X-a is consistent with A) add X=a to A; res - search(U,A) if res !# false return res remove X=a from A; return false; A magic square of size N is an N...
I currently have a code that I have written that uses global variables. My professor wants me to rewrite this code so that it uses the return function instead. I dont understand why because it works the same, but I am not great at using return and barely understand it. here is my code. This is in Python3 #Created an empty dictionary using variable #grocery_item grocery_item = {} #Created an empty list for using variable #grocery_history grocery_history = [] #This...
/* FILE NAME: Class{aSet}.cpp FUNCTION: A template class for a set in C++. It implements all the set operations, except set compliment: For any two sets, S1 and S2 and an element, e A. Operations which result in a new set: (1) S1 + S2 is the union of S1 and S2 (2) S1 - S2 is the set difference of S1 and S2, S1 - S2 (3) S1 * S2 is the set intersection of S1 and S2, S1 * S2 (4) S1 + e (or e +...
:)
Problem: ??? Your task: implement in CH the algorithm solution shown below. Then analyze it and explain, using just one or two sentences, what it does. Write this explanation as a comment at the top of your program. This explanation will be worth 5 points of your total grade. Do not be too detailed (for example, do not write it opens a file and then declares variables, and then reads from a file...), it should look like the problem...
Below is the code for two programs in C language, I was trying to make proper comments within the code so that someone can understand it. Please review the comments within the code and let me know if it makes good sense. Let me know if I need to make any changes to the comments! Thank you. PROGRAM 1: /* program calculates harmonic mean for 10 numbers entered by the user */ /* if illegal value (x<0) is entered, the...
Create a #define called MAPSIZE. Set to 10. Create global variables DirectionsFilename and MapFilename. Use char arrays and set them to nulls by using {}. Create a structure called RowCol that has two int members called row and col to hold the row and column. Function MoveNorth should have a return value of void and a parameter of a pointer to RowCol. { To move north, you need to subtract 1 from PositionPtr->row. Before doing so, you need to check...
Please help me finish my code. Before the final pause in the main function, create an ArrayList of another type such as double, char, short, bool, float, etc. Your choice. Add five data items to your array as we did for the int and string array lists. Print them out with a for loop as we did before. Print out the count and capacity of your new array list. Source.cpp #include #include #include #include "ArrayList.h" using namespace std; /// Entry...
Convert into pseudo-code for below code =============================== class Main { public static void main(String args[]) { Scanner s=new Scanner(System.in); ScoresCircularDoubleLL score=new ScoresCircularDoubleLL(); while(true) { System.out.println("1--->Enter a number\n-1--->exit"); System.out.print("Enter your choice:"); int choice=s.nextInt(); if(choice!=-1) { System.out.print("Enter the score:"); int number=s.nextInt(); GameEntry entry=new GameEntry(number); ...