QUESTIONS T2

Ace your homework & exams now with Quizwiz!

B T or P

RESOLVENT OF THE FOLLOWING CLASSES Q or P or T ?

Imperative requires that a programmer describes an algorithm for solving at hand Declarative requires that the programmer describes the problem

The distinction between the imperative and declarative programming paradigms?

C++

Which of the following is an example of a language that is based on the object oriented paradigm A. LISP B. PROLOG C. C D. C++

PROCESS

1. Which of the following is an activity? A. Algorithm B. Program C. Process

5000

10. At most, how many entries in a list of 5000 names will be interrogated when using the sequential search algorithm? ___________

ANSWER: A THETA(Lgn)

10. The binary search algorithm is an example of an algorithm in which of the following classes? A. (lg n) B. (n) C. (n lg n) D. ( n 2 )

ANSWER: The value reported should be X - 1.

10. The following procedure was designed to compute the largest integer whose square is no greater than N, where N is assumed to be a positive number. (If N is 5, then the procedure should report the value 2.) Find and correct the error. procedure squareroot (N) X 0; while (X2 N) do (X X + 1); report the value of X

ANSWER: B X > 4

11. Under the assumption that X takes on only integer values, which of the following is the termination condition for the following loop? while (X < 5) do ( . . . ) A. X < 5 B. X > 4 C. X < 4

Sequential

11. Which of the sequential or binary search algorithms would find the name Kelly in the list John, Kelly, Lewis, Maurice, Nathan, Oliver, Pat, Quincy, Roger, Stan, Tom more quickly? _______________

ANSWER: A

12. Under the assumption that X takes on only integer values, which of the following is the termination condition for the following loop? repeat ( . . . ) until (X < 5) A. X < 5 B. X > 4 C. X > 5

BINARY

12. Which of the sequential or binary search algorithms would find the name Roger in the list John, Kelly, Lewis, Maurice, Nathan, Oliver, Pat, Quincy, Roger, Stan, Tom more quickly? ____________

ANSWER: B N>4

13. Under the assumption that N takes on only integer values, which of the following is the termination condition in the following recursive procedure? procedure xxx (N) if (N < 5) then (apply the procedure xxx to the value N + 1) else (print the value of N) A. N < 5 B. N > 4 C. N < 4

ANSWER: A N<5

14. Under the assumption that N takes on only integer values, which of the following is the termination condition in the following recursive procedure? procedure xxx (N) if (N < 5) then (print the value of N) else (apply the procedure xxx to the value N - 1) A. N < 5 B. N > 4 C. N > 5

ANSWER: D X<=5

15. Which of the following is a loop invariant at the point at which the test for termination is performed in the following loop structure? X 3; while (X < 5) do (X X + 2) A. X > 5 B. X < 5 C. X 5 D. X 5

ANSWER: B X<8

16. Which of the following is a loop invariant at the point at which the test for termination is performed in the following loop structure? X 3; repeat (X X + 2) until (X > 5) A. X > 5 B. X < 8 C. X 5 D. X 6

ANSWER: B N=0

17. Which of the following is the base case in the recursive procedure below? procedure xxx (N) if (N = 0) then (print the value of N) else (apply the procedure xxx to the value N - 1) A. N > 0B. N = 0 C. N < 0

ANSWER: C Assertions

18. Preconditions, postconditions, and loop invariants are examples of which of the following? A. Pseudocode B. Iterative structures C. Assertions D. Recursion

ANSWER: C X X + 1) until (X > 6)

19. Which of the following does not print the same sequence of numbers as the others? A. X 5 B. X 4 C. X 5 while (X < 6) do while (X < 5) do repeat (print the value of X; (X X + 1; (print the value of X; X X + 1) print the value of X) X X + 1) until (X > 6)

PROGRAM

2. Which of the following is a representation? A. Algorithm B. Program C. Process

ANSWER: A Stepwise Refinement

20. Which of the following is not a way of representing algorithms? A. Stepwise refinement B. Pseudocode C. Flowchart D. Programming language

ANSWER: B X+1

