Computer Science 101 - Lecture Notes

Jul 7, 2024

Computer Science 101

Introduction to Computer Science

  • When facing a code error:
    • First Step: Change nothing, try running it again.
    • If unsuccessful: Might feel like you need a Computer Science degree.
    • Irony: High-paying jobs in software engineering without knowing how things work feel like magic.

Understanding Computers

  • Turing Machine: A theoretical device that manipulates symbols on a strip of tape according to a table of rules and can compute anything.
  • Central Processing Unit (CPU): Contains a piece of silicon with billions of transistors acting as switches.
  • Bit: Smallest piece of information a computer can use; a value at a switch.
  • Byte: A package of 8 bits; can represent 256 different values.
  • Character Encoding: Characters typed are mapped to binary values (e.g., ASCII, UTF-8).

Binary and Hexadecimal Systems

  • Binary System: Uses 0 and 1; difficult for humans to read.
  • Hexadecimal System: Base 16 format, representing binary in a more readable form.
  • Nibble: A 4-bit group in hexadecimal.

Programming and Machine Code

  • Programming Languages: Code in higher-level languages is converted to machine code (binary format).
  • Random Access Memory (RAM): Stores data for applications; each location has a memory address.

Computing Hardware

  • Input Devices: Keyboard, mouse.
  • Output Devices: Monitor.
  • Operating Systems (OS): Provide an interface for managing hardware resources (e.g., Linux, Windows).
  • Shell: A program that exposes the OS to the user, taking text input and producing output; can connect to remote computers via SSH.

Programming Languages and Abstractions

  • Scripting Languages: Python (interpreted line by line).
  • Compiled Languages: C++ (compiled into machine code before execution).
  • Built-in Data Types: Characters, numbers, variables.
  • Dynamic Typing: Python automatically identifies data types.
  • Static Typing: In languages like C, data types must be specified.
  • Memory Management: Allocation and deallocation of memory.
  • Garbage Collection: Automatic memory management.

Data Types and Structures

  • Integers and Floats: Whole numbers and numbers with decimals.
  • Characters and Strings: Individual characters or sequences.
  • Big Endian vs. Little Endian: Memory storage order.

Data Structures

  • Array/List: Indexed collection starting at 0.
  • Linked List: Items pointing to the next item.
  • Stack: Last in, first out (LIFO).
  • Queue: First in, first out (FIFO).
  • Hash/Map/Dictionary: Key-value pairs.
  • Trees: Hierarchical data structure.
  • Graphs: Nodes connected in various ways.

Algorithms

  • Function: Block of code taking input, processing, and outputting a result.
  • Conditional Logic: If-else statements.
  • Loops: Repeating blocks of code (for, while).
  • Recursion: Function calling itself; needs a base condition to avoid infinite loops.
  • Big-O Notation: Measures algorithm performance (time and space complexity).
  • Common Algorithms:
    • Brute Force: Trying all possible combinations.
    • Divide and Conquer: Splitting problems into smaller parts.
    • Dynamic Programming: Using memoization to store sub-problem results.
    • Greedy Algorithms: Short-term beneficial choices.
    • Backtracking Algorithms: Incremental exploration of paths.

Programming Paradigms

  • Declarative Programming: Describes what the program does, not how.
  • Imperative Programming: Explicit instructions for control flow.
  • Multi-Paradigm Languages: Support multiple programming styles (e.g., Python, JavaScript).
  • Object-Oriented Programming (OOP): Using classes and objects.
    • Classes and Objects: Blueprints and instances of data.
    • Encapsulation: Properties and methods.
    • Inheritance: Sharing behaviors between classes.
    • Design Patterns: Common ways to structure code.
    • Memory: Call stack for short-term, heap for long-term storage.

Concurrency and Parallelism

  • Threads: Virtual cores on physical CPU cores.
  • Parallelism: Code executing on different threads simultaneously.
  • Concurrency: Handling multiple tasks on a single thread (event loop, co-routines).

Cloud Computing and Networking

  • Virtual Machines: Software simulating hardware, fundamental to the cloud.
  • Internet Protocol (IP): Identifies machines on a network via unique addresses.
  • Domain Name Service (DNS): Maps URLs to IP addresses.
  • TCP Handshake: Establishes connection to exchange messages.
  • SSL/TLS: Encrypts messages for secure communication.
  • HTTP/HTTPS: Protocols for client-server data exchange.
  • API: Standardized data interaction, commonly REST architecture.

Conclusion

  • Miscellaneous Knowledge: Understanding devices like printers, popular demand in tech help.