Docsity

Introduction to Computer Science: Algorithms, Data Structures, and Digital Technology - Pr, Schemi e mappe concettuali di Computer Graphics

Toggle sidebar
bg1
COMPUTER SCIENCE
WHAT IS COMPUTER SCIENCE?
The science about representation and processing of information’s.
Association for Computing Machinery (ACM): The study of computers and algorithmic
processes, including their principles, their hardware and software designs, their
applications and their impact on society.
THE COMPUTER
It is a tool for the representation and processing of information. Is a device capable of
executing a set of basic actions or moves executed on data to produce results. The
execution of the various moves is requested in phases (instructions) written in a given
programming language.
VON NEUHMAN ARCHITECTURE
MEMORY
DATA REPRESENTATAION
Data can be number, text, images etc.
Example: representing numbers
0 and 1 ar ethe only number know to the computer
( Binary System)
Ecample: representing characters
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Anteprima parziale del testo

Scarica Introduction to Computer Science: Algorithms, Data Structures, and Digital Technology - Pr e più Schemi e mappe concettuali in PDF di Computer Graphics solo su Docsity!

COMPUTER SCIENCE

WHAT IS COMPUTER SCIENCE?

The science about representation and processing of information’s. Association for Computing Machinery (ACM): The study of computers and algorithmic processes, including their principles, their hardware and software designs, their applications and their impact on society. THE COMPUTER It is a tool for the representation and processing of information. Is a device capable of executing a set of basic actions or moves executed on data to produce results. The execution of the various moves is requested in phases (instructions) written in a given programming language. VON NEUHMAN ARCHITECTURE MEMORY DATA REPRESENTATAION Data can be number, text, images etc. Example: representing numbers 0 and 1 ar ethe only number know to the computer ( Binary System) Ecample: representing characters

Every character correspond to a number PROGRAMMING It is the activity with which we set the computer to execute a set of actions on some given data with the purpose of solving a problem. BIG DATA SCIENCE Create programs capable of analysing huge quantities of data with the purpose of understanding its meaning. PHYTHON HISTORY The language was originally developed in 1991 by Guido Van Rossum. Its name was based on Monty Python’s Flying Circus. ALGORITHMS The problems are solved through the execution of algotithms. An Algorithm is a finite sequence of moves which solves a class of problems in a finite time. Coding is the phase of writing an algorithm trought an ordered set of senteces (“Instructions”), written in some programming language, which specify the actions to be performed. A PROGRAM A program is a text written according to the syntax and semantics of a programming language. A program may not be an algorithm example ( traffic lights). PSEUDO CODE In the 2design” phase, before coding the instructions necessary for the execution of the program. CONTROL INSTRUCTIONS A program needs control instructions:

  • IF/THEN/ELSE : I will choose an instruction (or a block of instructions) instead of another based on a condition.
  • FOR/WHILE : Repeat an operation ( or a block of operations ) while a condition does not change (loop) ALGORITHMS The term ALGORITHM derives from the name of the Arab mathematic Al-Khuwarizmi, who lived in the 9th^ AD. An algorithm is a succesion of instructions or steps that define the operations to be performed on the data to obtain the reluts; an algorithm provides the solution to a class of problems. The execution scheme of an algorithm specifies that the steps must be performed in sequence, unless otherwise indicated. An algorithm is the ordered set of moves or actions that solves a given roblem.
  • It describes the solution method through an ordered set of actions
  • The execution of the actions in the order specified by the algorithm, starting from the input data,allows to obtain the solution of the problem(results). PROPERTIES OF AN ALGORITHM

A strctured block diagram is a block diagram in which flow charts are structured. A flowchart is structured when is satisfies one of the following properties:

  1. Is an elementary scheme
  2. Is a selecion scheme It as been shown from Bohm/Jacopini fundumental programming theorem 1996 that any algorithm can be coded by referring exclusively to a structured algorithm anf therefor by adhering to the three fundameltal structures: THE PSEUDO CODE The psudo-code is a language for the representation of algotithms alternative to the folwchart and without its intrinsic limitations. Its purpose is to make the code understandable, readable and clear; the syntax will therefor be less rigotous that in a real language and the keywords will make its interpretation intuitive. ARCHITECTURE AND NETWORKS THE COMPUTER FROM THE OUTSIDE Main components:
  • Central Unit (case)
  • Video (monitor)
  • Keybord and mouse
  • CD player Accessory componets:
  • Printer
  • Modem
  • Scanner COMPUTER ARCHITECTURE Inspired by the model of the Von Neumann Machine.

VON NEUMAN MACHINE

