Algorithm Analysis MCQ PDF
Algorithm Analysis MCQ PDF
https://quizplus.com/study-set/319
21 Chapters
1050 Verified Questions
Algorithm Analysis
MCQ PDF
Cou
Algorithm Analysis delves into the systematic evaluation of algorithms to determine their
efficiency and effectiveness in solving computational problems. The course explores key
concepts such as time and space complexity, with an emphasis on Big O, Big Theta, and
Big Omega notations. Students will examine various algorithmic paradigms, including
divide and conquer, dynamic programming, and greedy algorithms, while analyzing the
trade-offs involved in their use. Through theoretical study and practical exercises, the
Recommended Textbook
C++ Programming Program Design Including Data Structures 6th Edition by D.S. Malik
Page 2
Chapter 1: An Overview of Computers and Programming
Languages
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/128444
Sample Questions
Q1) Main memory is called ____.
A) read only memory
B) random access memory
C) read and write memory
D) random read only memory
Answer: B
Page 4
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/5305
Sample Questions
Q1) The ____________________ type is C++ 's method for allowing programmers to
create their own simple data types.
Answer: enumeration
Q4) The escape sequence \r moves the insertion point to the beginning of the next line.
A)True
B)False
Answer: False
Q6) A mixed arithmetic expression contains all operands of the same type.
A)True
B)False
Answer: False
Page 5
To view all questions and flashcards with answers, click on the resource link above.
Chapter 3: Input/Output
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5306
Sample Questions
Q1) Suppose that x = 55.68,y = 476.859,and z = 23.8216.What is the output of the following
statements?
cout << fixed << showpoint;
Cout << setprecision(3);
Cout << x << ' ' << y << ' ' << setprecision(2)<< z << endl;
A) 55.680 476.859 23.82
B) 55.690 476.860 23.82
C) 55.680 476.860 23.82
D) 55.680 476.859 23.821
Answer: A
Q2) You can use the function getline to read a string containing blanks.
A)True
B)False
Answer: True
To view all questions and flashcards with answers, click on the resource link above.
Page 6
Chapter 4: Control Structures I (Selection)
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5307
Sample Questions
Q1) What does <= mean?
A) less than
B) greater than
C) less than or equal to
D) greater than or equal to
Q2) Suppose found = true and num = 6.The value of the expression (!found)|| (num > 6)is
____________________.
A)True
B)False
Sample Questions
Q1) ____ loops are called posttest loops.
A) break
B) for
C) while
D) do...while
Q3) Assume that all variables are properly declared.The following for loop executes 20
times.
for (i = 0; i <= 20; i++)
\(\quad\)cout << i;
A)True
B)False
Q4) What is the output of the following C++ code? num = 100;
while (num <= 150)
\(\quad\)num = num + 5;
cout << num << endl;
A) 150
B) 155
C) 160
D) 165
To view all questions and flashcards with Page 8 click on the resource link above.
answers,
Chapter 6: User-Defined Functions
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5309
Sample Questions
Q1) Given the following function:
int strange(int x,int y)
{
\(\quad\)if (x > y)
\(\quad\)\(\quad\)Return x + y;
else
\(\quad\)Return x - y;
}
What is the output of the following statement?
Cout << strange(4,5)<< endl;
A) -1
B) 1
C) 9
D) 20
To view all questions and flashcards with answers, click on the resource link above.
Page 9
Chapter 7: User-Defined Simple Data Types, Namespaces,
Sample Questions
Q1) Consider the declaration: enum sports
{BASKETBALL,FOOTBALL,HOCKEY,BASEBALL,SOCCER};
Which of the following statements is true?
A) SOCCER-- = BASEBALL
B) BASEBALL++ = SOCCER
C) HOCKEY + FOOTBALL < SOCCER
D) FOOTBALL <= SOCCER
Q3) Consider the following statements: string str1 = "Gone with the wind";
String str2;
After the statement str2 = str1.substr(5,4); executes,the value of str2 is "____".
A) Gone
B) with
C) the
D) wind
Page 10
To view all questions and flashcards with answers, click on the resource link above.
Chapter 8: Arrays and Strings
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5311
Sample Questions
Q1) The statement strlen("Marylin Stewart"); returns ____________________.
Q2) Given the declaration int list[20]; the statement list[12] = list[5] + list[7]; updates the
content of the twelfth component of the array list.
A)True
B)False
Q3) 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++)
\(\quad\)\(\quad\)cout << list[j] << " ";
\(\quad\)cout << endl;
B) for (int j = 0; j <= 9; j++)
\(\quad\)\(\quad\)Cout << list[j] << " ";
\(\quad\)cout << endl;
C) for (int j = 1; j < 11; j++)
\(\quad\)\(\quad\)cout << list[j] << " ";
\(\quad\)cout << endl;
D) for (int j = 1; j <= 10; j++)
\(\quad\)\(\quad\)cout << list[j] << " ";
\(\quad\)cout << endl;
To view all questions and flashcards with answers, click on the resource link above.
Page 11
Chapter 9: Records (structs)
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5312
Sample Questions
Q1) If a variable is passed by ____________________,then when the formal
parameter changes,the actual parameter also changes.
Q2) Consider the accompanying struct definition.The statement that assigns the
average of testScore and programmingScore to score is ____________________.
Q3) You can declare struct variables when you define a struct.
A)True
B)False
Q4) Consider the accompanying struct definition in Figure 1.The statement that initializes
the member firstName to Melissa is ____________________.
Q7) Consider the accompanying struct definition in Figure 1.The statement that initializes
the member testScore to 95 is ____________________.
To view all questions and flashcards with answers, click on the resource link above.
Chapter 10: Classes and Data Abstraction
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/128469
Sample Questions
Q1) How many destructors can a class have?
A) no explicit destructors
B) one
C) two
D) any number
Q2) To guarantee that the member variables of a class are initialized,you use ____.
A) accessors
B) mutators
C) constructors
D) destructor
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) $
To view all questions and flashcards with answers, click on the resource link above.
Chapter 11: Inheritance and Composition
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5314
Sample Questions
Q1) Which of the following statements about inheritance is true if
memberAccessSpecifier is protected?
A) The private members of the base class become protected members of the derived
class.
B) The derived class can directly access any member of the base class.
C) The public members of the base class become protected members of the derived
class.
D) The protected members of the base class become private members of the derived
class.
Q4) Existing classes,from which you create new classes,are called ____ classes.
A) child
B) base
C) sibling
D) derived
To view all questions and flashcards withPage 14 click on the resource link above.
answers,
Chapter 12: Pointers, Classes, Virtual Functions, Abstract
Sample Questions
Q1) Which of the following would be appropriate syntax for the heading of a copy
constructor for a class called rulerType?
A) rulerType(int inches, int centimeters)
B) rulerType()
C) rulerType(const rulerType& myRuler)
D) copy rulerType(int inches, int centimeters)
Q4) The statement that declares board to be a pointer to a pointer is: int
____________________;
Page 16
Chapter 13: Overloading and Templates
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5316
Sample Questions
Q1) Which of the following is the general syntax of the function prototype to overload the
post-increment operator as a member function?
A) className operator++();
B) friend className operator++();
C) className operator++(int);
D) friend className operator++(int);
Q3) To overload the pre-increment (++)operator for a class,if the operator function is a
member of that class,it must have ____ parameter(s).
A) no
B) one
C) two
D) three
Q4) Both parameters of the function to overload the operator << are reference
parameters.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above.
Page 17
Chapter 14: Exception Handling
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5317
Sample Questions
Q1) The function ____ can check whether an expression meets the required conditions;
if the conditions are not met,it terminates the program.
A) check
B) look
C) assert
D) what
Q2) In a sequence of try/catch blocks,the last catch block of that sequence should be
____.
A) catch(...){ }
B) catch(int x){ }
C) catch(str){ }
D) catch(exception){}
Q3) When an exception is thrown,if the program does not handle the exception,then the
function ____ is called to terminate the program.
A) log
B) what
C) terminate
D) close
To view all questions and flashcards with answers, click on the resource link above.
Page 18
Chapter 15: Recursion
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5318
Sample Questions
Q1) ____ control structures use a looping structure,such as while,for,or do...while,to
repeat a set of statements.
A) Iterative
B) Recursive
C) Procedural
D) Object
Q2) Which of the following solution methods would be the best choice for a mission
control system?
A) Iterative
B) Direct recursive
C) Indirect recursive
D) Infinite recursive
Q3) In the Tower of Hanoi recursive program,if needle 1 contains three disks,then the
number of moves required to move all three disks from needle 1 to needle 3 is 8.
A)True
B)False
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
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5319
Sample Questions
Q1) When you build a linked list in the backward manner,a new node is always inserted
at the end of the linked list.
A)True
B)False
Q2) How many pointers are needed to build a linked list in a backward manner?
A) One
B) Two
C) Three
D) Four
Q3) The deleteNode operation (if the item to be deleted is in a doubly linked list)requires
the adjustment of ____ pointer(s)in certain nodes.
A) one
B) two
C) three
D) four
Q4) For classes that include pointer data members,the assignment operator must be
explicitly ____________________.
Q5) A linked list in which the last node points to the first node is called
a(n)____________________ linked list.
Sample Questions
Q1) The postfix expression 5 6 + 4 * 10 5 / - = evaluates to ____.
A) 10
B) 30
C) 42
D) 44
Q3) The elements at the ____________________ of a stack have been in the stack
the longest.
Q6) The expression a + b is the same in both infix notation and postfix notation.
A)True
B)False
Q7) The expression (a - b)* (c + d)is equivalent to which of the following postfix
expressions?
A) a b c d - + *
B) a b - c d + *
C) a b - + c d *
Page 21
D) - + * a b c d
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
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5321
Sample Questions
Q1) In the average case,sequential search typically searches ____.
A) one quarter of the list
B) one third of the list
C) one half of the list
D) the entire list
Q2) A sequential search of an n-element list takes ____ key comparisons if the item is
not in the list.
A) 0
B) n/2
C) n
D) n<sup>2</sup>
Q3) 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
Q5) In the case of an unsuccessful search,it can be shown that for a list of length n,a
binary search makes approximately ____________________ key comparisons.
Sample Questions
Q1) Let T be a binary search tree with n nodes,in which n > 0.The number of key
comparisons is approximately O(____________________).
Q4) The three traversal algorithms discussed for binary trees are ____,____,and ____.
A) order, preorder, postorder
B) in, preorder, order
C) order, preorder, post
D) inorder, preorder, postorder
Q5) After inserting an item in a binary search tree,the resulting binary tree must be
a(n)____________________.
To view all questions and flashcards with answers, click on the resource link above.
Page 23
Chapter 20: Graphs
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5323
Sample Questions
Q1) The two most common graph traversal algorithms are depth first traversal and
breadth first traversal.
A)True
B)False
Q2) A graph G is a pair,G = (V,E),where V is a finite nonempty set called the set of ____
of G,and the elements of E are the pairs of elements of V.
A) nodes
B) branches
C) vertices
D) edges
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.
Q4) The vector container stores and manages its objects in a dynamic array.
A)True
B)False
Q5) ____________________ iterators are forward iterators that can also iterate
backward over the elements.
Page 25
Q7) List containers are implemented as doubly ____________________.
To view all questions and flashcards with answers, click on the resource link above.