This file contains questions asked by students along with the answers provided. (The identity of the students will not be included) New Q&A will be added at the top of this file as they arrive -- it's a stack. ----------------------------------------------------- Question 10 Feb 10 I hear there is a solution to A2 being circulated. How will this affect marking? Answer Please see the opening paragraphs in the section for Assignment 2 on the course home page. ----------------------------------------------------- Question 9 Feb 6 How does the merge work? See the course web page for more information (see the section on assignment two). ----------------------------------------------------- Question 8 Feb 6 What is "self" for? It is basically a reference to your self. It is a way of referring to the object that is executing the procedure or function. For example if you needed to pass a pointer to the current object from within a function or a procedure being executed by the current object. It might be done like: otherobject->Procedure(self) Self is built into turing and doesn't need to be declared. C++ has something similar called "this". The text has references to self on pages 277 and 303. Question 7 Feb 3 More examples have been added to "Additional Reading/Pointers" Possible cause of bugs: Functions that have no parameters still require () after them. eg element->GetRow() You are supposed to run the file spmat.dem If you run the file spmat.tu, it complains that you cannot run a class. If you run the file spmat2.tu, it does not know that this is to be included a part of a file and it simply tries to run it. The error will be something like, "count has not be declared" Solution: In the window for spmat.dem, go to the menu File/"Fix main Program" Now when you hit "Run" in any window, this file is executed. ----------------------------------------------------- Question 6 Feb 2 - What does the following question (from Section 3.1) mean: - "At what ratio of nonzero elements to the total number of matrix - elements (=RxC) does a sparse matrix use less space than the standard - method of storing matrices." R = number of rows and C = number of columns Let NZ be the number of non zero elements so: ratio = NZ/(RxC) What does this ratio have to be so that the sparse method uses less space than the standard method? ----------------------------------------------------- Question 5 Jan 30 > In section 3.1 what does it mean by "asymptotic" and "BIG O", We have not actually covered this yet, but in short it means - drop low order terms - drop the multiplicative constant eg 3n^3 + 1000n^2 + n + 29 is Big O of n^3 > What does "amount of overhead for square matrices with all nonzero > elements" mean? Overhead is a term to mean the amount something costs before you even start. In this example, it is asking for the number of bytes of memory used to store a matrix that has no elements. > In Section 4.2, What is the purpose of the parameter ColRow passed to > GetDate ? >> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% >> % GetData returns the value of a data item represented in the array. >> % If rowCol = 'r', the search is along a row list. If rowCol = 'c', the >> % search is along a column list. >> % >> % Precondition: 1 <= row <= maxRow and 1 <= col <= maxCol >> % and rowCol in {'r','c'} >> % Postcondition: data at element >> >> function GetData(row, col : int, rowCol : char) : int >> end GetData GetData(2,3,'c') It queries the value of the matrix at entry (row=2, col=3) If the element is not there, then the entry is zero This element can be found in two ways. r - search through the col linked list starting at rowList(2) c - search through the row linked list starting at colList(3) ----------------------------------------------------- Question 4 Jan 29 How can we use assertions for GetData and ExistsElement in a sparse matrix. Section 4.2 describes assertion testing but we do not hand in the file massert.dem (See Question 3). Answer *** NEW REVISED 8pm JAN 29 *** The three demonstration related *** files. An Assert command has been added to the demonstration. The *** revised sample.in and sample.out files show how this is similar to *** using an assert in OOT but you can have multiple asserts be false *** and still continue the demonstration. ----------------------------------------------------- Question 3 Jan 29 What do we do about the file massert.dem mentiond in section 4.2 of the specification. Answer Do not hand in massert.dem. It was suggested you use this to test out your programs to save you time. You should later add similar assertions to your input file for the demonstartion program. See Question 4. ----------------------------------------------------- Question 2 Jan 29 What is a report? What do you mean by professional report? Answer A link (pointer), from the home page for the course, points to a file answering those questions. The link is in the fourth paragraph of the section on Assignments. URL http://www.cs.yorku.ca/Courses/1030/whatisareport.text ----------------------------------------------------- Question 1 Jan 27 The specification refers to the file arrelem.tu in section 3.2 and to the class SparseArrary at several points. Where and what are they. Answer They are editing errors. SparseArray should be SparseMatrix, and arrelem.tu should be matelem.tu