0% found this document useful (0 votes)
6 views

computer notes

The document covers key concepts in computational thinking, including algorithms, decomposition, abstraction, and the use of subprograms. It explains programming constructs, data structures, binary representation, and error types in programming, along with searching and sorting algorithms. Additionally, it discusses data compression, the stored program concept, and the architecture of computer systems, including the CPU and memory functions.

Uploaded by

sunsshope
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

computer notes

The document covers key concepts in computational thinking, including algorithms, decomposition, abstraction, and the use of subprograms. It explains programming constructs, data structures, binary representation, and error types in programming, along with searching and sorting algorithms. Additionally, it discusses data compression, the stored program concept, and the architecture of computer systems, including the CPU and memory functions.

Uploaded by

sunsshope
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 14

Topic 1: computational thinking

• an algorithm is a step by step procedure for solving a


problem.
• Decomposition and abstraction are two important
computational thinking skills used to analyse the problem,
design the solution and resign the solution.
• Decomposition is the process of breaking down the problem
into smaller parts or smaller sub problems.
• Abstraction is the process of hiding or removing unnecessary
details to solely focus on the important points.
• Subprogram is a self contained block of code that performs
a specific task within a larger program
• there are 2 types-
pre-existing sub programs- high level programming
languages have number of ready made subprograms to
perform common tasks such as handling output or counting
number of characters
there are built in subprograms such as print or len or ones
that have to be imported before use such as math.floor and
random.randint

user- defined subprograms- programmers can write their


own user defined subprogram to perform specific tasks in the
program.

• Uses of sub programs


1. subprograms breaks down complex programs to smaller
parts that are easy to code and debug
2. subprograms makes the programs logic clear. Giving the
subprograms a meaningful name will express the purpose of
the program clearly
3. subprograms make it easier to maintain the code. The
subprogram can be changed or modified without affecting
the other parts of the program.
4. Subprograms can be used over and over again avoiding any
unnecessary duplications.
5. Subprograms can be stored in the library and used when
required.
6. Subprograms allows a group of programmers to work
together on a project at the same time parallel debugging
and coding different parts of the subprogram.
Programming constructs
1. sequence- used to ensure that the program runs in the
correct order.(arrows in the flowchart)
2. Selection- used to choose between two or more options.(if,
elif and else in python)
3. repetition- process of repeating set of instructions until
desired outcome is made. Two types. Condition controlled
repetition- number of times the loop should be executed is
not known before the loop is started(for in range and while in
python). Count controlled repetition- number of times the
loop should be executed is known before loop is
started(while in python). Repetition in written
descriptions(until, while, go back to)
4. iteration- process of repeating a set of instructions for each
item in the data structure. Flowcharts have a string,one
dimensional or two dimensional data structures. This is like a
count controlled repetition. (for in, for in range and while in
python) and (all, for every. While not last in written
descriptions)

variables and constants


• variables and constants are used to store values within the
algorithm or the program.
• Variables store values that can change while the program is
running.
• Constants store values that cannot change while program is
running.
• Variables and constants should be named(identifiers). The
names should not be short, it should be meaningful. It also
should not contain reserved words such as print.
• Variables are named in camel case and constants named to
upper case.
• Assignments are associations of piece of data with a variable
or constant

1 dimensional arrays and 2- dimensional arrays


• array is a data structure that stores multiple data items
called elements under the same identifier. (stores data in
rows and columns)
• 2 dimensional arrays have a second array at the each
position of the 1 dimensional array
records
• record is a collection of data objects(data types)
• collection of records form 2 dimensions
• single record forms 1 dimension
• each data item is called the field

arithmetic operators, relational operators and logical operators


• arithmetic operators are used to perform calculations in
programs.(% is used to divide and return the remainder
and // for integer division)
• relational operators(!= not equal and == for equal)
• logical operators
1. AND- operator used if all of the overall statements
are true
2. OR- operator used if any of the overall statements are
true
3. NOT- operator used when non of the overall
statements are true and reversed.
Dry run and trace tables

• dry run is a method used to investigate the functioning of


the algorithm.
• Along with the dry run, trace table is used to store inputs
and outputs of the algorithm.

Errors that can occur in programs


• errors are bugs which may prevent the execution of the
program or produce unexpected or wrong output.
• There are 3 types:
1. syntax errors- caused by not following the rules of the
program. Like misspelling command words and using
wrong punctuation(easiest to find and correct because
they are flagged up by the compiler and interpreter
while translation)
2. run time errors- caused by asking the processor to
execute impossible operations such as dividing by zero
or opening a non existing file). Thus the program may
crash due to this.
3. Logical errors- caused by the flaw in the design of the
program. (these errors are the hardest to find, make
sure to check if variables are initialized correctly, right
operators used or the assignments are used in correct
way). These may produce unexpected outcome.

