Computer Science - 9210 OxfordAQA

Searching Algorithms

Aperçu

You have lost your passport somewhere in the house. One way to find it is to start in the hall and search every room in turn until you hit it. The other way, if the house is a hotel with numbered rooms and you know the number, is to walk to the middle corridor, see whether your room is above or below, and ignore half the building. Both plans find the passport. Only one of them is any use in a hotel with a thousand rooms.

Those two plans are the linear search and the binary search, and this specification wants three things from you: the mechanics of each, the ability to follow and write pseudocode for both, and a clear-eyed comparison of where each one wins. The comparison is not simply that binary is faster. Binary search demands something in return, and knowing what it demands is the difference between a two-mark answer and a four-mark one.

Objectifs

  1. Understand and explain how the linear search algorithm works.
  2. Understand and explain how the binary search algorithm works.
  3. Compare and contrast linear and binary search algorithms.

Carte mentale

Ce theme est schematise pour montrer comment les idees se relient.

Ouvrez la carte mentale dans l'application

Note de cours

A search algorithm answers a question of the form: is this value in this collection, and if so, where? The answer usually comes back as a position, and by convention an impossible position such as -1 means the value was not there at all. Almost every program you use runs thousands of searches a second, and the specification requires two of them by name: the linear search and the binary search.

Fiche complete disponible sur l'application Green Bridge

Installez l'application Green Bridge CBT sur votre telephone ou votre ordinateur pour acceder a toute la bibliotheque IGCSE : sujets d'examen, baremes, cartes mentales, fiches memo et lecons audio.

Notes de cours complètes avec diagrammes
Assistant d'apprentissage piloté par l'IA
Des examens blancs chronometres, corriges des que vous terminez
Disponible sur Android, Windows, macOS et Linux Application iOS bientot disponible

Évaluation de la leçon

Félicitations, vous avez terminé la leçon sur Searching Algorithms. Maintenant que vous avez exploré le concepts et idées clés, il est temps de mettre vos connaissances à lépreuve. Cette section propose une variété de pratiques des questions conçues pour renforcer votre compréhension et vous aider à évaluer votre compréhension de la matière.

Vous rencontrerez un mélange de types de questions, y compris des questions à choix multiple, des questions à réponse courte et des questions de rédaction. Chaque question est soigneusement conçue pour évaluer différents aspects de vos connaissances et de vos compétences en pensée critique.

Utilisez cette section d'évaluation comme une occasion de renforcer votre compréhension du sujet et d'identifier les domaines où vous pourriez avoir besoin d'étudier davantage. Ne soyez pas découragé par les défis que vous rencontrez ; considérez-les plutôt comme des opportunités de croissance et d'amélioration.

  1. Which condition must be met before a binary search can be used? A. The data must be stored in a file B. The data must be numeric C. The data must be sorted D. The data must contain no duplicates Answer: C
  2. An array holds 64 sorted items. What is the maximum number of comparisons a binary search will make? A. 6 B. 8 C. 32 D. 64 Answer: A
  3. A linear search is used on an array of 40 items to look for a value that is not present. How many comparisons are made? A. 1 B. 20 C. 39 D. 40 Answer: D
  4. In an iterative binary search, which assignment is made when the middle element is smaller than the target? A. First becomes Middle B. First becomes Middle + 1 C. Last becomes Middle D. Last becomes Middle - 1 Answer: B
  5. Which of the following is an advantage of a linear search over a binary search? A. It makes fewer comparisons on large data sets B. It works on data that is not in any order C. It halves the search area at each step D. It can only be used on arrays Answer: B

Travaillez ces questions dans l'application

Travaillez ces questions dans l'application

Pratiquez des questions blanches

Vous voulez vous entraîner sur des questions blanches sur Searching Algorithms ? Téléchargez lapplication Green Bridge CBT pour accéder à des questions blanches et à des évaluations complètes sur ce sujet.

Téléchargez l'application sur Google Play.

Tout ce dont vous avez besoin pour exceller au JAMB, WAEC et NECO.

Green Bridge CBT Mobile App
Assistant de chat d'apprentissage personnalisé par IA
Plus de 200 000 questions d'examen IGCSE, JAMB, WAEC et NECO.
Plus de 1200 notes de cours
Assistance Hors Ligne - Apprenez à Tout Moment, Partout
Horaire du Pont Vert
Résumés littéraires et questions potentielles
Suivez vos performances et votre progression
Explications Approfondies pour un Apprentissage Complet