1.1 and 1.2 notes
Created
@January 21, 2025 1:27 PM
Class
CSCI 1010
1.1 Computer Systems
Program: A set of instructions for a computer to follow.
Software: Collection of programs used by a computer.
Hardware: Physical components of a computer.
Hardware Types
PCs: Small, individual-use computers.
Workstations: Larger, more powerful PCs.
Mainframes: Large, shared-use computers requiring support staff.
Five Main Components:
Input devices (e.g., keyboard, mouse).
Output devices (e.g., monitor, printer).
Processor (CPU).
Main memory.
Secondary memory.
Component Details:
Processor, main memory, and secondary memory are housed in one cabinet.
The processor and main memory function as the core of the computer.
Input and output devices communicate with the processor and memory.
Memory Overview
Main Memory:
Binary Codes:
1.1 and 1.2 notes
1
Strings of 0s and 1s in memory are interpreted based on coding schemes (e.g., 01000001 = 'A'
or 65).
The computer tracks the code type for each memory location.
Main Memory:
Holds programs and data temporarily while being used.
Organized in bytes (8 bits) due to convenience with binary and character encoding.
Also called RAM (Random Access Memory), allowing direct access to any memory location.
Secondary Memory:
Permanent storage (e.g., hard disks, CDs, DVDs, flash drives).
Stores information in files.
Processor (CPU)
The "brain" of the computer:
Executes instructions and performs calculations.
Functions based on simple, predefined instructions.
Software:
Operating System (OS):
Acts as the intermediary between the user and the computer.
Allocates resources and manages tasks.
Examples: Windows, Mac OS, Linux, iOS, Android.
Functions: Runs programs, edits files, and processes user commands.
Programs
A program is a set of instructions for the computer.
Input to a computer includes:
Program: Instructions.
Data: Information processed by the program.
The computer executes the program to process the data and produce output.
Programming Languages
High-Level Languages:
1.1 and 1.2 notes
2
Examples: C++, Java, Python, C#.
Resemble human languages, making them easier to write and read.
Must be translated into machine language for the computer to understand.
Low-Level Languages:
Include assembly language and machine language.
Example (Assembly): ADD X Y Z
Example (Machine): 0110 1001 1010 1011 (binary translation).
Machine language is the direct set of instructions the computer follows.
Compilers
Definition: A compiler is a program that translates a high-level language (e.g., C++) into
machine language that a computer can execute.
How It Works:
Input: Source program (written in a high-level language like C++).
Output: Object program (machine-language equivalent).
To the compiler, the source program is just a string of characters to translate into
machine code.
Steps to Execute a Program:
1. Run the compiler with the source program (C++ code) as input.
2. Compiler produces object code in machine language.
3. Execute the machine-language program on the actual input data to produce the final
output.
Linkers
Definition: A linker combines the object code from the compiler with precompiled object
code for routines (e.g., input/output functions).
Purpose: Produces a complete machine-language program by combining:
The compiled code from your program.
Pre-existing, compiled routines needed for operations like input and output.
1.1 and 1.2 notes
3
Automation: Many systems automatically handle the linking process for routine cases.
1.2 Programming and Problem Solving
Algorithm:
An algorithm is a step-by-step sequence of clear instructions to solve a problem. It can be
written in plain English or a programming language. A program is simply an algorithm
written for computers to understand.
Steps to Create an Algorithm:
1. Define the problem.
2. Formulate the solution as clear steps.
3. Write it in plain English.
Example:
To count how many times a name occurs in a list:
1. Get the list and target name.
2. Set a counter to zero.
3. Compare each name to the target name; increment the counter for matches.
4. Output the counter value.
Characteristics:
Sequential: Follow steps in order.
Unambiguous: Clear and precise instructions.
Repeatable: Produces the same result under the same conditions.
Programing design
1. Two Phases of Program Design
1.1 and 1.2 notes
4
Problem-Solving Phase:
Define the task clearly (input, output, and format).
Design an algorithm (written in plain English) to solve the problem.
Test the algorithm through desk-checking (mentally or on paper).
Implementation Phase:
Translate the algorithm into a programming language like C++.
Test the program by running it with sample input to identify errors.
2. Importance of Proper Design
Novice programmers often skip the problem-solving phase, thinking it saves time.
However, experience shows that following the two-phase process leads to fewer errors
and faster completion.
A well-designed algorithm simplifies coding and reduces frustration.
3. Testing and Iteration
Both phases involve testing:
The algorithm is tested during the problem-solving phase.
The program is tested during the implementation phase.
Real-life design is iterative:
Errors or deficiencies may require revisiting earlier steps, like redefining the
problem or redesigning the algorithm.
Object-Oriented Programming (OOP)
1. Overview of OOP
Object-Oriented Programming views a program as a collection of interacting objects
rather than just algorithms manipulating data.
Example: A highway simulation program might represent objects such as cars and lanes,
with algorithms defining their behavior.
Programming in OOP involves designing objects and their algorithms instead of just
crafting algorithms.
2. Key Features of OOP
1.1 and 1.2 notes
5
Encapsulation: Simplifies object descriptions and hides unnecessary details (information
hiding).
Inheritance: Facilitates code reuse by enabling objects to inherit properties and
behaviors from other objects.
Polymorphism: Allows a single name or interface to represent different behaviors in the
context of inheritance.
3. Software Life Cycle (6 Phases)
1. Analysis and Specification: Define the problem/task clearly.
2. Design: Plan the objects and algorithms.
3. Implementation: Code the program.
4. Testing: Ensure the program works as intended.
5. Maintenance and Evolution: Improve and update the program over time.
6. Obsolescence: Discard and replace outdated programs when necessary.
1.1 and 1.2 notes
6