Searching algorithms

EasyMediumHard
12
Question 1
Hard

Extend the program in Figure 1 to implement a linear search. Your answer must be written in C#.

string[] missions = {"Mercury", "Gemini", "Apollo",
                     "Skylab", "Voyager", "Artemis"};

Figure 1

The program should ask the user to enter a space mission name and perform a linear search on the array missions to check if that mission is present in the list.

The program must:

  • prompt the user to input a mission name to search for
  • output the message Mission Located if the mission is present in the array
  • output the message Mission Unknown if the mission is not present in the array

You must write your own linear search routine and not use any built-in search functions or methods available in C#.

You should use meaningful variable names and correct C# syntax in your answer.

[7]

Searching algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Searching algorithms