Fundamental functional units:

  • Processor ( CPU Central Processing Unit)
  • I / O unit (Input/Output)
  • Central Memory (RAM and ROM)
  • System bus DIGITAL TECHNOLOGY CPU, Central Memory and devices ar emade with digital electronic technology. Data and operations are encoded strting from two distinct values of electrical quantities:
  • High voltage
  • Low volgate The two binary digits 0 and 1 are associated with these value ( positive logic and negative logic). Dat aand operations are encoded by bit sequences ( BIT = BINARY DIGIT) CPU is able to operate only in a binary arithmetic, performing elementay operaions: sum and difference, shift…. Working directly on the hardware, the user is forced to express their commands at the machine leven, through bit sequences. CENTRAL PROCESSING UNIT (CPU) It carries out the processing and data transfer, that is, it executes the programs. It is composed of:
  • Clock
  • Registers
  • ALU (aritmetic and logic unit)
  • ControlUnit CPU inside

MAS MEMORY

Stores large amount of informations and the informations are not lost when the machine is turned off. Is much slower to acces to main mamory. Examples:

  • Disks
  • CD
  • DVD
  • ….. CENTRAL MEMORY Relatively limited size, is very quick to access and it’s composed by:
  • RAM (Random Acces Memory) is volatile (it loses its contents when the computer is turnet off), is used to store data and programs.
  • ROM (Reand Only Memory) is persistent ( retains its content when the cmoputer is turned off) but its content is fixed and immutable, used to store system programs. ADDRESSING It is the activity with which the computer selects a particular memory cell. To do this the processor places the address of the desired cell in the Address Register (RI) READ OPERATION Read: The content of the memory cell addressed by the Assress Register is copied to the Data Regster WRITE OPERATIONS Write: The contents of the data register are copied into the memory cell addressed by the Address Register. SYSTEM BUS The sistem bus is a set of different “Communications lines”
  • Data bus
  • Address bus
  • Command bus The Bus connects two functional units at a time, one transmits and the other receives. Data transfer takes place either under the control of the CPU, or by direct memory access (DMA). DATA BUS
  • Bidirectional
  • It is used to transmit data from the memory or vice versa ADDRESS BUS
  • Unidirectional
  • It is used to transmit the contents of the address register to memory COMMAND BUS
  • Bidirectional
  • Typically used to send commands to the memory or to a peripheral (printer)
  • Can be used to sent commands to the processor in the case of DMA or I/O interfaces OPERATING SYSTEM SOFTWARE Programs that are run by the system. Distincion between:
  • Basic software (ex Operating system)
  • Application software So the software is a set of programs with a layared organization, each with higher level functionality than those below OPERATING SYSTEM: Set of programs that manage computer resources ( memory, CPU, file system ….) and that operates on top of hardware and firmware and manage the hardware components of the computer. The S.O (operating system) translates user requests into appropriate machine instructions, which translate into sequences of electrical values and impulses at the hysical machine level and viceversa. Based on the number of users:
  • Single-user (mnon-user): only one user can use the system at a time.
  • Multi-user(mulit-user): multiple users can interact with the machine at the same time. In the case of several simultaneous users, the Operating System must provide each one with the abstraction of a “dedicated” system. OPERATING SYSTEM CLASSIFICATION Based on the number of programs running:
  • Mono-programmed (mono-task): only one program can be executed at a time
  • Multi-programmed (multi-task): the S.O. it is able to carry out the execution of multiple programs at the same time (while using only one CPU)

