Site Visited 498534 times | Page Visited 32 times | You are in : Etantonio/EN/Universita/1anno/FondamentiInformatica/Pascal/ |
Given Pascal and structures Types Di Dato1) Describe the type of data INTEGER: Draft of variable byte constituted from 2 and therefore can be assumed values comprised between -215 and 215-1, On they can be executed the following operations: addition - removal * multiplication DIV gives back the entire part of the quotient MOD gives back to the rest della division in fact the given back value gives to MOD B is the entire minimum not negative that can be embezzled to To in order obtaining an entire multiple of B. succ(x) gives back entire following n° pred(x) gives back the n° entire previous
2) Describe the type of data REAL: It is a type of implemented data in order to identify the real numbers, is expressed in mobile virgola. Given that she is a type it does not order them are impossible the operations pred and succ while they become necessary of the rounding operations: trunc(x) gives back the entire part of n° real the x round(x) gives back entire the more neighbor n° real to the x
3) Describe type CHAR: It is used in order to implement the characters immessi from keyboard, on it are possible the following operations: ord(c) gives back associated code ASCII to character c chr(i) gives back the associated character to code ASCII i succ(c) gives back to successive code ASCII to that one correspondent to character c pred(c) gives back to code ASCII previous to that one correspondent to character c
4) Describe the type of data BOOLEAN: It is a type of since the manipulation of logical operations concurs, normally is associated to variable that act as as an example from Flag for the escape from the cycle when one determined condition is true. Pu² to only assume the values TRUE or FALSE, 1 or 0. A particular case of I use on the entire numbers is: Odd(x) is true if the n° he is uneven
5) As the type of data is defined enumerated: It is a type of data defined therefore: TYPE name = (tipo_1, tipo_2..., tipo_n) the types can as an example be the days of the week or the seeds of a bunch of papers etc... Defining the type of enumerated data concurs uses it of the functions succ(x), pred(x) and ord(x) this last one takes advantage of the fact that to every type comes associated n° an entire N from 0 to N and gives back therefore this number.
6) Describe the type interval: The definition of this type concurs to choose an interval of an entirety orders defined them already, that becomes through the TYPE name possible = inferior limit. advanced limit the sets already defined they are the entire numbers, the character set âA'.. âZ' and defined the very small correspondent âa'.. âz' and part of the sets can also be used through the type of enumerated data. The greater usefullness of this instruction is to make available only that that is really necessary that it can be a complication for the programmatore but facility in characterizing eventual trabocchi of the variable ones is also one.
7) As they come it uses the types you for the variable and constant definitions of: For the constants they do not come uses you the types in how much come directly inizializzate to the value, the sintassi is: Nome_costante CONST = value For the variable ones the types must before be defined and then the variable ones that use them, the sintassi is: Nome_variabile VAR: tipo_variabile
8) What is the types record and like they are defined: Draft of a type in a position to conglobare not homogenous types which describe but an only entity like the date that is constituted from entire for the day one tightens for the month and an other entire one for the year. They are defined through: TYPE tipo_record = RECORD variabile_1: tipo_variabile_1; ............. variabile_n: tipo_variabile_n END; This type is often to the base of the Array in fact through it can be defined the constitution of the single line of the Array.
9) As the content of a record can be changed: Through the instruction: nome_record.nome_campo: = nuovo_valore
10) Describe the type of ARRAY data: The Array is structures that concur to group variable with characteristics in common, in particular the lines of the Array is all equal ones and can be constituted from with more variable also than various type.
11) In that way can be defined one variable of bidimensional Array type: Direttamente VAR nome_array: ARRAY [ tipo_intervallo_1, tipo_intervallo_2 ] of tipo_righe Indirectly defines before the new type through the instruction TYPE tipo_array = ARRAY [ tipo_intervallo1, tipo_intervallo_2 ] of tipo_righe and then declares one variable of those tipo VAR nome_array: tipo_array where tipo_righe it can be is a normal type that a record. 12) As an element of an Array can itself be modified: Through the instruction nome_array[ line, column ]: = nuovo_valore
13) Describe the type of data Together: It is a type of since the implementation of the sets stico calculation concurs, is defined with through: TYPE nome_set : = SET OF tipo_elementi The eseguibili operations on the sets are following: To B gives back to the entirety union of To and B To * B gives back to the entirety intersection of To and B A - B gives back with of the values that are in To but not in B To: = To [ X] it adds element X to with To To: = A - [ X] eliminates element X from with To The eseguibili tests on the sets are following: To = B To is equal to B ? A B To is various from B ? To < = B To is contained in B? To > = B To contains B ? el IN B the element el is contained in B?
14) Describe the type of data Gunlayer: The scope to accommodate memory addresses is a type of having data rendering possible implementazioni of lists and trees through one dynamics management of the memory. Being that given various they occupy in memory you space some various achieves that the type of aimed data the gunlayer must be specified through the instruction: TYPE tipo_di_dato_puntato gunlayer = ^
15) Which instructions concur to associate an element to a gunlayer or of disassociarlo: NEW(nome_puntatore) asks the Sysop an element to associate to the gunlayer DISPOSE(nome_puntatore) yields to the Sysop the space occupied from the element associated to the gunlayer. 16) As it is made to associate a value to the field given of the record aimed from PUNT: Through the instruction: punt^ dati: = value in a generalized manner utilizza punt for operations on the gunlayer and for operationsis used instead punt^ on the element aimed from the gunlayer.
17) Which instruction is used for the breaking in of a value from part of the customer and which for the press to video: Input read(variabile); Output write(âtesto', variabile); Structures of control18) Which are the structured instructions: Composed instruction is groups of instructions that go executed in the order in which son written they begin with BEGIN and end with END. Instruction ripetitiva is groups (WHILE condition GIVES), (REPEAT istruzioni UNTIL condition) and ( the contatore FOR: = n to m I GIVE instructions) Instruction conditions them Is groups (IF condition THEN istruzione_1 ELSE istruzione_2) and (HOUSES variable OF caso_1: istruzione_1; caso_2: istruzione_2;... ; caso_n : istruzione_n END) Instruction WITH variable Servants with of type record laddove is wanted to be approached the fields of a same record in order to modify them and it is wanted to be avoided to always use the structure: nome_record.nome_campo: = nuovo_valore is used instead sintassi WITH nome_record Do nome_campo: = nuovo_valore;
19) Characteristics of cycle WHILE: It is a cycle that could never also be executed inasmuch as the condition is in head, is not exited from the cycle in the case that the condition is false.
20) Characteristics of cycle REPEAT: It is a cycle which it comes always executed at least once inasmuch as the condition of is the last instruction, is exited from the cycle only if the condition is true. To notice that BEGIN are not necessary and END if the instructions that are between REPEAT and UNTIL are more than in how much this last ones they act as already of for if from delimitatori.
21) Which he is the greater one I use of the instruction HOUSES: It is used laddove is wanted to be avoided I use it of nested instructions IF THEN ELSE, that that is made is instead to take a variable one and to define what must be made for everyone of the various values that it can assume. Procedures and functions22) To what it serves and which procedure is the format of one: The procedure or sottoprogramma servants to render more leggibili the programs and very adapted to a philosophy of development TOP-DOWN in which before the functionalities are defined generate them and then she is come down in the specific one. Un example is PROCEDURES nome_procedura(parametro_formale_1..., parametro_formale_n); variabile_locale VAR: type; BEGIN instructions; END; an example of call of this procedure is : name _ procedura(parametro_formale_1..., parametro_formale_n) 23) To what it serves and which function is the format of one: The function is a particular case of procedure which gives back a single value and it gives back it through its name that is behaved therefore like one variable. Un example is FUNCTION nome_function (parametro_formale_1..., parametro_formale_n): tipo_di_dato_restituito; variabile_locale VAR: type; risultato : tipo_di_dato_restituito; BEGIN instructions; turned out : = nome_function ; END; an example of call of this function is : a:= name _ function (parametro_formale_1..., parametro_formale_n); where to it is one variable of the same type given back from the function.
24) What is the meaning for parameters forms them and parameters put into effect them: The parameters form them are of the generic parameters object of the elaboration of the procedure or the function, generic in how much a procedure or function not chip ax in income one determined variable bens¬ a tipologia of variable that it renders it usable in more contexts. In particular: Parameters formali are those generic ones on which the procedure or function works Parameters attuali are that real that the program supplies to the procedure or function and this of it replace the value to the parameters form them.
25) How many typology of passage of the parameters are: to) passage for valore Viene supplied to the procedure only a variable copy of variable and the same one which therefore cannot be modified from the procedure which cannot only modify the copy. As an example: PROCEDURES nome_procedura(parametro_formale_1: tipo_variabile) cannot alter the value of variable the X supplied from the instruction name _ procedura(X) b) variable passage for Viene supplied to the procedure the variable one which therefore cannot be modified from the procedure. This modality is used ogniqualvolta is necessary to obtain of the values of return from one procedure. As an example: PROCEDURES nome_procedura(VAR parametro_formale_1: tipo_variabile); can alter the value of variable the X supplied from the instruction name _ procedura(X)
26) What is the meaning for ricorsione: It is a programming methodology that stretches to estrinsecare a way to reason that it is then that one of the mathematical induction, in practical draft of a function which between its instructions of it has also one that the same function recalls. It is from noticing that every time that the function recalls if same the calling function only is interrupted and will resume its execution once that the execution of the called function will be completed. Every ricorsiva call moreover generates variable which has the same name but they are completely different from the variable ones of the calling function.
27) When a variable one is local and when instead he is total: A variable one is local to the procedure when it is defined between the definition of the procedure and the BEGIN of the same one, is instead total when it is defined externally to the procedure. Files28) What is the meaning for Rows and how many typology ve are some: Rows are with of data that so are extended from not being able to reside in memory, ve of are substantially 2 types: to) Rows interni draft of Files of temporary use whose contained it can go lost to the term of the program b) Rows esterni draft of Files whose contained it cannot go lost to the term of the program and therefore are needed of being memorizza you on physical supports which tapes and floppy disk. In the implementazioni to the rows physical a variable one is associated buffer that it acts as from interface.
29) As one assigns rows to one variable buffer: A variable one buffer concurs to read the values contained in the rows, is assimilable to a logical interface, is assigned through the instruction ASSIGN(nome_buffer, ' NOME_FILE.DAT') where nome_buffer it must preventively have been declared throughthe VAR nome_buffer: ROWS OF tipo_elementi
30) As one prepares rows for the writing: Through comando the REWRITE(buffer_file) which it cancels the content of the rows and it is prepared to write being placed itself it on 1° the element of the same one.
31) As it can be written rows: It is necessary the following brace of commandos: buffer_file^: = valore_da_write writes the value on the variabile_buffer PUT(G) Trascrive the value from the buffer to the rows. Given the recurrent use of the brace of the previous ones instruction has been predisposed one that the congloba: WRITE(buffer_file, value) writes the value on the rows
32) As one prepares rows for the reading: Through comando the RESET(buffer_file) which it places in buffer 1° the element read from the rows.
33) As it can be read rows: It is necessary the following brace of commandos: variable : = buffer_file^ assigns the value on the buffer to one variable GET(G) associates to buffer the value of the successive member of the G rows Given the recurrent use of the brace of the previous ones instruction has been predisposed one that the congloba: READ(buffer_file, variabile) reads a value from the rows and it assigns it the variable one 34) As one closes rows: Through comando the Close(buffer_file). Structures of data35) How many and which given structures are possible: Structures lineari List sequenziale representation representation collegata simple circular symmetrical Pila Tail Structures alineari Albero Binary simple of search N-ario Graph Lists36) What is a list and which operations must be concurred on every type of list: A list is with of data all of the same type characterizes from one order relation to you. The typical operations are: cons insertion of an element in head to the list car reads the value of 1° the element of the list cdr eliminates 1° the element of the list and of it it gives back the value null verification if the reference to beginning list is NIL (gunlayers), 0 (matrices) or not. Insertion of an element in one position whichever of the list. Elimination of an element from one position whichever of the list.
37) Describe the sequenziale representation of the lists and its disadvantages: It is a representation that generally comes implemented through a record of name LIST constituted from a field of containing unidimensionale Array type the elements in the order, a FIRST field that identifies 1° the element of the list on the Array and a field indicating LENGTH the length of the same list. The disadvantages are that the dimension of the Array must not dynamically be defined a priori and based on the real occupation of the list, that can generate memory waste or trabocco of the ability to accommodate elements, moreover every time that immette or removes an element from a middle position is necessary to make to slide all the other elements.
38) Describe the connected representation of the lists: Of this representation ve of they are 2 possible implementazioni: through Matrici Risolve the problem of having to make to slide all the elements when immette or removes an element intermediate of the list. through Puntatori Consente to only occupy the necessary space of memory. Both the methods are base to you on the idea to associate to every element of the list beyond to the data also the position where to find the successive element of the list.
39) Describe the connected representation of the lists implemented on Array: An Array constituted from records everyone is had of which is formed from a GIVEN field having contained the information and from a SUCCESSIVE field containing the position in the Array of the successive element, the last element of the list will contain value 0 in the SUCCESSIVE field while the position in the Array of 1° the element of the list is identified from one variable. It comes then defined a free list which cooperates with the real list in how much supplies them elements when an element wants itself to be added to the real list while when an element from the real list wants itself to be eliminated, it is this last one to yield the record interested to the free list. Both the lists are described from a type record LIST whose fields are FIRST LENGTH and.
40) Describe the connected representation of the lists implemented through gunlayers: Every element of the list is implemented on a record formed from a GIVEN field having contained the information and from a SUCCESSIVE field of type gunlayer which the tip to the memory lease where it begins the successive record. The last element of the list is characterized from a value NIL in the SUCCESSIVE field to indicate that not null tip. Allorchè becomes a new record necessary in order to add an element to the list, if ago demanded some to the Sysop through the NEW(puntatore) instruction which associates to the variable gunlayer the address of the lease to use in order memorizzare a new element. When it is wanted instead to be eliminated an element is good norm to give back the record to the direct management of the Sysop through the DISPOSE(puntatore) commando. One variable FIRST of punta_elemento_lista type apt is necessary moreover to always identify 1° the element of the list. Battery41) What is one battery structure: Draft of a linear structure of assimilable type LIFO to a battery of plates where the last one that has been immesso will be also the 1° to being removed. The typical operations on this structure are: Top Returns the emerging element that is that inserting of last Push Inserisce a value in the battery Pop Elimina from the battery the emerging element and of gives back the GIVEN value of the field Test_Pila_Vuota Controlla if the reference to 1° the element of the battery is NIL(puntatori), 0 (matrices) or not. Crea_Pila Pone to NIL(puntatori) or 0 (matrices) the reference to 1° the element of the battery
42) In how many ways the implementation of one is possible battery structure: Be a matter of a linear structure former, it is much similar alla list della which indeed sense turns out to be only a limitation nel that in a battery is concurred to only add and to eliminate elements to a same end della. In virtue of that the implementazioni are therefore possible are through matrices that through gunlayers. Tail43) What is one structure to tail: Draft of one linear structure of assimilable type FIFO to the tail that makes in a Swiss post office them. The typical operations on this structure are: Primo Returns the inserted element for first in the tail and that therefore it will be the first one to exit. In_coda Inserisce an element in the tail will have therefore to be modernized the LAST reference Out_coda Elimina the element of the tail aimed from FIRST and of it gives back the GIVEN value of the field Test_Coda_Vuota Controlla if the reference to 1° the element of the tail is NIL(puntatori), 0 (matrices) or not. Crea_Coda Pone to NIL(puntatori) or 0 (matrices) the references FIRST and LAST.
44) In how many ways the implementation of one is possible structure to tail: Be a matter of a linear structure former, he is much similar one to the list, in virtue of that are therefore possible the implementazioni is through matrices that through gunlayers, both must possess of the references are to 1° the element of the tail that to the last element of the tail through record a CODA | FIRST | LAST | Tree45) What is a tree and how many types ve are some: Draft of a not linear structure particularly adapted to represent situations to hierarchical character. The elements represent the nodes of the tree, from every node other elements can dipanarsi that are said sons while the node parent is said father or root in the case that does not have fathers, if a node does not generate sons then comes said leaf in how much finishes them. The level of a node is equal to the n° of nodes to cover in order to catch up the root. The structure in such a way described is lend very well to being analyzed in ricorsiva shape. The types of tree are: Tree binary every node can have to the maximum 2 sons Tree N-ario every node can have n sons
46) Which are the typical operations on the binary trees: Costruisci Returns a tree formed from one root and a left sottoalbero and one skillful. Radice Returns the value associated to the root Left Returns the left sottoalbero of the binary tree Right Returns the skillful sottoalbero of the binary tree Test_Albero_Vuoto Controlla if the tree is empty or less
47) Describe the visits in Preordine, Postordine, Symmetrical: Preordine analyzes to the root therefore the left sottoalbero finally the skillful sottoalbero Postordine analyzes il sottoalbero left, then the skillful sottoalbero and finally it analyzes the root Simmetrica Analizza before the left sottoalbero therefore the root and finally the skillful sottoalbero.
48) Give the outcome of the 3 typology of the following visit on of tree: Preordine : ETA, CARL, MARIA, MARGHE, LISA, BETSY, GENNY, BARBARIAN, CHRISTIAN. Postordine : MARIA, LISA, BETSY, MARGHE, CARL, BARBARIAN, CHRISTIAN, GENNY, ETA. Simmetrica : MARIA, CARL, LISA, MARGHE, BETSY, ETA, BARBARIAN, GENNY, CHRISTIAN.
49) Describe the connected representation , through records and gunlayers, of a binary tree: Every element and therefore every node of the tree is simulated from a record constituted of 3 lives: SINISTRO is a gunlayer to the left sottoalbero, is NIL if the left sottoalbero is empty VALORE contains the information associated to the node DESTRO is a gunlayer to the skillful sottoalbero, is NIL if the skillful sottoalbero is empty It is then necessary one variable that it heads for the root of the tree.
50) What is a binary tree of search: It is a characterized binary tree from the fact that every node is such that the nodes of the sottoalbero of left contain smaller or equal values regarding the considered node while the nodes of the sottoalbero of right contain greater values regarding the same node. It comes defined binary tree of search in how much lowers in considerable way the necessary times for the search of a value in how much to every step of the search eliminate half of the elements. Graph51) What is a Graph : Draft of a not linear structure particularly adapted to represent binary relations on of with of elements, to example very lend al better problem del covered in order to pass from a room of a maze to an other stanza. substantially distinguishes dagli trees for the possibility to catch up a same node through 2 various distances that it renders necessary one marcatura goddesses nodes visitati .
52) That types of visits are possible on a Graph : In profondità the departure node is analyzed and for every successor the same what is made In Ampiezza the successory ones of a node are analyzed to all and then the successory ones of the successory ones are analyzed.
53) As a graph is represented on a computer: Fà reference to a matrix of the adjacency where there are many lines and many columns how many are the nodes, is a true logical value in a cell of the matrix if there is a branch that joins the 2 correspondents nodes. An other carrier is then necessary to indicate if a determined node already has been visited. |