精華區beta NTU-Exam 關於我們 聯絡資訊
課程名稱︰計算機概論 課程性質︰ 課程教師︰張璞曾 開課系所︰電機系 考試時間︰2006/6/14 試題 : 1.Rewrite the following program segment using a single case statement instead of nested if-then-else statements.(6%) if(W=5) then(Z<-7) else(if(W=6) then(Y<-7) else(if(W=7) then(X<-7) ) ) 2.(a)Suppose the variable X in a program was declared to be of type integer. What error would occur when executing the program statement X<-2.5 ?(3%) (b)Draw the parse tree for the expression" x*y+y/x " (3%) 3.Suppose the procedure modify is defined by Procedure Modify(Y) Y<-9; Print the value of X; Print the value of Y; Also suppose that X is a global variable. Id parameters are passed by value, what will be printed when the following program segment is excuted? What if parameters are passed by reference?(6%) X<-5; Apply the procedure Modify to X; Print the value of X; 4.(a)Why would a large array probably not be passed to a procedure by value?(3%) (b)What is the diffrence between the public and private parts of a class? (3%) 5.The factorial of 0 is defined to be 1. The factorial of a positive integer is defined to be the product of that interger times the factorial of the next smaller nonnegative integer. We use the notation n! to express the factorial of the integer n. Thus the factorial of 3 (written 3!) is 3*(2!)=3*(2*(1!))=3*(2*(1*(0!)))=3*2*1*1=6 Design a recursive algorithm that computes the factorial of a given value. (10%) 6.Use big-theta notation to classify the traditional grade school algorithms for addition and multiplication. That is ,if asked to add two numbers each having n digits, how many individual additions must be performed? If requested to multiply two n-digit numbers, how many individual multiplications are required? (10%) 7.Answer the following questions in terms of the list: Alice, Byron, Carol, Duane, Elaine, Gene, Iris. (a)Which search algorithm (sequential or binary) will find the name Gene more quickly? why? (2%) (b)Which search algorithm (sequential or binary) will find the name Alice more quickly? why? (2%) (c)Which search algorithm (sequential or binary) will detect the absence of the name Bruce more quickly? why? (2%) (d)Which search algorithm (sequential or binary) will detect the absence of the name Sue more quickly? why? (2%) (e)How many entries will be interrogated when searching for the name Elaine when using the sequential search? How many will be interrogated when using the binary search? And explain it. 8.What is the diffence between coupling and cohesion? Which should be minimized and which should be maximized? why? 9.What problems could arise during the modification stage if a large program was designed in such a way that all of its data elements were golbal?(6%) 10.Disign an algorithm for printing a linked list in reverse order using a stack as an auxilliary storage structure.(10%) 11.Draw a diagram showing how the binary tree below appears in memory when stored without pointers using a block of contiguous memory cells. (6%) Z / \ T W / \ P R / \ H J 12.(a)What is the difference between a user-defined data type and a primitive data type?(4%) (b)What is the difference between an abstract data type and a user-defined data type?(4%) 13.Suppose an array with six rows and eight columns is stored in row major order starting at address 20. If each entry in the array requires only one memory cell, what is the address of the entry in the third row and fourth column? What if each entry requires two memory cells? (6%) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.7.59