Algorithm Design and Analysis Final Exam - 881 Verified Questions

Page 1


Algorithm Design and Analysis

Final Exam

Course Introduction

Algorithm Design and Analysis explores foundational techniques for designing efficient algorithms and rigorously analyzing their performance in terms of time and space complexity. This course covers classical strategies such as divide and conquer, dynamic programming, greedy algorithms, and graph algorithms, as well as advanced topics like randomized algorithms and NP-completeness. Students will learn to assess the correctness and efficiency of algorithms, apply them to solve complex computational problems, and understand fundamental limitations of algorithmic solutions. The course emphasizes both theoretical understanding and practical implementation through problem sets, case studies, and programming assignments.

Recommended Textbook

C++ Programming Program Design Including Data Structures 8th Edition by D. S. Malik

Available Study Resources on Quizplus

21 Chapters

881 Verified Questions

881 Flashcards

Source URL: https://quizplus.com/study-set/3128 Page 2

Chapter 1: An Overview of Computers and Programming Languages

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/128445

Sample Questions

Q1) Dividing a problem into smaller subproblems is called ____ design.

A) OOD

B) top-down refinement

C) structured

D) analog

Answer: C

Q2) The ____ handles the overall activity of the computer and provides services.

A) central processing unit

B) operating system

C) arithmetic logic unit

D) control unit

Answer: B

Q3) Assembly language uses easy-to-remember instructions called ____________________.

Answer: mnemonics

Q4) In a C++ program, statements that begin with the symbol # are called ____________________ directives.

Answer: preprocessor

Q5) The ASCII data set consists of ____________________ characters. Answer: 128

To view all questions and flashcards with answers, click on the resource link above. Page 3

Chapter 2: Basic Elements of C++

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/61982

Sample Questions

Q1) The expression static_cast<int>(9.9) evaluates to ____.

A) 9

B) 10

C) 9.9

D) 9.0

Answer: A

Q2) The value of the expression 33/10, assuming both values are integral data types, is ____.

A) 0.3

B) 3

C) 3.0

D) 3.3

Answer: B

Q3) If a C++ arithmetic expression has no parentheses, operators are evaluated from left to right.

A)True

B)False

Answer: True

Q4) The maximum number of significant digits is called the ____________________.

Answer: precision

To view all questions and flashcards with answers, click on the resource link above. Page 4

Chapter 3: Inputoutput

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/61983

Sample Questions

Q1) Suppose that ch1 and ch2 are char variables and the input is:WXYZ What is the value of ch2 after the following statements execute? Cin)get(ch1); Cin)putback(ch1); Cin >> ch2;

A) W

B) X

C) Y

D) Z

Answer: A

Q2) C++ has a special name for the data types istream and ostream.They are called ____________________.

Answer: classes

Q3) You can use the function getline to read a string containing blanks.

A)True

B)False

Answer: True

Q4) In C++, the dot is an operator called the ____________________operator. Answer: member access

To view all questions and flashcards with answers, click on the resource link above. Page 5

Chapter 4: Control Structures I Selection

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/61984

Sample Questions

Q1) Which of the following will cause a logical error if you are attempting to compare x to 5?

A) if (x == 5)

B) if (x = 5)

C) if (x <= 5)

D) if (x >= 5)

Q2) In a switch statement, if the value of the expression does not match any of the case values, the statements following the ____________________ label execute.

Q3) In C++, && has a higher precedence than ||.

A)True

B)False

Q4) Assume you have three int variables: x = 2, y = 6, and z.Choose the value of z in the following expression: z = (y / x > 0) ? x : y;.

A) 2

B) 3

C) 4

D) 6

Q5) The ____________________ of relational and logical operators is said to be from left to right.

To view all questions and flashcards with answers, click on the resource link above. Page 6

Chapter 5: Control Structures Ii Repetition

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/128468

Sample Questions

Q1) What is the next Fibonacci number in the following sequence? 1, 1, 2, 3, 5, 8, 13, 21, ...

A) 34

B) 43

C) 56

D) 273

Q2) The ____ statement can be used to eliminate the use of certain (flag) variables.

A) while

B) switch

C) break

D) if

Q3) The number of iterations of a counter-controlled loop is known in advance.

A)True

B)False

Q4) The control variable in a flag-controlled while loop is a bool variable.

A)True

B)False

