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
Lady_Fox [76]
4 years ago
14

supppose we already have a list called words, containing all the words(i.e., string).Write code that produce a sorted list with

all duplicate words removed. For example, if words ==['hello', 'mother','hello','father','here','i','am','hello'], your code would produce the list ['am','father','hello','here','i','mother'].
Computers and Technology
1 answer:
alexandr402 [8]4 years ago
4 0

Answer:

I will code in Javascript.

<em>//define and initialize both arrays.</em>

var words = ['hello', 'mother','hello','father','here','i','am','hello'];

var sortedList = [];

 

 for ( var i = 0;  i < words.length ; i++ ){  <em>//loop used to go throght the words</em>

   var duplicated = false;  <em>// boolean used for detect duplicates</em>

   for ( var j = i + 1;  j < words.length ; j++ ) {  <em>//loop used to compare with other words</em>

     if( words[i] == words[j] ) {  <em>//if the word is duplicated, duplicated becomes true.</em>

       duplicated = true;

       break;

     }

   }

   if (! duplicated) {  <em>//if at the end of the loop of each word duplicated is false, then the element is pushed into sortedList.</em>

     sortedList.push(words[i]);    

   }

 }

 sortedList.sort(); <em>//when the loop is finished, use the Javascript method to sort an array.</em>

You might be interested in
What message will scroll?
Tasya [4]
Yeah there no picture
6 0
3 years ago
Read 2 more answers
A CRS is most commonly used for
BigorU [14]
It is mostly used to store and retrieve information
6 0
4 years ago
What word is used today to refer to network-connected hardware devices?.
lions [1.4K]
Th answer to your question is Endpoint
5 0
3 years ago
What is the result of adding 1234.5674 and
Charra [1.4K]

Answer:

C. 1280.245

Explanation:

1234.567 + 45.678 = 1280.245

3 0
3 years ago
Create a C++ program that declares, initializes, and outputs the values contained in a two-dimensional array
Kazeer [188]

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variables

int r_size,c_size;

cout<<"enter the number of row:";

// read the value of row

cin>>r_size;

cout<<"enter the number of column:";

// read the value of column

cin>>c_size;

// create a 2-d array

int arr[r_size][c_size];

// read the value of array

cout<<"enter the elements of array:"<<endl;

for(int x=0;x<r_size;x++)

{

for(int y=0;y<c_size;y++)

{

cin>>arr[x][y];

}

}

cout<<"elements of the array are:"<<endl;

// print the array

for(int a=0;a<r_size;a++)

{

for(int b=0;b<c_size;b++)

{

cout<<arr[a][b]<<" ";

}

cout<<endl;

}

return 0;

}

Explanation:

Here we have demonstrate a 2- dimensional array. In which, how to read the elements and how to print elements of array.Read the value of row and column from user.Create a 2-d array of size r_sizexc_size. then read the elements of array either row wise or column wise. Then print the elements.To print the elements, we can go either row wise or column.

Output:

enter the number of row:2

enter the number of column:3

enter the elements of array:

1 2 3

2 3 4

elements of the array are:

1 2 3

2 3 4

8 0
4 years ago
Other questions:
  • if you want to presents slides to fellow sudents or co-workers witvh productively software should you use to create them?
    6·1 answer
  • Which of the following is not hardware? Question 7 options: A) Wireless network router B) Printer C) Virus Scanner D) Flat-panel
    11·1 answer
  • Why are computers assigned IP addresses
    15·1 answer
  • Deon plans to ride a 15 mile bicycle trail.his if his average is 20 miles per hour
    15·1 answer
  • When was the very first computer made??
    5·1 answer
  • Write an application program in C++ to implement a class Fibonacci to print Fibonacci series upto N using member function series
    9·1 answer
  • What is a transducer? A. an energy-converting device B. a sensing device C. a robot movement D. a signal display unit
    8·1 answer
  • I need this answer right away!
    13·1 answer
  • Write a calculator program that will allow only addition, subtraction, multiplication &amp; division. Have the
    7·1 answer
  • The Monte Carlo method is commonly used to approximate areas or volumes of shapes. In this problem, we will use Monte Carlo to f
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!