Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
220 Cards in this Set
- Front
- Back
Data Structure |
Method of representing logical relationships between individual data elements. |
|
Synonym for Programming |
Coding |
|
Is Python an interpreter or a compiler |
Interpreter |
|
What is the relationship between data structures and instruction code? |
Data structure can compute addresses of data items with arithmetic operations. Linked data structures are storing addresses of data items within structure itself. |
|
Is an array a data structure? |
Yes |
|
What operations can be done on data structures? |
Organize Data Access Data Manipulate Data |
|
Linear Data Structure |
Values stored in sequence and in linear fashion |
|
Non Linear Data Structure |
Values stored in non sequential matter |
|
Homogeneous Data Structure |
Values with same type of data stored (arrays) |
|
Non-Homogeneous Data Structure |
Values with different types of data grouped (classes) |
|
Dynamic Data Structure |
References, pointers, size, memory locations can be changed during program execution. |
|
Static Data Structure |
Variable remains in the memory throughout the program |
|
Name 3 of the most common Python data structures |
List Tuple Dictionary |
|
List |
List of values where each value is an element and is numbered started from 0. [1] in [32,45,23] would be 45. |
|
Tuple |
Are like lists, except values cannot be changed. |
|
Dictionary |
Contains an index of keys and definition/value for each key (kind of like ordered pairs). |
|
What bracket type do you use for lists? |
[] |
|
What bracket type do you use for tuples? |
() |
|
What type of brackets do you use for a dictionary? |
{} |
|
Simple Data Structure |
A sequence, an abstract data type, where each element is assigned a number for its position. |
|
Name some operations you can perform on sequences |
Indexing Slicing Multiplying Adding Checking for membership (ISMAC) |
|
What is an instance of a list? |
Each instance of a value is called either an item, entry or element and it is a computer representation of mathematical concept of infinite sequence. |
|
Array |
Data structure that stores homogenous values |
|
Array Module |
Methods for creating arrays of fixed types with homogeneous data types |
|
List vs Array |
Lists only allow sequential access, array allows random access. Lists are collections of heterogenous elements, arrays are homogeneous. |
|
Are arrays slower than lists? |
Yes |
|
Where do you store data when a program is run? |
Main memory, aka RAM. |
|
What happens to volitile memory when program terminates |
It disappears or deletes itself. |
|
How is data stored permanently? |
In a file. |
|
Where are files stored? |
On secondary storage (hard drives). |
|
Is secondary storage volitile or non-volitile |
Non-volitile |
|
How are files organized and identified? |
Organized into directories and identified by unique name. |
|
Field |
Basic element of data made up of characters |
|
Record |
Organization of related fields treated as a unit, row |
|
File |
Collection of similar records, a table |
|
Database: |
Collection of related data |
|
Contiguous Logical Address Space |
Space that the OS makes through abstractions of physical properties of its secondary storage devices to define a logical storage unit called a file. |
|
Why is a file an abstract data type? |
Files are based on its data items and associated operations |
|
Name a file's attributes |
Name Type Location Size Protection Time, Data, USER ID |
|
How do you open a file? |
open(filename, mode) |
|
What does file.name do? |
Returns name of file |
|
What does file.closed do? |
Returns true if file is closed |
|
What does file.mode do? |
Return access modef il was opened with |
|
What does file.softspace do? |
Return false if space explicitly required with print |
|
what does file.read(n) do? |
Returns how many characters (n) you want to read from file |
|
What does file.readline() do? |
Reads one line from file |
|
What does file.readlines() do? |
Reads all lines from file |
|
What does file.close() do? |
Flushes any unwritten information and closes file object |
|
What does file = open("file.txt", "w") do? |
Creates a file |
|
What does the following code do: for line in file: print line |
A loop that reads lines |
|
What does file.write("string") do? |
Writes to a file |
|
Why should you close a file? |
Frees up any system resources taken by open file. |
|
ADT |
Abstract Data Type |
|
What is an Abstract Data Type |
Mathematical model for certain class of data structure that have similar behaviour. |
|
Abstract Data Type vs Data Structure |
ADT is more logical, thought of as a picture of the data and the operations to change it. Data structure is more concrete, where it can be implemented and used within an algorithm. |
|
What is a pointer? |
Programming language primitive whose value refers directly to another value stored elsewhere in the memory using its address. |
|
What are some linear data structures? |
Array Linked List Stack Queue |
|
Array |
Collection of data of same type stored in consecutive memory location |
|
Linked List |
Collection of data of same type, but not stored in consecutive memory |
|
Stack |
last-in-first-out data structure |
|
Queue |
first-in-first-out data structure |
|
Singly Linked List |
Linked list that contains nodes which have two fields. Integer value and next node, which points to the next node in the line of nodes. |
|
Doubly Linked List |
Linked list that has a second link field beside the next node that points to the previous node in sequence. |
|
Graphs |
A way to represent finite set of data that has a relationship between pairs of elements |
|
Trees |
Special class of graphs that are used to represent data that has some hierarchical relationship among data elements |
|
Search Trees |
Data values at each node are stored form some ordered set, in such a way that in-order traversal of the trees visits nodes in ascending order of stored values |
|
Binary Trees |
Each node branches into two other nodes. |
|
Red-Black Trees |
Data structure which is a type of self-balancing binary search that contains colours for each node. |
|
Heap |
Tree-based data structure that satisfies the heap property. |
|
Function |
Sequence of computer program instructions that perform a specific task. |
|
Arguments |
Inputs of a function |
|
What does import in Python do? |
Loads up functions into memory that can be called by program. |
|
What does def function_name (arguments) do? |
Creates a new function where function_name is your own name, and arguments are the inputs required for the function. |
|
What does return do? |
Sets a variable to be a value returned from a function |
|
Local Variable |
Variable declared within subroutines |
|
Global Variable |
Variable declared at the start of a program and can be used within any subroutines |
|
Higher-Order Function |
Function that accepts one or more functions as input, returns new function. |
|
Subroutine |
A module of code that may be treated as functional unit to accomplish specific sub-task within main program. Often called multiple times. |
|
What is an advantage to subroutines? |
Great for decomposing complex programming tasks into simpler steps and reducing duplicate code. |
|
What is a disadvantage to subroutines? |
Imposes computation overhead and requires standard housekeeping code. |
|
Overhead |
Combination of excess or indirect computation time, memory, bandwidth or other resources that are required to attain a particular goal. |
|
What are the steps to an algorithm development? |
(D)efine Program (R)equirements (D)esign (I)mplementation (T)est and Debug |
|
What are the basic styles of good programming? |
(K)ISS (R)eadability (I)ndent Style (M)odularize (N)o Deviants (confusing, you must not be) |
|
Debugging |
A process of finding and reducing number of bugs |
|
What is a good debugging style? |
Minimizing inter-modular dependency. Reproducing bug. Simplify inputs. |
|
What is the standard bug rate in procedural coding? |
6% |
|
Interpreter |
Program that directly executes code without converting the language (Python!) |
|
Compiler |
Program that transforms the source code into object code for the computer to understand. |
|
Script |
List of commands that can be executed without user interaction |
|
Is Python multi-paradigm or single-paradigm? |
Multi-paradigm |
|
Is Python a dynamic or static programming language |
Dynamic |
|
Is Python a scripting language? |
Yes |
|
What is open source? |
Free to the public to manipulate code wise. |
|
What are some advantages to Python? |
User friendliness. Easy to use and learn. Requires 10 times less code than C++. |
|
What are some disadvantages to Python? |
Not suited for all problems that are CPU intensive. 100x slower than C++ and takes 10x more space. |
|
What does a computer machine do? |
Stores programs and data. Execute steps sequentially. Produces output from input. |
|
What is computer architecture? |
The way hardware components in a computer interact and communicate. The union of micro and macro architecture. |
|
What is Von Neumann Architecture? |
Model for designing and building computers. |
|
What are the 3 characteristics of Von Neumann Architecture? |
Memory, I/O, ALU, CU. Stored Program Concept. Follows Sequential Execution of Instructions. |
|
Is Von Neumann Architecture micro of macro architecture? |
Macroarchitecture |
|
What does CPU stand for and what does it contain. |
Central Processing Unit. ALU and CU.
|
|
What does the ALU do? |
Performs integer arithmetic and logic operations. |
|
What are logic operations? |
Boolean AND / OR |
|
What does the CU do? |
Master conductor of all operations including reading and interpreting instructions, sequencing the processing of data, responsible for moving data between ALU and memory, and has a instruction set of all possible instructions that it could be asked. |
|
Memory |
Storage for information. |
|
TRUE or FALSE. The faster memory is, the less expensive and higher it's capacity. |
FALSE. The faster the memory is, the more expensive and lower it's capacity. |
|
RAM |
Random Access Memory |
|
ROM |
Read-Only Memory |
|
What is the instruction cycle? |
Fetch instruction form memory. Decode instructions. Execute instructions. |
|
What is the difference between macro and micro architecture? |
Macro is visible to us, micro is not. |
|
What does microarchitecture consist of? |
Binary codes. Transistors Gates. Circuits. |
|
What are binary codes? |
0's and 1's. |
|
What are transistors? |
On/Off switches. They are the heart of high-speed electronic digital computers. |
|
What are logic gates? |
Logical operations made from transistors. |
|
What are circuits? |
Combinations of gates. |
|
What is abstraction? |
Hiding unnecessary details for some immediate purpose. |
|
How much faster is an electronic vs something mechanical? |
10^5 |
|
Digital System |
System that can manipulate discrete elements of information. |
|
Was Analog or Digital computers invented first? |
Analog |
|
Analog vs Digital? |
Analog computers work in parallel. Digital computers work fast but do not work in parallel. |
|
Bit |
Binary Digit (0's and 1's) |
|
Byte |
8 bits |
|
What are the first 5 numbers in binary? |
0 1 10 11 100 |
|
What are transistors made of? |
Semiconducting materials/elements. |
|
Algorithm |
Well order collection of unambiguous and effectively computable operations that, when executed, produces a result and halts in a finite amount of time. |
|
What are the characteristics of an algorithm? |
Representation: concrete symbolic encoding of information. Transformation: the steps used to calculate a specific result.
|
|
Syntax |
Grammar, specifies form of a language by describing possible combination of symbols. |
|
Semantics |
Meaning, specifies what is being conveyed by the language. |
|
Formal Language |
Set of strings of symbols that may be constrained by rules specific to it. |
|
Natural Language |
English or any other spoken language. |
|
Pseudocode |
Language to describe what we want to program in english. Combination of formal and natural language. |
|
Spaghetti Code |
Code written with little attention to the flow of logic. Unstructured and tangled. |
|
What are the 3 primary control structures? |
(S)equence (normal) (I)teration (for loops) (D)ecision (if) |
|
For Loops |
Iterative loops that are used when the # of iterations is known. |
|
While Loops |
Conditional loops that are used when the # of iterations is unknown. More flexible than a For Loop. |
|
What are the levels of language in terms of the distance from hardware (abstraction)? |
Machine -> Assembly -> High Level |
|
What are the two types of Programming Paradigms? |
Declaritive: What to compute. Imperative: How to compute. |
|
What are the sub genres of declaritive? |
Logic & Funtional. |
|
What are the sub genres of imperative? |
Procedural & Object Oriented. |
|
What kind of language is Python? |
Declarative & Imperative. |
|
What is Python? |
High-level programming language where design emphasizes readability, and syntax allows programmers to express concepts in fewer lines of code. |
|
What is computing science? |
Study of algorithms including their formal mathematical properties, hardware realizations, linguistic realizations and applications. |
|
What is Moore's law? |
# of transistors and speed of microprocessors doubles every 18-24 months. |
|
What happened in the computer revolution? |
Computer power is rising exponentially. |
|
When were the first computers built? |
1940's and machine centred. |
|
What are the 3 types of user interfaces? |
GUI (WIMP): Graphic User Interface CLI: Command Line Interface HYBRID: GUI + CLI (UNIX) |
|
How should you program? |
With precision and accuracy. |
|
What are the 3 classes of bugs? |
Syntax: Incorrect grammar or spelling Semantic: Incorrect meaning Logic: Incorrect operation but code still able to run |
|
What is turing completeness? |
System in which program are written to find an answer, able to solve any computational problem given enough time and space. |
|
Turing Machine |
Hypothetical device representation computing machine to help computing scientists understand the limits of mechanical computation. Used to analyze the general properties of computers. |
|
Theory of Turing Machine |
Device that manipulates symbols on a strip of tape according to table of rules. |
|
Deterministic Turing Machine |
Basic computer that uses a fixed set of rules to determine future actions. |
|
Non Deterministic Turing Machine |
Works in parallel to prescribe more than one action for one solution. |
|
Computational Complexity Theory |
Theory that focuses on classifying computational problems according to their inherent difficulty and relating those classes to each other. The study of the size of a problem. |
|
Computational Problem |
A task that can be solved by mechanically applied mathematical steps. |
|
Decision Problem |
A problem for which an algorithm can always answer YES or NO. |
|
Class P |
Decision problem that increases in time as a polynomial function of the problem size. |
|
Class NP |
Decision problem solvable in time which increases faster than polynomial in n, but once solution is obtained, it can be verified in time polynomial in n (P). |
|
Class NP Complete |
Decision problems in NP, to which all other problems in NP can be reduced in polynomial time. |
|
Unsolvable Problem. |
A program where there exists no algorithm for its solution. |
|
Halting Problem |
Problem of determining whether a program will finish running or continue to run forever. Self referential. |
|
Binary Tree |
A structure where every node branches into two descendant nodes and number of nodes expands/grows in complexity exponentially with depth. |
|
Big O Notation |
Relative representation of the complexity of an algorithm. It tells you how fast a function grows or declines. |
|
Analysis of Algorithms |
Determination of the amount of resources needed for execution. Resources = time + storage |
|
Time |
Amount of time or steps it takes to fully compute an algorithm. |
|
Storage |
Amount of space or memory needed to process the algorithm. |
|
Case Complexity |
Best, Worst, Average. Measures the time complexity of different inputs of the same size. |
|
Best Case |
Solving a problem for best input of size n with least number of steps. |
|
Worst Case |
Solving a problem for worst input in most number of steps. |
|
Average case |
Solving a problem with average input, uniform distribution of all inputs of size. |
|
Tractable Problem |
Algorithm that has at most worst-case polynomial time complexity. |
|
Intractable Problem |
Algorithm that cannot be solved at all. No worst-case polynomial time complexity. |
|
What are the four classes of time complexity? |
Linear Quadratic Logarithmic Exponential |
|
Linear Complexity |
O(n) Looking at how a problem changes if it is done for more elements. |
|
Quadratic Complexity |
O(n^2) Problem that takes four times as long to solve when size of problem doubles. |
|
Logarithmic Complexity |
O(logx(n)) Problem that halves its space with every step until solution is achieved. Binary searches. |
|
Exponential Complexity |
O(b^n) Problem where running time increases exponentially with one step increase in input. |
|
Searching |
An algorithm to loop up a particular value in a list or data structure. Find a value and determine position. |
|
What are the 3 types of search algorithms |
Linear search Binary search Ternary search |
|
Binary Search |
Search that halves the list until a value is found. Divide & Conquer style! |
|
Is Linear or Binary faster? |
Binary because it always halves. |
|
Ternary Search |
Used to find minimum or maximum of an increasing/decreasing function and determines whether the min/max is in the first third or last third, and repeats same procedure with remaining two-thirds. Divide and Conquer. |
|
Sorting |
An algorithm to put elements of a list in a certain order, where output is either in nondecreasing order or is a permutation. |
|
What are the 3 types of sort algorithms? |
Simple sort. Efficient sort. Bubble sort. |
|
Simple Sort |
Insertion sort and selection sort. Both of which is efficient if used on small data. |
|
Insertion Sort |
An element in the list is compared with all elements before it until it is not greater than the element after it. |
|
Efficient Sort |
Practical general sorting algorithms based on algorithm with average complexity, including heap sort, merge sort and quick sort. |
|
Bubble Sort |
Swapping adjacent element pairs only from multiple passes through the list until sorted. |
|
Is insertion sort faster than selection sort? |
Yes. Less comparisons and good performance on almost-sorted data. |
|
Dialectic Classification of Algorithms by Implementation |
Recursive or Iterative. Logical or Procedural. Serial or Parallel. Deterministic or Non-Deterministic.
|
|
Recursive Algorithm |
Calls itself repeatedly until a certain condition is met. |
|
Iterative Algorithm |
Use of repetitive constructs like loops. |
|
Logical Algorithm |
Top-Down style of logic where a logic component expresses the axioms which may be used in computation and a control component determines the way in which deduction is applied to the axioms. |
|
Serial Algorithm |
Algorithms that execute one instruction at a time. |
|
Parallel Algorithm |
Several instructions at once. |
|
Deterministic Algorithm |
Predefined process on how to solve a problem. |
|
Non-Deterministic Algorithm |
Guesses of best solutions at each step through heuristics. |
|
Divide & Conquer |
Design paradigm that works by dividing problem into sub problems. Conquers each sub problem recursively and combines results. |
|
Memoization |
Optimization technique used to primarily speed up computer programs by keeping results of expensive function calls and returning the cached result when same inputs occur again. |
|
Dynamic Programming |
Solving problems with overlapping sub-problems |
|
Hash Table |
Data structure used to implement an associative array and can map keys to values. |
|
Greedy Method |
Same to dynamic, except algorithm does not require a solution at each stage for every sub-problem. |
|
Linear Programming |
A method to achieve the best outcome in a mathematical model, whose requirements are represented by linear relationships. |
|
Reduction |
Solving a problem by transforming it into another proble by simplest transformation. |
|
Graphs |
Used to model problems |
|
Probabislistic |
Random choices are made to solve problems |
|
Heuristic |
Experience-based techniques for problem solving. Comes up with a solution that may not be accurate by arbitrary guesses. |
|
Data |
Facts or figures that relay something specific but are not organized in any way. |
|
Type System |
Set of rules that assigns a property to the elements of a computer program. |
|
Data Type |
A classification scheme that identifies various types of data. |
|
What are the four things data types determine? |
Possible value for the type. Operations that can be done on that type of value. Meaning of the data. The way values of that type can be stored. |
|
Primitive Data Types |
Characters, integers, real numbers, booleans, alphanumerics. |
|
Complex Data Type |
Data type built upon simpler data types. Arrays. |
|
Data Structure |
A way to describe how a program is storing information given. Invisible to us programmers. |
|
Complex Data Type vs Data Structure? |
Data structure decides how complex data types are stored. |
|
What type of data do computer programs mostly process? |
Numerical and Logical data that are processed through ALU circuits.
|
|
Constant vs Variable |
Constant is an immediate value found in an expression. Variable is a memory location containing some known/unknown value. |
|
Typing |
Giving or assigning value in memory or object to a data type. |
|
Why is typing important? |
Computers cannot tell the difference between two values/objects. Typing conveys meaning to the programmable hardware to form a symbolic system. |
|
Type Checking |
Process of verifying and enforcing constraints of types, implemented at either compile-time or run time. Dynamic is used by Python. |