Linear search and binary search(searching algorithms)


• these are standard searching algorithms.
• Linear search
sequential. Starts at the beginning of the list and compares
first item with target value. If they match, stop. If they
doesnt, move to the next item and compare once again.
Repeat until target value is found or end of list is reached or
length of the list is 0. (linear search uses brute force- tries all
possibilities until solution found or all the possibilities are
exhausted. Brute force does not use any special techniques.
It use raw computing power. It is more likely inefficient
because it starts at beginning of list and goes on till a match
is found or the list is over. This method is time consuming.
Yet it is simple.). Performed on short, unsorted and rarely
searched algorithm.
Best case- first item worst-last item or not in list
• binary search
it should be sorted. Start and compare search item with the
median. The list keep on splitting to find the median. Stops if
the items match. If search item is lower, discard the median
and higher items. If search item is higher, discard the lower
items and median. Stopped when there is no more items to
be searched or the search item is not found. Uses divide and
conquer method- breaks the list down into smaller lists and
perform same operation on each. It is efficient. Complex as it
requires recursion. Performed on sorted, long and oftenly
searched list.
Best case- first median position worst- last median position

Bubble sort and merge sort( sorting algorithms)

• bubble sort is an sorting algorithm that uses brute force


technique. It works by comparing the adjacent items and
swapping them if required to get the items arranged in
either ascending or descending order. This method caries out
till the list is sorted by performing few passes.
• Merge sort is an sorting algorithm that uses brute force
technique. It works by dividing the the list into sub
components till one item is left separately. Then it rebuilds
them together in ascending or descending order accordingly.
It is very efficient.

Topic 2- using binary


• binary is used to represent data and program instructions.
• why computers use binary? Computer processors have
billions of transistors which acts like switches. They have 2
states. On or off. On means 1 and off means 0. these are
bits. Data in computers are represented as bit patterns. 4
bits form a nibble and 8 bits form a byte.
• Number of unique binary patterns can be calculated by 2**n.
N represent the number of bits.
• Two's complement is used to represent signed integers in
binary.
• Check for the most significant bit(left most one). 0 represent
positive and 1 represent negative.
• To convert negative denary number to binary. Follow these
steps(twos complement)
1. write the same number in the positive forn using
binary
2. flip all bits, 1s to 0 and 0s to 1
3. add 1 to the bit pattern above
• binary addition results in = 1+1 0 and carry 1
= 0+0 0
= 0+1 1

arithmetic and logical shifts

logical shifts

1. left logical shift


shift the binary digits acc to given number of positions to
left.
Discard the left most bits acc to given number of positions
fill in the right side empty places with 0s
2. right logical shift
shift binary digits to right acc to number of positions given
discard the rightmost bits acc to number of positions given
fill in empty spaces in the left with 0s.

Arithmetic shifts

1. right arithmetic shift


shift the binary digits to the right acc to no of positions given
discard the right most bits acc to no of positions
fill in empty spaces in left with the msb
2. left arithmetic shift
shift the binary digits to left acc to no of positions given
discard the left most bit acc to no of positions
fill in empty spaces in right with the msb

overflow error
• overflow error is when an operation produces a result that
requires higher number of bits than what is available in the
computer to store it. There is an extra 9th bit which requires
extra storage than what the computer can store.
• This causes the program to crash and result in incorrect or
unexpected results.

Hexadecimal
• hexadecimals break each 8 binary digits into nibbles(4
binary digits) which are easier to use.
• Hexadecimals helps programmers because it uses fewer
digits.
• From 10 onwards hexadecimal is represented using alphabet
• uses of hexadecimals:
1. helps humans to cope up with long strings, 8 bit
binary are hard to deal with. But hexadecimal is
much simpler to use
2. computers use hexadecimal to represent
malfunction and error code
3. hexadecimal used in assembly language to
represent numerical values.

