2.3 - Algorithms
No description yet. This curated deck is ready for daily study.
Card preview (12)
What is a systematic approach to problem solving?
• Reaching a solution by identifying the individual steps required. • a set of rules allows an algorithm that is followed to be precisely lead to an answer. • Allows developers to automate solutions.
What does abstraction allow?
It allows us to think about what is important and what is not.
What 4 steps should you take for a systematic approach?
• Break the problem down. • Think about what data is important or not important. • Consider relevent data structures. • Tackle each part of the problem step by step.
What is an algorithm? (Simplified)
A sequence of steps followed in order to solve a problem.
How does a linear search work?
It starts at the first item in the list and checks each item one by one to find an item in a sorted or unsorted list.
What are the 4 characteristics of a linear search?
• Doesn’t require the data set to be in order e.g settings file. • Can be efficient for smaller data sets. • Is inefficient for large data sets. • Easiest searching algorithm to implement but usually the most ineffient.
What is a typical use of a linear search?
The find-and-replace function in a word processor.
When is an algorithm correct?
If the result is correct for all input instances.
What 4 things does a linear search algorithm have to do?
• Be able to locate an item in a data set (if it exists). • Be able to locate the item regardless of whether the data set is sorted or unsorted. • Run without crashing even if the item being searched for doesn’t exist in the data set. • Check each item sequentially, starting with the first item.
What is a binary search algorithm?1
An efficient algorithm for finding an item in a sorted data set. It starts at the middle item in the list and repeatedly divides the list in half.
What are the 2 characteristics to be a binary search?
• Requires the data set to be sorted first (e.g. numerical or alphabetical order) • Is efficient for large data sets.
When would you use a binary search?
When you need to search for an item in a large, sorted data set. (e.g. online dictionary in alphabetical order).