Q5) In a while and for loop, the loop condition is evaluated before executing the body of the loop.Therefore, while and for loops are called ____________________ loops.

To view all questions and flashcards with answers, click on the resource link above. Page 7

Chapter 6: User-Defined Function

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

Source URL: https://quizplus.com/quiz/61986

Sample Questions

Q1) A function ____________________ is a function that is not fully coded.

Q2) ____________________ parameters are useful in three situations: When the value of the actual parameter needs to be changed When you want to return more than one value from a function When passing the address would save memory space and time relative to copying a large amount of data

Q3) The standard header file for the abs(x)function is ____.

A) &lt;cmath&gt;

B) &lt;ioinput&gt;

C) &lt;cctype&gt; D) &lt;cstdlib&gt;

Q4) To use the predefined function tolower, the program must include the header file

A) &lt;cctype&gt; B) &lt;iostream&gt; C) &lt;cmath&gt; D) &lt;cstdlib&gt;

Q5) When you attach & after the dataType in the formal parameter list of a function, the variable following that dataType becomes a(n) ____________________ parameter.

Page 8

To view all questions and flashcards with answers, click on the resource link above.

Chapter 7: Namespaces, the Class String, and

User-Defined Simple Data Types

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/61987

Sample Questions

Q1) The following is a valid C++ enumeration type:enum places {1ST, 2ND, 3RD, 4TH};.

A)True

B)False

Q2) Which of the following statements declares the studentGrade variable?

A) enum studentGrade {A, B, C, D, F};

B) enum int {A, B, C, D, F} studentGrade;

C) enum studentGrade {A, B, C, D, F} grades;

D) enum grades {A, B, C, D, F} studentGrade;

Q3) An enumeration type can be passed as a parameter to a function only by value.

A)True

B)False

Q4) The string expression strVar.____________________ starts at index pos, replaces the next n characters of strVar with all the characters of str.

Q5) In C++, namespace is a reserved word.

A)True

B)False

Q6) The general syntax for accessing a namespace member is: namespace_name->identifier.

A)True

B)False Page 9

To view all questions and flashcards with answers, click on the resource link above.

Page 10

Chapter 8: Arrays

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/61988

Sample Questions

Q1) Suppose that list is an array of 10 components of type int.Which of the following codes correctly outputs all the elements of list?

A) for (int j = 1; j < 10; j++)

Cout << list[j] << " ";

Cout << endl;

B) for (int j = 0; j <= 9; j++)

Cout << list[j] << " ";

Cout << endl;

C) for (int j = 1; j < 11; j++)

Cout << list[j] << " ";

Cout << endl;

D) for (int j = 1; j <= 10; j++)

Cout << list[j] << " ";

Cout << endl;

Q2) The one place where C++ allows aggregate operations on arrays is the input and output of C-strings.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above.

11

Chapter 9: Records Structs

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/61989

Sample Questions

Q1) Consider the following function prototype:int seqSearch(const listType& list, int searchItem); The actual parameter cannot be modified by ____.

A) seqSearch

B) listType

C) list

D) searchItem

Q2) Arrays are passed by ____________________ only.

Q3) An array name and index are separated using ____.

A) curly brackets

B) square brackets

C) a dot

D) a comma

Q4) Which of the following is an allowable aggregate operation on a struct?

A) Arithmetic

B) Assignment

C) Input/output

D) Comparison

Q5) If a variable is passed by ____________________, then when the formal parameter changes, the actual parameter also changes.

To view all questions and flashcards with answers, click on the resource link above. Page 12

Chapter 10: Classes and Data Abstraction

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

Source URL: https://quizplus.com/quiz/61990

Sample Questions

Q1) What does ADT stand for?

A) abstract definition type

B) asynchronous data transfer

C) abstract data type

D) alternative definition type

Q2) A class and its members can be described graphically using a notation known as the ____ notation.

A) OON

B) OOD

C) UML

D) OOP

Q3) A ____ sign in front of a member name on a UML diagram indicates that this member is a protected member.

A) +

B) -

C) #

D) $

Q4) A program or software that uses and manipulates the objects of a class is called a(n) ____________________ of that class.

To view all questions and flashcards with answers, click on the resource link above. Page 13

Chapter 11: Inheritance and Composition

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

Source URL: https://quizplus.com/quiz/61991

Sample Questions

Q1) ____ is the ability to combine data, and operations on that data, in a single unit.