True colors
• true color uses 24 bits or 3 8 bit binary patterns to represent
each color variations. Which might be hard to remember or
use and code. Instead, hexadecimal represent this large
strings in 6 digits which are much more easier to remember
and work with.

• Computers represent text characters, numbers and symbols


by strings by using binary.(either 0s and 1s)
• ASCII have 7 bits and have 128 bit sequences.
• Ascii can only represent limited number of symbols and the
english alphabet in both camel and simple case.
• Unicode has much more number of bits than ascii so it can
represent various language alphabets and different symbols.
Bitmap images
• picture elements in short. Pixels increase the details of the
images.
• Image size is calculated by multiplying width and the height
• color depth- number of bits used to encode the color of each
pixel. Color depth increases the actual colors in the image.
• Resolution- it is the number of pixels per inch.
• Pixelated is when an image is enlarged too much.

Analogue sound
• sound recordings convert changes in air pressure into
voltage changes. This is called analogue recordings
• sample interval is when samples of sound waves are
recorded at fixed regular intervals.
• Sample rate is number of samples over a given time. Sample
rate increases accuracy.
• Bit depth is the number of bits used to encode each sample.
• Calculate file size by = bit depth*time in secs*sample rate
• fidelity means how much copy is accurately matching to the
original one.
• Samples are snapshots of sound at regular time intervals.

Unit conversions
1. byte-2**0 or 1024 bytes
2. kibibyte- 2**10 1024 bytes
3. mebibyte- 2**20 1024 kibibytes
4. gibibytes- 2**30 1024 mebibytes
5. tebibytes- 2**40 1024 gibibytes(1024 is a binary prefix)

data compression

• reducing size of large files by using compression algorithms


which repackage or remove some of it.
• They can be either lossy or lossless
1. lossless- compresses by checking for the data
that is being repeated at different places. Then
data is brought to one reference, it doesn't
occur any data loss. The data that is
compressed can be completely uncompressed
to the original form without any changes. Can
be done on text files, graphic files with low
color depth. Not suitable for image files or
audio and 24 bit color files. Example: png
image files, flac and alac audio files and
compressed text files.
2. Lossy- compresses by checking for places with
slight differences(in image files) and small
differences of frequency in audio files that
cannot be heard anyway. The image files are
compressed using smaller number of bits and
those low frequency parts in audio files are
omitted. Can be used in image files and digital
sound recordings. Not suitable for text files and
executable software. Examples: mp3 audio files
and jpg image files
• importances of compressing files
1. less internet bandwidth is required to upload and
download the content.
2. Less transmission time- higher speed
3. less storage is needed to store files
4. causes less congestion via the internet
5. useful for streaming video and audio files

Topic 3- The stored program concept


• the stored program concept was introduced in 1940s by alan
turing and john von neuman to reprogram the computer so
variety of tasks can be executed. Even though computing
machines were available before, they were only capable of
carrying out one task at a time.
• Computer architecture refers to structure of computer
system including hardware components and how they work
together to perform programs.
• Von neuman architecture consist of:
1. input- to enter data and program instructions to
process
2. output- to return results of processing
3. central processing unit- process data program
instructions after fetching them from the main
memory, it happens one at a time.
4. Main memory- load program instructions and data
that are prior to be processed.
• Main memory is short term- it only stores the data and
program instructions that are currently used, so the main
memory is continually changing.
• Main memory contain collections of storage locations that
have their own their unique addresses. They might store
data items or program instructions.
• Called as the RAM as it can read and write the storage
locations anytime.
• Called as the primary storage as it have fast and direct
access with the CPU.
• Main memory is used in computers and phones too. The
storage in those devices are high so more data can be
loaded over time.
• Main memory is volatile, meaning it needs power to keep
retaining the info.

The central processing unit


• CPU decodes and execute data and program instructions.
Components of the CPU:
1. clock- synchronises actions of the CPU.
2. Busses- transfer data and instruction through out
components of the computer system.
3. Arithmetic logic unit- proceed with arithmetic and logic
operations.
4. Registers- storage of data that can be directly accessed.

Clock

• CPU's clock is a quartz crystal that vibrates at a constant