3. Which of the following set of instructions defines an algorithm in the formal, strict sense? A. X 3; B. X+1 3; C. X 3; while (X < 5)do while (X < 5) do while (X < 5) do (X X) (X X + 1) (X X - 1)

ANSWER: No, the instructions are not executable (not effective).

4. Do the following instructions define an algorithm? Explain your answer. Write down all the positive odd integers. Select the integer in the middle of the list. Print the even integer that is one less than the selected odd integer.

D Assignment Statement

4. Which of the following is not a means of repeating a block of instructions? A. Pretest loop B. Posttest loop C. Recursion D. Assignment statement

ANSWER: A LEWIS

5. When searching within the list Lewis, Maurice, Nathan, Oliver, Pat, Quincy, Roger, Stan, Tom which of the following entries will be found most quickly using the sequential search algorithm? A. Lewis B. Pat C. Tom

ANSWER: B PAT

6. When searching within the list Lewis, Maurice, Nathan, Oliver, Pat, Quincy, Roger, Stan, Tom which of the following entries will be found most quickly using the binary search algorithm? A. Lewis B. Pat C. Tom

ANSWER: C Alice Sylvia Nancy Lois

7. Which of the following lists would not be obtained at some point when applying the insertion sort algorithm to the list below? Sylvia Nancy Lois Alice A. Nancy B. Alice C. Alice D. Lois Sylvia Lois Sylvia Nancy Lois Nancy Nancy Sylvia Alice Sylvia Lois Alice

Answer B Theta(n)

8. In general, an algorithm in which of the following categories is considered more efficient? A. (lg n) B. (n) C. (n lg n) D. ( n 2 )

ANSWER: 13

9. At most, how many entries in a list of 5000 names will be interrogated when using the binary search algorithm? ___________

Answer D THETA(n^2)

9. The insertion sort algorithm is an example of an algorithm in which of the following classes? A. (lg n) B. (n) C. (n lg n) D. ( n 2)

homogenous heterogeneous

A ___ array is an array in which all entries are of the same type whereas entries in _____ array may be of different types

Program

A representation of an algorithm (perhaps nonterminating algorithm)

Second generation

Assembly Languages are ____

formal paramater (DATA TO BE EXECUTED) is used in a subprogram unit to refer to that data to be executed an actual paramater (DATA GIVEN TO THE SUBPROGRAM UNIT) is that data that is given to the subprogram unit

Difference between a formal paramater and an actual paramater?

a procedure returns values via paramaters and variables a function returns a value as the "value of the function"

Difference between a procedure and a function?

translate the program is to convert it to another language interpreting the program is to execute it directly from its language form.

Difference between translating a program and interpreting the program?

global variable is readily accessible throughout the program whereas a local variable is accesibale only within a specific area

Distinction between global and local variables?

Third generation

High Level Languages are____

ANSWER: The termination condition will never be reached because X will always be odd.

Identify a flaw in the control of the following loop. X 3 while (X 8) do (X X + 2)

No, the process will terminate because X will become negative due to overflow.

If numeric values are represented in two's complement notation, does the following program represent an infinite process? Explain your answer. X 2 while (X > 0) do (X X + 1)

A list of the formal paramters

In addition to the procedures name what other information is contained in a typical procedure header?

natural formal

In contrast to ____-languages such as english and spanish, programming languages are considered ____ languages and are rigorously defined by their grammar.

method

In the context of object oriented paradigm, a ______ is an imperative program unit that describes how an object should react to a particular stimulus.

Classes Objects

In the context of object oriented paradigm,____ are templates from which ____ are constructed

Integer, Real, Boolean, Character

List four data types that occur as primitive types in many high level programming languages?

Name of Variables Data types Data structures

List three items of information that would be contained in a typical parsers symbol table?

ANSWER: the assignment statement using , the if-then-else statement, the while statement, the repeat statement, and the definition and activation of procedures. WHILE REPEAT IF THEN

List three of the primitives in the pseudocode developed in this chapter. ____________________ ____________________ ____________________

They are machine dependent they require an algorithm be expressed in small machine steps