A) Inheritance

B) Encapsulation

C) Polymorphism

D) Composition

Q2) The new classes that we create from existing classes are called ____ classes.

A) sibling

B) base

C) derived

D) parent

Q3) A derived class can directly access the protected members of the base class.

A)True

B)False

Q4) ____ is a "has-a" relationship.

A) Inheritance

B) Encapsulation

C) Composition

D) Polymorphism

To view all questions and flashcards with answers, click on the resource link above. Page 14

Chapter 12: Pointers, Classes, Virtual Functions, and

Abstract Classes

Available Study Resources on Quizplus for this Chatper

44 Verified Questions

44 Flashcards

Source URL: https://quizplus.com/quiz/61992

Sample Questions

Q1) In ____ binding, the necessary code to call a specific function is generated by the compiler.

A) static

B) dynamic

C) shallow

D) deep

Q2) The dereferencing operator is also known as the indirection operator and refers to the object to which its operand points.

A)True

B)False

Q3) The ____ constructor is executed when an object is declared and initialized by using the value of another object.

A) default

B) copy

C) struct

D) class

Q4) The statement that declares board to be an array of six pointers wherein each pointer is of type int is: int ____________________;

To view all questions and flashcards with answers, click on the resource link above. Page 15

Q5) A(n) ____________________ is a collection of distinct elements of the same type.

Chapter 13: Operator Overloading and Templates

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

Source URL: https://quizplus.com/quiz/61993

Sample Questions

Q1) Suppose cType is a class template, which can take int as a parameter.The statement: ____ declares x to be an object of type cType, and the type passed to the class cType is int.

A) cType&lt;int&gt; x;

B) cType int x;

C) cType int = x;

D) cType int :: x;

Q2) Which of the following is the general syntax of the function prototype to overload the pre-increment operator as a nonmember function?

A) className operator++();

B) friend className operator++();

C) className operator++(int);

D) friend className operator++(className&);

Q3) When writing the definition of a friend function, the name of the class and the scope resolution operator precede the name of the friend function in the function heading.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above.

16

Chapter 14: Exception Handling

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

Source URL: https://quizplus.com/quiz/61994

Sample Questions

Q1) The statements that may generate an exception are placed in a ____ block.

A) throw

B) finally

C) try

D) catch

Q2) The order of the catch blocks does not affect the program.

A)True

B)False

Q3) A(n) ____________________ block specifies the type of exception it can catch and contains an exception handler.

Q4) One of the typical ways of dealing with exceptions is to use an if statement.

A)True

B)False

Q5) Which of the following is a valid C++ statement?

A) assert(0 = divisor);

B) assert(divisor != 0);

C) assert(divisor 0);

D) assert(divisor is 0);

Q6) The class ____________________ deals with the string subscript out of range error.

Page 17

To view all questions and flashcards with answers, click on the resource link above.

Chapter 15: Recursion

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

Source URL: https://quizplus.com/quiz/128470

Sample Questions

Q1) Infinite recursions execute forever on a computer.

A)True

B)False

Q2) Which of the following function headings can be used for a recursive definition of a function to calculate the nth Fibonacci number?

A) void rFibNum(int a, int b)

B) bool rFibNum(int a, int b)

C) bool rFibNum(int a, int b, int n)

D) int rFibNum(int a, int b, int n)

Q3) Consider the accompanying definition of a recursive function.Which of the statements represent the general case?

A) Statements in Lines 3-11

B) Statements in Lines 5-6

C) Statements in Lines 5-11

D) Statements in Lines 7-11

Q4) You can use a recursive algorithm to find the largest element in an array.

A)True

B)False

Q5) Recursive algorithms are implemented using ____________________ functions.

18

To view all questions and flashcards with answers, click on the resource link above.

Chapter 16: Linked Lists

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/61996

Sample Questions

Q1) Consider the accompanying code.What is the effect of the following statement? newNode->info = 50;

A) Stores 50 in the info field of the newNode

B) Creates a new node

C) Places the node at location 50

D) Cannot be determined from this code

Q2) Which of the following statements appears in the insert function of a doubly linked list?

A) current++;

B) trailCurrent++;

C) newNode++;

D) count++;

Q3) In a linked list, the link component of each node is a(n)

Q4) For classes that include pointer data members, the assignment operator must be explicitly ____________________.

