Lexicographical order, assignment help

Other

1-

Write the program that asks the user to enter 10 names of cities (one name at a time) to be stored in an array, sorts the resulting list of city names lexicographically and displays the sorted list to the console.

Note: Lexicographical order is a generalization of the way the alphabetical order of words is based on the alphabetical order of their component letters. It is also known as dictionary order.

Hint: Comparing two words lexicographically can be done by using “<” and “>” for C++ strings.

Example:

Original List: Paris, Washington DC, London, Tokyo, Madrid, Rio di Janeiro, Brussels, Ankara, Rome, Amsterdam

After applying the Lexicographical order, the list will be become:

Resulting List:Amsterdam, Ankara, Brussels, London, Madrid, Paris, Rio di Janeiro, Rome, Tokyo, Washington DC

If the first letters of the two cities are the same, you should compare the next ones.

Original List:Ankara, Amsterdam

Resulting List:Amsterdam, Ankara

2-

You are given the following source code to search for a number in an array

#include <iostream>

using namespace std;

int search(int sa, int list[ ], int size)

  bool notFound = true;

  int position = -1;

  int k = 0;

  while (k<size && notFound)

  {

  if (list[k] == sa)

  {  notFound = false;

  position = k;

  }

  k++;

  }

  return position;

}

 

int main( )

{

int searchArg = 17; 

int myList[10] = {16,14,54,23,8,12,17,36,11,22};

int pos;

// call Search to find the value’s position

pos = search(17,myList,10);

cout << “Search key was found at index “ << pos << endl;

Modify search function and the main method to search for a string value, entered by the user,in a string array, instead of searching for an integer value in an integer array.

This is the string list to use for test:

List: Rome, Ankara, Brussels, London, Madrid, Paris, Rio di Janeiro, Tokyo, Washington DC

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational