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
How has technology fragmented the audience for sports and entertainment<br> commodities?
PSYCHO15rus [73]

Technology has indeed made to audience of sports and entertainment increase rapidly.

Explanation:

Years passed, one will have to go to a sports stadium or an event center before he/she can access sports or entertainment.

But in recent years the introduction of internet has made every person who wishes to, to enjoy entertainment or sports in the comfort of his/her home or wherever he/she may find him/her self.

It has even given the opportunity for those who are not able to make time as and when the event is going on to watch or listen to it later.

The internet is one of the powerful tools that help individuals enjoy entertainment and sports across the world.

The invention of television and radio has also increased the ability for a sportsman or an entertainer to get more fans in just a short period of time.

4 0
3 years ago
You are reviewing the style sheet code written by a colleague and notice several rules that are enclosed between the /* and */ c
Flauer [41]

Answer:

Nothing will happen.

Explanation:

The rules written between /* and */ will be ignored because /* and */ are the standard way of writing comment in a style sheet code. So, whatever fall in between them will be ignored during rendering of the page.

7 0
3 years ago
Write a function endpoints that takes a list of numbers (eg. [5, 10, 15, 20, 25]) and returns a new list of only the first and l
Ne4ueva [31]

I included a picture of my code below. Best of luck with your assignment.

5 0
3 years ago
What is a programming language?
xenn [34]
D is the answer cause coding
5 0
3 years ago
Read 2 more answers
An example of software is a _____.<br><br> spreadsheet<br> mouse<br> track ball<br> printer
algol13

An example of software is a spreadsheet :)

8 0
3 years ago
Other questions:
  • The two types of objects responsible for collecting data are
    14·1 answer
  • Consider the concept of cultural lag. Identify two American values that are “lagging.” What are three norms that are lagging? Ho
    11·1 answer
  • Troubleshooting a printer that does not work includes a. connecting the printer to your computer b. checking to see if there is
    13·1 answer
  • How much health did a supply drop balloon originally have??
    7·2 answers
  • Windows 1.0 was not considered to be a "true" operating system but rather an operating environment because _____.
    13·1 answer
  • Which two tasks are associated with router hardening? (choose two.)?
    6·1 answer
  • When a person bullies someone using technology, it's called:
    9·2 answers
  • What is data? why is it important to collect data ? explain the points.​
    10·1 answer
  • Consider the following code: def tryIt(b): for i in range(len(b)): b[i] = b[i] + 100 #***********MAIN************ x = [] x = [56
    8·1 answer
  • Remember not to use tools that are ________ in any way.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!