Skip to content

Course home

Searching algorithms

Searching algorithms

EasyMediumHard
12
Question 1

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]
Markscheme

Searching algorithms Questions

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

33 exam-style questions on AQA GCSE Computer Science Searching algorithms. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank