1/49
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Algorithm
A step-by-step set of instructions that can be followed to solve a problem.
Computer Program
An implementation of an algorithm using a specific programming language.
Decomposition
The process of breaking down a problem into smaller, more manageable sub-problems that each accomplish a specific task.
Abstraction
The process of removing unnecessary details to focus on the essential parts of a problem.
Pseudocode
A way of describing algorithms using structured, plain English.
Program Code
Code written in a specific programming language.
Flowchart
A diagram that represents an algorithm using symbols.
Efficiency
A measure of how well an algorithm performs in terms of time or steps.
Searching Algorithm
A method used to find a specific value (target) in a list of data.
Linear Search
A search method that checks each item one by one.
Binary Search
A fast search method that works on sorted data by halving the search range on each iteration.
Sorting Algorithm
A method used to arrange data into a specific order, usually ascending or descending
Bubble Sort
A simple sorting algorithm that repeatedly swaps adjacent items.
Merge Sort
A fast, efficient sorting algorithm that uses divide-and-conquer.
Divide and Conquer
The process of repeatedly splitting a dataset into smaller datasets and so on
Why is binary search better than linear search for a large array?
Binary search is more efficient on average
A linear search would be less efficient because it must check all items
What are advantages and disadvantages of bubble sort and merge sort?
Bubble
A: simpler to code
A: quicker to sort smaller list
D: slower to sort larger arrays
D: less efficient
Merge
A: more efficient
A: quicker to sort larger arrays
D: harder to code
What is an array
a data structure that stores a collection of items, typically of the same data type, accessed using an index (one- and two-dimensional are required).
a collection of similar data items stored under a single name
each item is accessed using an index
Syntax Error
An error in the grammar or rules of the programming language, preventing the code from being translated or run
Advantages of decomposition?
It makes complex problems easier to understand
Easier to design and implement solutions for
Easier to debug and maintain
Allows sub-problems to be split across a team of developers
Advantages of abstraction?
focus on essential aspects of the problem
time is not wasted on developing unnecessary components
What factors affect speed of sorting algorithms?
size of data set
nature of data
algorithms design (bubble sort slower/merge sort faster; linear search slower/binary search faster)
Efficiency increases when?
number of steps is lower
algorithm avoids unnecessary operations
Linear search vs Binary search
Linear
any data (unsorted)
slower (checks one by one)
simple
Binary
sorted data
faster (halves list each step)
more complex to implement
How does linear search work?
start at first item in list
check each item one by one until target is found or end is reached
How does binary search work?
can only be used on sorted lists
repeatedly divides list in half, comparing middle element to target (divide and conquer)
narrow search range until item is found (as middle element) or the list cant be divided further
How does bubble sort work?
repeatedly goes through list, comparing 2 adjacent items and swapping if they are in wrong order
this is done as multiple passes until no swaps are needed - indicating the list is sorted
Characteristics of bubble sort
simple to understand and implement
inefficient for large data sets as it requires multiple passes
takes a long time if list is in reverse order
How does merge sort work?
divide and conquer algorithm
continuously splits the list in half until each sublist has one item
merge sublists back together in correct order
Characteristics of Merge Sort
faster than bubble sort for large datasets
uses more memory due to recursion and temporary lists
more complex to implement
Why do data types matter?
help computer understand how to store and manipulate data
choosing correct data types ensures the program runs efficiently and without errors
some operations are only valid for certain data types
What is a subroutine?
a block of code given a unique name that can be called multiple times
may include parameters and return values
Why are meaningful identifier names important?
improves readability and understanding
Characteristics of Array
items must be same data type
indexing starts at 0 (for most languages)
Array vs Records
array
data types - all elements must be the same
accessed by - index
suited for - list of similar items
records
data types - can be different
accessed by - field name
suited for - grouping related attributes
What is structured programming?
method of writing clear, modular, and easy-to-understand code using 3 core principles:
sequence
selection
iteration
Define the 2 types of subroutine
procedure - performs an action
function - performs an action and returns a value
Characteristics of local variables
declared inside a subroutine
can only be accessed within parameters of the subroutine
only exist while the subroutine is executing
Advantages of Subroutines
can be developed in isolation/independently/separately
easier to discover errors
easier to understand program code
easier for a team of programmers to work together on a large project
easier to reuse code
Data validation checks
length check
presence check
range check