Q5) A doubly linked list can be traversed in either direction. A)True B)False

Q6) The ____________________ operator advances the iterator to the next node in the linked list.

To view all questions and flashcards with answers, click on the resource link above. Page 19

Chapter 17: Stacks and Queue

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

Source URL: https://quizplus.com/quiz/61997

Sample Questions

Q1) If you try to add a new item to a full stack, the resulting condition is called an outflow.

A)True

B)False

Q2) If you try to add a new item to a full stack, the resulting condition is called a(n)

A) override

B) overflow

C) overload

D) underflow

Q3) The bottom element of the stack is the last element added to the stack.

A)True

B)False

Q4) The expression a + b is the same in both infix notation and postfix notation. A)True

B)False

Q5) A queue is a First In First Out data structure.

A)True B)False

Q6) In ____________________ notation, operators are written after the operands.

Page 20

To view all questions and flashcards with answers, click on the resource link above.

Chapter 18: Searching and Sorting Algorithms

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/61998

Sample Questions

Q1) The formula to find the index of the middle element of a list is ____.

A) (mid + last)/2

B) (first + last) - 2

C) (first + last) / 2

D) (first + mid ) * 2

Q2) In a bubble sort for list of length n, the first step is to compare elements ____.

A) list[0] and list[n]

B) list[0] and list[n-1]

C) list[0] and list[1]

D) list[n-1] and list[n+1]

Q3) In a quick sort, all of the sorting work is done by the function

Q4) The selection sort algorithm finds the location of the smallest element in the unsorted portion of the list.

A)True

B)False

Q5) For a list of length n, the bubble sort makes exactly ____________________ key comparisons.

Q6) The top node of a comparison tree is call the ____________________ node.

Page 21

To view all questions and flashcards with answers, click on the resource link above.

Chapter 19: Binary Trees

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

Source URL: https://quizplus.com/quiz/61999

Sample Questions

Q1) The level of the root node of a binary tree is 1.

A)True

B)False

Q2) The key of the right child below the root node of a search binary tree is 40.The value in the root node could be ____.

A) 30

B) 40

C) 50

D) 60

Q3) In the diagram of a binary tree, an arrow is called a(n) ____.

A) relation

B) path

C) directed line

D) directed branch

Q4) In addition to the inorder, preorder, and postorder traversals, a binary tree can also be traversed level-by-level, which is also known as ____________________ traversal.

Q5) Let T be a binary search tree with n nodes, in which n > 0.When T is linear, the search algorithm makes ____________________ key comparisons, in the unsuccessful case.

22

To view all questions and flashcards with answers, click on the resource link above.

Chapter 20: Graph Algorithms

Available Study Resources on Quizplus for this Chatper

48 Verified Questions

48 Flashcards

Source URL: https://quizplus.com/quiz/62000

Sample Questions

Q1) The edges connecting two vertices can be assigned a non-negative real number, called the ____ of the edge.

A) key

B) weight

C) width

D) height

Q2) Let e (u, v) be an edge in an undirected graph G.The edge e is said to be ____________________ on the vertices u and v.

Q3) If two edges, e<sub>1</sub> and e<sub>2</sub>, are associated with the same pair of vertices {u, v}, then e<sub>1</sub> and e<sub>2</sub> are called ____ edges.

A) parallel

B) adjacent

C) connected

D) incident

Q4) A minimal spanning tree of G is a spanning tree with the minimum ____.

A) path

B) cycle

C) weight

D) height

To view all questions and flashcards with answers, click on the resource link above. Page 23

Chapter 21: Standard Template Library

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

Source URL: https://quizplus.com/quiz/62001

Sample Questions

Q1) Every container contains the typedef ____________________.An iterator of this type is used to iterate through the elements of a container in reverse.

Q2) ____________________ predicates check a specific property for a single argument.

Q3) In the ____ sort algorithm, the array containing the data is viewed as a binary tree. A) modifying B) heap

C) nonmodifying

D) numeric

Q4) A function object contains a function that can be treated as a function using the ____ operator.

A) *

B) :: C) ()

D) .

Q5) The name of the class that implements the vector container is container.

A)True B)False

Q6) List containers are implemented as doubly ____________________.

To view all questions and flashcards with answers, click on the resource link above. Page 24

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
Algorithm Design and Analysis Final Exam - 881 Verified Questions by Quizplus - Issuu