CS Notes
CS Notes
- Programming : includes the creation of a series of steps that will solve a problem or
problems/ Is a process of solving a problem in phases.
-
- Definitions:
- Runtime: the amount of time it takes for a program or operation
- Compilation :
- Execution : the act of running a program or code, causing the computer to perform the
specified tasks.
- Computers can only solve problems solvable by humans except ai obv
- The client doesn’t know what they want a lot of the time cuz they misdiagnose the
problem
- Decomposition :
- Data presentation :
- Generalization :
- Algorithms : series of unambiguous instructions designed to solve a problem and achieve
a certain goal in a finite number of steps
1. Identification
● explicitly pinpoint where the problem is
● Describe the problem
1. Development
● Make plans B and C etc
1. Selection
2. Implementation
● Executing solution
Programming: series of steps to solve a problem; a sequence of instructions that explain to a
computer how to solve a problem
-
1. Identification
● explicitly pinpoint where the problem is
● Describe the problem
1. Development
● Make plans B and C etc
1. Selection
2. Implementation
● Executing solution
● Decomposition
● Data representation
● Generalization
● Modeling
● Algorithms
1. Finiteness
2. Definiteness
3. Effectiveness
4. Input
5. Output
Ways to Express an Algorithm
3. Pseudocode
Generic artificial language that doesn’t use syntax of any particular programming
language
4. Programming language
Prefetching: getting data or instructions from memory into the cache before they are
actually needed, instead of waiting for the data from RAM
Gantt chart:
List of jobs & how long it takes
Sequential:
Concurrent:
Pre-condition/input: indicates what must be true before the sub-procedure is called. It
describes the starting state before the execution of an algorithm
Post-condition/output: indicates what will be true when the sub-procedure completes its
task
Exception: an act or event that disrupts the anticipated flow of the program’s execution
Sequential processing: the execution of all sub-procedures one after the other by a single
processor
Programs are broken down into procedures, and procedures are broken down into
sub-procedure.
Input: Something you put into the programing
Process: Something happens to your input
Output: Your changed input appears
Pseudocode -
Memory location- memory locations are identified by their addresses we give them names
Iteration :
- Iteration is the process of repeating a series of instructions .
- Iteration is expressed using the “ from to loop” and the “while loop” statements .
- The diamond shape performs a boolean test , evaluates and expression and returns a
boolean value (true or false )
Pre-planning: Process of planning something in advance
Pre-planning is set up or preparation required before a solution is implemented
Prefetching on broad terms: Getting data into the cache before they are actually used
Gantt Chart: A bar graph that shows when a process will start and end. Shows what is
being worked on at which times. On the left are tasks, at the top there is time.
Pre-Condition: What must be true before a procedure is called. The starting state
Post-Condition: What must be true when the procedure completes the task.
Sequential processing - is the execution of all sub-procedures one after the other by a single
processor
Concurrent - Means something that happens at the same time as something else. Imagine a
situation where a user replies to his emails while listening to his favorite song. Tasks are
implemented concurrently.
Programs are broken down into procedures and procedures are broken down into sub-procedures
Object Oriented Programming: It uses abstraction. It is based on the principle that all everyday
tasks and things can be considered as entities. They are called objects (nouns) or events (verbs.
You can use Methods to change the values of data in an object. (Note: It is like functions from
Python)
Collection: An abstract class. It is used to add, store, manage, retrieve, manipulate, and
communicate the data using predefined methods
Array code
Bubble Sort: A simple algorithm that repeatedly steps through an array to sort it. It compares
adjacent terms and switches them if they are not in correct order.
Binary Search: Going to the middle term and checking if the target number is greater or less
than.
What affects Algorithm Runtime:
A compiler translates high level code to low-level instructions. Compilers translate once. It
issues errors if it finds syntax errors.
A grammar is a meta-language that is used to define the syntax of a language, while the rules of
statement construction are called syntax.
Each high level language has a unique syntax and a specific limited vocabulary.
The word import, class, int, etc. in Java are reserved keywords with special meaning in the Java
language.
Machine language is a very low level language that is the only thing a computer can
comprehend.
We use high level language because they are closer to spoken languages.
Modular programming is breaking down a complex program into smaller simpler components.
Advantages of modular programming:
● Distributed development
● Code reusability
● Program readability
A subprogram (sub procedure) is a unit that contains a sequence of computer instructions that
perform a specific and predefined task. It is defined and called within the program.