Algorithm Design Basics

ReliableNihonium avatar
ReliableNihonium
·
·
Download

Start Quiz

Study Flashcards

10 Questions

What is the common pattern found in computations such as finding the total of physics marks or determining the number of occurrences of a word in a paragraph?

Repetition

What is the term used to describe the pattern of doing something repetitively, such as arranging students by their heights?

Iterator

What is the step involved in setting up the required context for the iterator to function?

Initialisation

What is the purpose of maintaining additional cards in an iterator?

To write down what we are seeing as we go through the repetition

What is the importance of knowing when to stop the iterator?

To ensure the repetition stops when the desired result is achieved

What is the first step in examining a data element within a dataset?

Picking one element to work on.

What happens to the extracted table row after it is examined?

It is marked as seen.

Why is altering the original data items from the dataset not considered in this book?

It can lead to many inadvertent errors.

What corresponds to picking a card in a tabular dataset?

Extracting one row of the table.

Why can't we simply repeat the previous step in examining the dataset?

We need to do something with the examined element before moving on to the next one.

Study Notes

Iterator Pattern

  • The iterator pattern involves repetition, such as finding the total of physics marks of all students or counting the occurrences of a certain word in a paragraph.
  • To arrange students in a class by their heights, an iterator pattern can be used by repeatedly selecting two students who are out of order and asking them to exchange their places.

Initialization

  • Initialization involves setting up the context for the iterator to function, such as arranging cards in a single pile or maintaining other cards to write down what is seen during the iteration.
  • The cards can be in any order at the start, but may need to be in a specific order depending on the dataset.

Picking and Examining One Data Element

  • Within the repeated step, one element is picked to work on, such as the top card from an ordered pile or any card from an arbitrarily ordered pile.
  • The picked card is kept aside for examination, and specific fields in the card may be read out and their values processed.

Marking the Data Element as Seen

  • Once the chosen element is examined, it is marked as seen and set aside, and the next data element is processed in the same way.
  • The process can be repeated many times, but it is important to keep track of the examined elements to avoid revisiting them.

Learn about the fundamental concepts of algorithm design, including repetition and iteration. Understand how to apply these concepts to real-world problems, such as calculating totals and counting occurrences.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Generative Design Concepts Quiz
3 questions
Algorithm Design and Analysis Quiz
5 questions
Algorithm Design Principles Quiz
10 questions
Algorithm Design and Analysis Quiz
18 questions
Use Quizgecko on...
Browser
Browser