File as a logical resource consisting of a sequence of bits, which is given a name. Very powerful abstraction that allows you to treat physically different entities in the same way such as text files, hard drives, printers, directories, keyboards, videos….

  • Ordinary ( data archives, commands, source programs, executables…)
  • Directory ( managed directory by OS only, they contain references to files)
  • Specials (hardware devices, central memory, hard disk…) FILE SYSTEM The file system is organized as a direct acyclic graph (DAG) Each file has:
  • An absolute name, consisting of the path starting from “/” (example. /home/users/readme.txt).
  • A relative name, consisting of the path starting from the current directory FILE SYSTEM NAVIGATION USING THE SHELL Cd [] is used to change the current directory, and thus to move through directories. The parameter is optional -if not given, the command takes you to the home directory. APPLICATIONS Application programs which, making use of the operations made available by the Operating System, provide useful functions for users. Examples (Web Browser, Facebook App on Phone …)
  • They solve user specific problems.
  • They are written in high-level programming languages.
  • They are affected to a lesser extent by the characterstics of the underlying environment architecture (portability). PROGRAMMING ENVIRONMENT It is the set of progems that allow the writing, verification and execution of new programs (software development and testing phases). Components:
  • Editor (SOURCE PROGRAM)
  • Translator ( EXECUTABLE PROGRAM)
  • Debugger ( ELIMINATION OF LOGIC ERRORS) EDITOR It is used to write the source program ( one or more text files containing the coding of a program written in a high-level language). Automatically distinguish (different colors):
  • Directives to the compiler
  • The other keywords of the language
  • The constants
  • User-defined symbols TRANSLATORS The translation of the source program into an executable program is carried out by the 3 programs executed in sequence:
  1. Compiler It has two functions:
  • Syntactic analysis of the source program
  • Transdormation of the source program into an object program or “object code”
  1. Linker A program can be made up of several files, may need other support programs. The linker creates the relocatable executable program by the linking any
  2. Loarder The loader completes the creation of the executable program by loading a relocatable program into the main mamory. DEBUGGER It allows you to run a step-by-step program, checking what happens as you go:
  • Watch windown (varable values)…. Function call stack (function calls). In order to disxover and eliminate logical errors (run-time) not detectable by the compiler. INTERPRETER Translators first translates the whole program and then executes the translated version. In the real world, the translation can also be done intercalated, sentence by sentence, by a third person: the interpreter. This is aslo possible in computer science thanks to interpreter programs (which operates on instructions rather than on sentences). COMPILERS AND INTERPRETERS The translators-compilers transalate the entire program (whithout running it!) and output the executable program. Transaltors-interpreters immediately translate and execute every single instruction of the source program. INTEGRATED DEVELOPMENT EVIROMENT TEXT EDITOR Some editors are “specialized” for programming languages, they provide syntax highlighting and then report errors ecc…. INTEGRATED DEVELOPMENT ENVIRONMENT (IDE) Are a text editor and interpreter really all we need?
  • To spped up the development phases and “order” the code , programmers use more advanced tools.
  • Intregrated development environment (IDE)
  • They usually contain the interpreter itself and other utilities such as the “debugger”. DATA REPRESENTATION AND CODING INFORMATION REPRESENTATION
  • While with other standards the same character can have different encoding, in UNICODE each character has a unique encoding.
  • It has a large industrial diffusion (Miscrosoft, Apple..) ans is sepported by various =S an Internet Browsers. IMAGE REPRESENTATION The images are a “continuous” and not made up of sequences of well-defined objects such as numbers and strings. Therefore, they must first be “discretized” or transformed into a set of distinct parts that can be coded separately with bit sequences. DIGITAL IMAGES Grid of elements called pixels, quantization: how many bits each pixel is represented by. Pixel representattions:
  • The representation in “shades of gray”: on byte per pixel, with 256 shades of gray for each point (black and white images), or more bytes per pixel, to have as many shades as possible.
  • RGB color representation (red, green, blue): commonly 3 bytes per pixel that difine the intensity of each base color. This way I have about 16 million different definable colors. IMAGE REPRESENTATION We try to save memory with the use of a “palette” that contains the subset of the representablr colors that appears in a photo.
  • Each pixel encodes an index within the palette. With compression techniques that do not code each pixel autonomously but try to group the areas that have common characteristics. Most used formats:
  • TIFF (Tagged image file format).
  • GIF (Graphics interchange format).
  • JPEG (Joint photographers exper group). DATA COMPRESSION Lossy algorithms (wich lose informations). They are generally specific to a certain field and exploit the characteristics of the objects to be represented to “throw away” unimportant information. The compression algorithms used in GIF and JPEG formats for still images exploit the characteristic of the human eye of being insensitive to slight color changes in contiguous points, and therefor eliminate these slight changes by flattening the color of the image. It is generally possible to specify how much we are willing to lose through some parameters. IMAGES REPRESENTATION Moving images (VIDEO..)
  • Movement is already discreetly represented in the media: with a rairly high number of fixed frames (24-30 per second) the human eye perceives movement as a continuum.
  • In principle I could encode each frame separately as a still image, but the memory space required would be enourmus.
  • Coding methods have therefore been developed that economize, encoding only the “differences” between one frame and another (MPEG). SOUND REPRESENTATION The accurancy of the reconstruction depends on:
  • How small the sampling intervals are.
  • How many bits I use to describe the sound in each sample in the quantization stage.
  • As usual…higher accurancy means more memory accupied! Lossy algorithms for sounds: they take advantage of the fact that for the human ear, low-volume sounds superimposed on others of greater volume are not very audible and can be eliminated. This is what happens in the MP3. MIME STANDARD MIME (Multiple INTERNET mail extension) Is a standard that allow you to correctly recognize the encoding of data of a different nature (text, images, sounds…). Often used in data transmission, to inform the recipient of the type of data transmitted (the encoding used). A MIME encoding includes:
  • A preamble (header), in whihch the type of the data we are encoding is specifies in a standard way (text / plain, image / jpeg, image / gif )
  • A body, which contains actual coding. BOOLEANS BOOLEAN ALGEBRA Dsigned by Boole, an English mathematician of the nineteenth century, it was only from the beginning of the twentieth century with the first calculation system and is based on:
  • Logical or Boolean variables: thet can take only values:0 and 1
  • Boolean Functions F(x,y,z) which can assume only two states: true and false TRUTH TABLE Each Boolean function is characterized by its own thruth table
  • X, Y, Z Boolean Variables
  • F(X; Y; Z) Boolean functions LOGICAL OPERATORS