click below
click below
Normal Size Small Size show me how
CECS 342 Quiz 1
| Question | Answer |
|---|---|
| Three Primary Language Evaluation Criteria | 1. Readability 2. Writability 3. Reliability |
| Orthogonality | A property where a small set of primitive constructs can be combined in a relatively small number of ways, and every combination is legal and meaningful. |
| Lexical Analysis | The first phase of compilation that converts characters in the source program into lexical units (tokens). |
| Syntax Analysis | The compilation phase (parsing) that transforms tokens into a hierarchical structure called a parse tree. |
| Semantic Analysis | The phase that checks for errors difficult to find during parsing, such as type mismatches (e.g., adding a string to an integer). |
| Define: Von Neumann Architecture | The basis for imperative languages where data and programs are stored in the same memory and executed by a CPU. |
| Von Neumann Bottleneck | The limitation in computer speed caused by the fact that the connection between the CPU and memory is much slower than the CPU's execution speed. |
| Aliasing | Having two or more distinct names (references) for the same memory location, which often reduces reliability. |
| Logic Programming Category | A language category based on formal logic and rule-based systems rather than the Von Neumann architecture (e.g., Prolog). |
| Functional Programming Category | A category modeled after mathematical functions, emphasizing the application of functions to parameters (e.g., LISP, Haskell). |
| Imperative Programming Category | Languages that use variables, assignment statements, and iteration, closely mimicking the Von Neumann architecture (e.g., C, Java). |
| Pure Interpretation | A system where programs are decoded and executed line-by-line by another program (the interpreter) without being translated to machine code. |
| Hybrid Implementation System | A compromise system that translates high-level code into an intermediate language (Bytecode) for easier interpretation (e.g., Java, .NET). |
| Optimization Phase | An optional compilation stage that attempts to improve the program by making it smaller or faster. |
| Abstraction | The ability to define and use complex structures or operations in ways that allow many of the details to be ignored. |
| Type Checking | Testing for type errors in a given program, either at compile-time or run-time. |
| Exception Handling | The ability of a program to intercept run-time errors and take corrective measures, enhancing reliability. |
| Cost of a Language | A criteria including training programmers, writing programs, compiling, executing, and maintenance. |
| Symbol Table | A database used by the compiler to store information about user-defined names (variables, functions, etc.) and their attributes. |
| Parse Tree | A hierarchical representation of the syntactic structure of a program. |
| Just-In-Time (JIT) Compilation | A hybrid method where bytecode is translated into machine code instructions at the time they are needed during execution. |
| Preprocessors | Programs that process the code before it reaches the compiler, often used for macro expansion (e.g., #include in C). |
| Simplest Language Complexity | A language that has a small number of basic constructs, which generally improves readability. |
| Syntax | Syntax is the form or structure of the expressions; |
| Semantics | Semantics is the actual meaning of those expressions. |
| The ‘R-W-R’ Mnemonic | Readability, Writability, and Reliability. |
| Fibonacci Sequence | A series of numbers where each number is the sum of the two preceding ones, usually starting with 0 or 1. |
| What is the difference between an interpreted language and a compiled languages? | Compiled language (C++): Translated into machine code before running (faster) Interpreted Language (Python): Executed line by line at running time (slower, but easier to write and debug) |
| Why is C++ generally faster than Python? | C++ is compiled to machine code. C++ also gives more control over memory and performance. Python uses dynamic typing (adds runtime cost) |
| int fib(int n) { if (n <= 1) return n; return fib(n-1) + fib(n-2); } What type of Fibonacci implementation is this? | Recursive Fibonacci |
| What is a major problem with this recursive approach? | Time Complexity: O(2^n) It is very slow for large n because it repeats many calculations |
| int fib(int n) { int a = 0, b = 1; for(int i = 0; i < n; i++) { int temp = a + b; a = b; b = temp; } return a; } What is this approach called? | Iterative Fibonacci Time Complexity: O(n) |
| Why is Iterative faster than recursive? | Avoids repeated calculations, runs in linear time O(n), and uses constant memory O(1) |