Planning and Designing Software Solutions Flashcards
What is an algorithm
a method of solution for a problem, it describes the steps taken to transform inputs into the required outputs.
What a the three control structures in an algorithm
sequence
decision
repetition
what are the two ways we can write algorithms
Flowcharts and Pseudocode
what is the top-down design
it is the process of breaking down a problem into its component parts.
what is stepwise refinement
the process of breaking down a component or module until it is a level where the parts can be implemented in a programming language, each level or step is a refinement of the previous level.
what is the difference between Functions and procedures
Functions retruun one result via the function itself, and are used as parts of experssions, where as a procedure return their results via parameters and their calls are statements on their own.
what Is Big O notation
it is used to compare algorithms, it describes the performance or time complexity of algorithms to the number of data items being processed.
What are common Big O classifications
O(1): the processing time is constant regardless the number of data items. example (display the first item in an array regardless the size of the array)
O(log n): Processing time increase slower as n increases in size. example (Binary search)
O(n): Processing time is proportional to the number of data items. example (linear searches)
O(n log n): processing of each data item is an O(log n) process, as there a n data items then the time complexity is O(n log n). example (Quick sort and merge sort)
O(n^2): processing of each data item potentially requires examining all other data items. example (bubble sort, insertion sort and selection sort)
O(2^n): processing time increases exponentially as the number of data n increases.
What is a linear search
It is a search that involves examining items one at a time from the beginning at the start of the list and continuing till the end of the list.
What is a Binary search
The search involves splitting the list into two parts each time a comparison is made. As the list must have been previously sorted, one half of the list can be discarded after each comparison is made. Eventually the required item will be found
Does a Linear search need to be sorted for it to work
No
Does a Binary search need to be sorted for it to work
Yes
What are the three sorting methods
Insertion Sort
Selection Sort
Bubble Sort
What is the insertion sort
Insertion sorts involve looking through a sorted list for the correct position for a new item and inserting the item into that position. This sort is particularly useful for when a small number of items needed to be added to an already sorted list.
What is the selection sort
it is essentially a repetition of linear searches to find the smallest (or largest) item in a list. Each time the search is complete, the item found is moved to the end of the sorted list. This type of sort is rather more intuitive for humans as it is a strategy often employed when sorting things by hand.
What is bubble Sort
It is a sorting method that is sorted by considering the order of individual item pairs and swapping them if they are out of order. This results in items moving one position at a time towards their final position.
what is a parameter
it is a value or variable passed to or returned from a function or procedure. Parameters are often called arguments.
What is a Swap in an Algorithim
A swap is used to exchange the content of one variable with that of another. A temporary variable and three steps are generally required.
example:
Temp = X
X = Y
Y = Temp
what is a string data type
It is a data type used to hold characters or texts. They are essentially an array of characters.
Whar are some routines for processing strings
Extracting
deleting
inserting
What is extracting
It is essentially making a copy of a section of the original string; the original string remains intact. There are three pieces of information required to achieve the extraction which is the original/intial string; the starting point of the extraction and either the length of the extraction string or end point of the string.
What is deleting
It is essentially cutting a portion from the string. The original string is reduced in length by the number of characters that have been removed. Three identical parameters are required: the original or initial string; the starting point for the deletion; and either the length of the string to be deleted or the finish point of the string to be deleted.
What is inserting
it is a string of characters into another string of characters that involves the splitting of the initial string into two parts and then joining the first part of the string with the insertion string and the final part of the initial string. . Parameters required to complete this process are the start position for the insertion, the insertion string, and the main or initial string.
what is an index
an Integer value used to denote a particular data item held in an array. Also called a dimension or subscript.
what are the common data structures
Multi dimensional arrays
Single dimensional array (just an array)
arrays of records
Records