List two disadvantages of both machine languages and assembly languages that are overcome by high level programming?

First Generation

Machine Languages are____

Imperative paradigm

Most machine languages are based on the ______

Indicies

Positions within arrays are identified by means of numbers called A. Indicies B. Paramaters C. Instance Variables D. Constants

If while else for class

Three examples of key words that are often found in high level languages?

INTEGER = Twos Compliment Real= Floting Point Character = ASCII

What encoding system is usted to encode data of each type? INTERGER= REAL= CHARACTER=

ANSWER: 3

When searching for the entry X within the list R, S, T, U, V, W, Z how many entries will be considered before discovering that the entry is not present? (Note that the list is in alphabetical order.)? ____________

ANSWER: A Lewis

When searching within the listLewis, Maurice, Nathan, Oliver, Pat, Quincy, Roger, Stan, Tom which of the following entries will be found most quickly using the sequential search algorithm? A. Lewis B. Pat C. Tom

Answer C do-while

Which of the following Java statements is guaranteed to loop at least one time?A. for B. while C. do-while

Assignment statement

Which of the following does not require a boolean structure? A. If Then else B while loop C assignemnet D for loop

Inheritance

Which of the following is a means of defining similiar yet different classes in an object oriented program ? A. Inheritance B. Parsing C. Coercion D. Code Optimization

Coercion

Which of the following is a means of nullifying conflicts among data types? A. Inheritance B. Parsing C. Coercion D. Code optimization

Answer B Program

Which of the following is a representation? A. Algorithm B. Program C. Process

Answer: C Process

Which of the following is an activity? A. AlgorithmB. ProgramC. Process

LISP

Which of the following is an example of a language that is based on the functional paradigm? A. LISP B. PROLOG C. C D. C++

comment statements

Which of the following is ignored by a compiler? a control statements b declarations of constants c procedure headers d comment statements

Assignment Statement

Which of the following is not a control statement? A. IF THEN ELSE B While loop C. Assignment statement D. For loop statement

B 5

Which of the following is not a possible value of the expression 4+6/2 -1 ? a 4 b 5 c 6 d 10

Executing the program

Which of the following is not a step in the process of translating a program? A. Executing the program B. Parsing the program C. Lexical Analysis D. Code Generation

Exclamatory Statement

Which of the following is not a type of statement found in a typical high level imperative programming language? A. Imperative statement B. Exclamatory Statement C.Declarative Statement D. Comment statement

Type

Which of the following is not a way of referring to a value in a program? A. VARIABLE B LITERAL C Constant D Type

Resolution

Which of the following is not associated with object oriented programming A. Inheritance B. Resolution C. Encapsulation D. Polymorphism

Operator Precedence

Which of the following is not associated with the concept of data type? A. Coearcion B. Boolean C. Operator Precedence D. Strongly Typed language

Source Code

Which of the following is not constructed by a typical compiler? A. Source Code B. Symbol Table C. Parse Tree D. Object program

B The portion of the program in which the variable can be accessed

Which of the following is the scope of a variable? A. The number of characters B. The portion of the program in which the variable can be accessed C. THE TYPE D. THE STRUCTURE

it fails to reflect the array of distinct programming paradigms

Why does the generation approach to classify programming languages fails the scope of todays language?

VALUE= 3 REFERENCE = 5

X goes to 3; sub(X); print the value of x Procdure sub (y) Y goes to 5 printed by passed by value? printed by passed by reference?

Process

___ is the action of executing a program (or algorithm)

Algorithm

____ is n ordered collection of unambiguous, executable steps that defines a terminating process

the grammar allows more than one parse tree for a single string

to say that grammar is ambiguous means that________

it means that the programs written in the language do not refer to properties of a specific machine. Compatible with any computer

what does it mean to say that a programming language is machine dependent?


Related study sets

Ecology Chapter 3 Review for Test 1

View Set

ap psych chapter 7 amsco, AP Psych Perception and Sensation

View Set

五年级 2021 数学 单元一:整数与运算 (试卷一) (b)

View Set