Programming:theory Flashcards
Describe the halting problem
Determining, given a program and input, whether or not the program will halt
{determining if a program will halt without running the program for a particular input}
Why can’t the halting problem be simulated with a turning machine?
The halting problem is non-computable, a program cannot be written that determines whether a given algorithm will halt for a specified input.
What are the components of a turing machine?
-infinite tape
-read/write head
-control unit
-finite set of states
-transition rules
-set of accepting/ halting states
What is a UTM?
Universal turing machine
What is a UTM?
-UTMs can simulate the behaviour of any other turing machine, and so can compute any computable sequence.
-Can act as an interpreter, taking data, programs or any other turing machine as an input
Why are UTMs more powerful than any other computer?
Because it has an infinite amount of memory/tape
What is an advantage of using constants?
-speed increases when run
-easier to read and maintain
-values only need to be assigned
Define a global variable
A variable that can be referenced/accessed from any point in the program.
Define a local variable
Can only be referenced/accessed within the subroutine it is defined in
What is an advantage of local variable usage?
-avoids redundant memory usage, as variable value is no longer stored once subroutine is finished executing
define the term record
A collection of fields, each of which could have a
different data type. You can think of a record as a row
from a table
define a pointer or reference
A way of storing memory addresses
what are the key features of an array?
-finite
-indexed
-same data type
what are user defined data types?
derived from existing data types in order to create a customised data structure
why are meaningful identifier names important?
-easier for others to understand
-means maintenance is easier
-collaborative programming is easier
What is a constant?
a variable that once defined, does not change its value
what is the python function for returning the length of a value?
len()
what is the python function for determining the position of a specified character?
rfind()
index = string_variablename.rfind(character)