rate, every tick means the CPU should carry out an action.
• Clock speed is measured in hertz. 1 hertz means 1 cycle per
second.
• Clock speed increases the data executed.

Buses

• busses transfer data and program instructions through out


components of the computer systems.
• There are 3 types:
1. control bus- transfer data and program instructions
between the cpu and other components.(bi
directional)
2. Address bus- contains the address of the memory
location where the cpu writes to or read from.( no of
wires the address bus use represent the bandwidth. 1
wire- 1 bit)(uni directional)
3. data bus- transfer data and instructions between the
cpu and the memory(bi directional)

fetch decode execute cycle


• fetch decode execute cycle is the sequence of steps carried
out by the CPU to execute a programme.
• This includes :

1. fetch- memory address of the next instruction is


placed on the address bus by the CPU. Control unit in
the CPU sends read signals via the control bus to the
memory. Then the data contents of the specified
memory location is transferred from the RAM to the
CPU. Those data are stored in registers.
2. Decode- control unit in the CPU decodes the
instruction by looking it up in the CPU's instruction
set.
3. Execute- the control unit carries out all operations of
other components. And if calculations should be done,
signal is sent to ALU for the execution to take place.
• Simply fetch decode execute cycle- the specified data is
fetched from the RAM into the CPU. The control unit decodes
the instructions by looking it up in the instruction set. The
control unit carries out operations, if calculations are needed
ALU is signaled to proceed.

The need for secondary storage

• secondary storage ensure the tasks are swapped quickly in


the computers which will make them general purpose
machines.
• Primary storage is short term.
• And it is volatile which means a power supply is required to
retain the data and instructions in use.
• Meanwhile secondary storage is long term.
• And it is non volatile, meaning it does not need a power
supply to retain the information.
• Secondary storage is important to store data and
instructions where they are not in use. If primary memory
was only used, the data would be swept away easily after
use.

How primary storage and secondary storage works together

• when a user opens an application it is loaded into the main


memory by the secondary storage.
• The further data files open in the application are also loaded
into the memory by the secondary storage.
• When the user saves the files, the data is transferred from
memory to secondary storage.
• When the application is closed, the data is removed from the
memory.

Differences between primary storage and secondary storage

• primary storage is volatile and needs power to retain its


information, meanwhile the secondary storage is non
volatile, doesn't need power to retain information.
• Primary storage is short term and secondary storage is long
term.
• Primary storage have direct and fast access with the CPU,
while the secondary storage doesn't have direct access but
data is transferred to memory in order to be executed, and
then to the CPU.
• Primary storage has limited scope to expand storage
meanwhile the secondary storage has practically no limits.
The storage can be further expanded by the use of external
devices such as external hard drive and USB sticks.
• Primary storage- main memory
• secondary storage- hard drive

types of secondary storage

• can be either magnetic, optical or solid state storage

1. magnetic storage- external/internal disc drives and


tape drives use magnetic storage. These have stack of
circular metal platters coated with a substance that
can be magnetised. Each platter contain a read write
head. To write data, the electromagnet in the head
magnetises the surface of the platter upto one of the
two polarities which are south to north or north to
south, representing 1 and 0s. To read the data, the
read write head detects the state of the platter. This
method allows faster access of data and have high
capacities of long time storage. But there are internal
moving parts which might fail and produce lot of noise
2. optical storage- CD/DVD and blue-ray discs use optical
storage. To write data, a laser burns the disc. The more
reflective ones are known as lands,1s and least
refractive ones are pits, 0s. To read the data, a laser is
shone to the disc, pits refract more dimly than lands.
The amount of light refracted by the surface is
detected by the sensors and translated to 1s and 0s.
This is cheap and portable but this method may result
in slow data access and this is prone to scratches.
3. Solid state storage- mobile phones, USB sticks, SSD
cards and solid state drives use solid state storage.
Solid state devices have grids of transistors. Write by
applying an electric current through the transistors
which may cause an electron pool. Empty electron pool
represent 1s and full pools represent 0s. Read by
applying small voltage, transistor turn on in empty
pools giving off 1s and transistor does not turn on in
full pools giving off 0s. This method have fast data
access, portability, no moving parts, no noise and less
power consumption. But this I s expensive and only
have limited read write cycles.

Embedded systems

• embedded system in a small computer in a chip that carries


out dedicated tasks within a larger program.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy