1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sattari [20]
3 years ago
15

Find the Nearest Repeated Entries in an Array People do not like reading text in which a word is used multiple times in a short

paragraph. You are to write a program which helps identify such a problem. Write a program that takes as input an array and finds the distance between closest pairs of equal entries. For example if s = <"All, "work", "and", "no", "play", "makes", "for", "no", "work", "and", "no", "fun", "and", "no", "results">, then the second and third occurrences of "no" is the closest pair.
Computers and Technology
1 answer:
e-lub [12.9K]3 years ago
3 0

Answer:

The following program is written in C++ Programming Language.

#include <iostream>   //header file

#include<cstring>    //header file

using namespace std;   //using namespace

int main()    //main function

{

int num;

cout<<"Enter the no. of words: ";   //print message

cin>>num;    //get input from the user

char input[num][10];

int visited[num]={0};

for(int i=0;i<num;i++)

{

cin>>input[i];

}

for(int i=0;i<num;i++)

{

int distance=1000,left,right,prev,flag;

left=i;

prev=i;

if(visited[i]==0)

{

flag=0;

for(int j=i+1;j<num;j++)

{

if(strcmp(input[j],input[i])==0)

{

if(j-prev<distance)

{

left=prev;

right=j;

distance=j-prev;

}

prev=j;

visited[j]=1;

flag=1;

}

}

if(flag==1)

cout<<"The closest distance between the pair of "<<input[i]<<" is "<<distance<<" and pair is ("<<left<<" , "<<right<<")"<<endl;

}

}

return 0;

}

Explanation:

Here, we define two header file <iostream> and <cstring> and using namespace "std".

Then, we define the main() function.

Then, we declare an integer variable "num"  in which we get the input from the user.

Then, we initialized the two array variable first is character array "input" and integer array visited and after all, we follow the instructions.

You might be interested in
Create a single line comment that says ""Print results to screen""
levacccp [35]

Answer:

//""Print results to screen""

Explanation:

In c,c++,java,javascript // is used for the single line comment.

syntax:- // comment.

Whatever text that is followed after // is commented means this line will not get executed by the compiler.

Comments are used to explain the code to other person who is working on the code or trying to understand that code.

6 0
3 years ago
A network administrator notices that some newly installed Ethernet cabling is carrying corrupt and distorted data signals. The n
OleMash [197]

Answer: EMI(Electromagnetic interference)

               RFI(Radio frequency interference)

Explanation: Electromagnetic interference is the emission of the electromagnetic signal that can disturb the working of the other device.It invokes the disturbance that can create error, under-performance mechanism,distortion etc in the equipment.

Radio-frequency interference(RFI) is the radio-frequency signal that interferes the other device by creating noise and distortion. This leads to breaking of the operation and data error.

Other options are incorrect because cross talk is referred as undesired communication between signal ,attenuation is the degradation in the  amplitude of any signal and extended length of cabling is increasing the length of the cable.Thus the correct answer is RFI and EMI.

4 0
4 years ago
Why do you think you are ready to handle the high school type of education and atmosphere? (in complete sentences)​
sertanlavr [38]

Answer:

I'm already in high school but at first, I was scared for my life literally. It wasn't what I expected it to be, though. Everyone was super nice to me and has been ever since I started. Turns out, high school is amazing.

Explanation:

5 0
3 years ago
A red bullet in a microflow indicates: a. that the microflow has been completed b. that the microflow contains errors c. that on
Viefleur [7K]

Answer:

d. an end point of the microflow mendix

Explanation:

In Computer programming, Microflows can be defined as a visual representation of textual program codes based on the Business Process Model and Notation (BPMN), it enables users to express the logic of application.

It is capable of performing various actions such as creating and updating objects, showing pages and making choices.

Microflows cannot be used in offline apps as it basically runs in the runtime server.

A red bullet in a microflow indicates an end point of the microflow mendix.

8 0
3 years ago
A large data set contains information about all students majoring in computer science in colleges across the United States. The
Vsevolod [243]

Answer:

The correct option is B

B. How many states have a higher percentage of female computer science majors than male computer science majors attending college in that state?

Explanation:

A.We can not analyze that students majoring in computer science tend to have higher grade point averages than students majoring in other subjects because we are only given data sets about computer science not about other majoring subject students

B. Because data set contains attributes of gender and state so we can easily analyze that how many states have a higher percentage of female computer science majors than male computer science majors attending college in that state.

C.We can not analyze that what percent of students attending college in a certain state are majoring in computer science because data sets doesn't contain any information about students other computer science students.

D. We can not analyze that which college has the highest number of students majoring in computer science because data sets doesn't contain attribute of college name.

4 0
3 years ago
Other questions:
  • Why is it best to run antivirus scans when the computer isn't being utilized?
    7·1 answer
  • How is the numeric string that makes up a digital signature created?
    5·1 answer
  • What is virtual office?
    11·1 answer
  • What is the traditional computer architecture long-supported by windows?
    6·1 answer
  • In which of the following careers are you most likely to do an apprenticeship?
    14·2 answers
  • Which of these statements best compares P waves and S waves of an earthquake?
    5·1 answer
  • I have 2 questions How do i send a picture for someone to answer the hw?
    6·2 answers
  • the ratio of length, breadth and height of a room is 4:3:1. If 12m^3 air is contained in a room, find the length , breadth and h
    14·1 answer
  • What can a user modify on a business card using the Edit Business card in the dialog box?​
    8·1 answer
  • What does a companys code of ehtics cover
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!