Skip to content

Latest commit

 

History

History
227 lines (170 loc) · 8.03 KB

README.md

File metadata and controls

227 lines (170 loc) · 8.03 KB

CS Note

Table of Contents

  1. Computer Memory and CPU Overview
  2. Binary
  3. Flow Chart
  4. Time & Space Complexity
  5. Data Structure
  6. Sorting & Searching
  7. Algorithms

Computer Memory and CPU Overview

(click to expand/hide)

Introduction

  • Byte: Consists of eight bits.
  • Bit: Simplest form of computing memory.
  • Memory Capacity: Number of bytes a computer can hold.

Central Processing Unit (CPU)

  • Core of a computer.
  • Processes both information and instructions.
  • Works faster than the transfer of information.
  • Switches tasks to allow info transfer to cache.

Memory Types

Cache Memory

  • Closest and fastest memory to the CPU.
  • Most expensive type of memory.
  • Function: When CPU gets an instruction, it checks cache first.
    • If info is in cache: it gets processed.
    • If not: CPU accesses main memory.
  • Organized in zones: Zone 1 (most important) and subsequent zones (lesser importance).

Main Memory

  1. RAM (Read Access Memory):

    • Volatile: Info is lost when power is cut.
    • Holds data and instructions currently in use.
    • More RAM = Faster system due to improved transfer rate.
  2. ROM (Read Only Memory):

    • Non-volatile: Info retained when power is off.
    • Pre-programmed and cannot be altered.
    • Contains critical instructions/data, especially during startup.

Secondary Memory

  • External memory solutions.
  • Slower access compared to main and cache memory.
  • Must transfer info to RAM for access.
  • Examples: Cloud storage, external hard drives, memory sticks.

Resources

  • Memory can be stored side-by-side or spread out throughout your computer. For some insights on this, you might be interested in reading more about heap versus stack memory

Binary

(click to expand/hide)

Boolean logic

Truth Table

boolean truth table

Gates

boolean logic gates


Flow Chart

(click to expand/hide)

flow chart example

flow chart example


Time and Space Complexity

(click to expand/hide)

Time Complexity

time complexity graph

Space Complexity

space complexity = input space + auxiliary space

Big-O notation (Time & space complexity)

Time & Space Complexity Table

time and complexity table

Resources


Data Structure

(click to expand/hide)

Basic Data Structure

Resources

Collection Data Structures

Resources

  • This article about Understanding Java tree APIs provides some excellent additional insight into different types of trees and the various attributes associated with them.
  • This article about Binary trees in C gives a breakdown of how trees are used in C. The focus is on the binary tree and the various types of binary trees and how one would implement them.
  • This article about C# collections gives an overview things like arraylist, hashtable, lists and so on implemented in C#.
  • This article about Trees provides an informative analysis of trees.
  • This article about Array-based lists gives more information relating to lists that are backed by arrays.
  • This article called What are static and dynamic data structures gives an interesting breakdown and analysis of static and dynamic data structures

Advanced Data Structures

Resources

  • When discussing hashing the probability of collisions was introduced. Learn more about the statistics behind the birthday paradox.
  • An excellent breakdown of graphs with associated terminology;
  • Information on heaps how to add and remove from them/

Sorting and Searching

(click to expand/hide)

Sorting

Selection Sort

  • Worst case: O(N^2)
  • Average case: O(N^2)
  • Best case: O(N^2)
  • Space complexity: O(1) Auxiliary

Quick Sort

  • Worst case: O(N^2)
  • Average case: O(N log N)
  • Best case: O(N log N)
  • Space complexity: O(N) Auxiliary

Searching

Linear Search

  • Worst case: O(N)
  • Average case: O(N)
  • Best case: O(1)
  • Space complexity: O(N) Auxiliary

Binary Search

  • Worst case: O(log N)
  • Average case: O(log N)
  • Best case: O(1)
  • Space complexity: O(N) Auxiliary

Resources

  • Here is an article on Time and space complexity of selection sort. It includes an implementation of selection sort and how one can calculate the complexity involved.
  • Here is an article about Quick-sort with a video tutorial and pseudocode. It provides a detailed analysis of various sorting algorithms, comparisons and further links to video explanations.

Algorithms

(click to expand/hide)

Divide and Conquer

Merge Sort

Recursion

Dynamic programming

Memoization

Greedy algorithms

Resources

  • This article provides a comprehensive breakdown of various algorithms that are graph specific. In this article, you will gain both an understanding of the data structure as well as insights into its implementation.
  • This article discusses space complexity. In it, you will find a comparison between implementing iterative solutions versus recursive ones.
  • This article explains what recursion is and which datatypes are most congenial for its implementation.