Algorithm Design and Analysis Practice Questions
Algorithm Design and Analysis Practice Questions
Practice Questions
https://quizplus.com/study-set/319
21 Chapters
1050 Verified Questions
Algorithm Design and Analysis
Practice Questions
Course Introduction
Algorithm Design and Analysis is a foundational course that explores the principles and
techniques used to create efficient and effective algorithms for solving computational
problems. Students will learn about classic design paradigms such as divide and
conquer, greedy algorithms, dynamic programming, and backtracking. The course also
covers methods for analyzing algorithm performance in terms of time and space
gain the skills necessary to design, analyze, and implement robust algorithms across a
variety of applications.
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) A program called a(n)____________________ translates the assembly
language instructions into machine language.
Answer: assembler
Q2) The programming language C++ was designed by Bjarne Stroustrup at Bell
Laboratories in the early ____.
A) 1960s
B) 1970s
C) 1980s
D) 1990s
Answer: C
Q3) The ____ is the brain of the computer and the single most expensive piece of
hardware in your personal computer.
A) MM
B) ROM
C) RAM
D) CPU
Answer: D
To view all questions and flashcards with answers, click on the resource link above.
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) A mixed arithmetic expression contains all operands of the same type.
A)True
B)False
Answer: False
To view all questions and flashcards with answers, click on the resource link above.
Page 4
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) In the C++ statement,
cin.get(u);
u must be a variable of type ____________________.
Answer: char
Q2) C++ provides a header file called ____________________,which is used for file
I/O.
Answer: fstream
Q3) 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
Q4) C++ has a special name for the data types istream and ostream.They are called
____________________.
Answer: classes
Page 5
To view all questions and flashcards with answers, click on the resource link above.
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) For a program to use the assert function,it must include which of the following?
A) #include <assert>
B) #include <cassert>
C) #include <assertc>
D) #include NDEBUG
Q2) Suppose that x is an int variable.Which of the following expressions always evaluates
to true?
A) (x > 0) || ( x <= 0)
B) (x >= 0) || (x == 0)
C) (x > 0) && ( x <= 0)
D) (x > 0) && (x == 0)
Q3) Which of the following expressions correctly determines that x is greater than 10 and
less than 20?
A) 10 < x < 20
B) (10 < x < 20)
C) 10 < x && x < 20
D) 10 < x || x < 20
Sample Questions
Q1) ____ loops are called posttest loops.
A) break
B) for
C) while
D) do...while
Q3) The ____________________ loop has an exit condition but no entry condition.
Q6) In the case of the sentinel-controlled while loop,the first item is read before the while
loop is entered.
A)True
B)False Page 7
To view all questions and flashcards with answers, click on the resource link above.
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) Which of the following function prototypes is valid?
A) int funcTest(int x, int y, float z){}
B) funcTest(int x, int y, float){};
C) int funcTest(int, int y, float z)
D) int funcTest(int, int, float);
Sample Questions
Q1) 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;
Q2) The ____ function is used to interchange the contents of two string variables.
A) iterator
B) traverse
C) swap
D) change
Q3) Which of the following statements is used to simplify the accessing of all globalType
namespace members?
A) using globalType;
B) using namespace globalType:all;
C) using namespace globalType::all;
D) using namespace globalType;
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 following statements store the value ____________________ into len.
int len;
len = strlen("Sunny California");
Q3) Consider the following declaration: int alpha[5] = {3,5,7,9,11};.Which of the following is
equivalent to this statement?
A) int alpha[ ] = {3, 5, 7, 9, 11};
B) int alpha[ ] = {3 5 7 9 11};
C) int alpha[5] = [3, 5, 7, 9, 11];
D) int alpha[ ] = (3, 5, 7, 9, 11);
Q5) Consider the statement int list[10][8];.Which of the following about list is true?
A) list has 10 rows and 8 columns.
B) list has 8 rows and 10 columns.
C) list has a total of 18 components.
D) list has a total of 108 components.
To view all questions and flashcards with answers, click on the resource link above.
Page 10
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) A(n)____________________ is a set of elements of the same type.
To view all questions and flashcards with answers, click on the resource link above.
Page 11
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) Consider the accompanying class and member functions definitions in Figure 3.How
many constructors are present in the class definition above?
A) none
B) one
C) two
D) three
Q4) The public members of a class must be declared before the private members.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above.
Page 12
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) Suppose that bClass is a class.Which of the following statements correctly derives
the class dClass from bClass?
A) class dClass:: public bClass
{
//classMembersList
};
B) class dClass: private bClass
{
//classMembersList
};
C) class dClass:: protected bClass
{
//classMembersList
};
D) class bClass: public dClass
{
//classMembersList
};
To view all questions and flashcards with answers, click on the resource link above.
Page 13
Chapter 12: Pointers, Classes, Virtual Functions, Abstract
Sample Questions
Q1) Given the declaration int *a;,the statement a = new int[50]; dynamically allocates an
array of 50 components of the type ____.
A) int
B) int*
C) pointer
D) address
Q2) In C++,the dot operator has a lower precedence than the dereferencing operator.
A)True
B)False
Q4) The statement int *p; is equivalent to int * p;,which is also equivalent to the
statement ____________________.
Q5) The statement that declares board to be a pointer to a pointer is: int
____________________;
Page 14
To view all questions and flashcards with answers, click on the resource link above.
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
pre-increment operator ++ as a member function?
A) className operator++();
B) className operator++(int);
C) friend className operator++();
D) friend className operator++(int);
Q2) The declaration of a friend function cannot be placed within the private part of the
class.
A)True
B)False
Q5) Operators can be overloaded either for objects of the user-defined types,or for a
combination of objects of the user-defined type and objects of the built-in type.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above.
Page 15
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) The general syntax to rethrow an exception caught by a catch block is: ____ (in this
case,the same exception is rethrown).
A) rethrow;
B) throw;
C) rethrow exception;
D) throw exception;
Q4) If a length greater than the maximum allowed for a string object is used,the class
____________________ deals with the error that occurs.
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
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5318
Sample Questions
Q1) Consider the accompanying definition of a recursive function.Which of the
statements represent the general case?
A) Statements in Lines 1-6
B) Statements in Lines 3 and 4
C) Statements in Lines 4, 5, and 6
D) Statements in Lines 5 and 6
Q4) The recursive algorithm must have one or more base cases,and the general solution
must eventually be reduced to a(n)____________________.
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) Which of the following correctly initializes a doubly linked list in the default
constructor?
A) head = NULL;
Back = NULL;
B) head = 0;
Back = 0;
Count = 0;
C) first = 0;
Last = 0;
D) first = NULL;
Last = NULL;
Count = 0;
To view all questions and flashcards with answers, click on the resource link above.
Page 18
Chapter 17: Stacks and Queues
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5320
Sample Questions
Q1) The addition and deletion of elements of the stack occurs only at the ____ of the
stack.
A) head
B) bottom
C) top
D) middle
Q3) The expression a + b is the same in both infix notation and postfix notation.
A)True
B)False
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) After the second iteration of bubble sort for a list of length n,the last ____ elements
are sorted.
A) two
B) three
C) n-2
D) n
Q2) Let f be a function of n.By the term ____________________,we mean the study
of the function f as n becomes larger and larger without bound.
Q4) Assume that list consists of the following elements.What is the result after bubble
sort completes? int list[] = {2,56,34,25,73,46,89,10,5,16};
A) 89 73 56 46 34 25 16 10 5 2
B) 2 56 34 25 5 16 89 46 73
C) 2 5 10 16 25 34 46 56 73 89
D) 2 10 16 25 34 46 56 73 89
Q5) To construct a search algorithm of the order less than log<sub>2</sub>n,it cannot
be ____________________ based.
To view all questions and flashcards with answers, click on the resource link above.
Page 20
Chapter 19: Binary Trees
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5322
Sample Questions
Q1) The listing of the nodes produced by the postorder traversal of a binary tree is called
the ____.
A) postsequence
B) postorder sequence
C) postorder table
D) post-script
Q2) In copying a binary tree,if you use just the value of the pointer of the root node,you
get a ____ copy of the data.
A) static
B) shallow
C) deep
D) local
Q3) A node in a binary tree is called a(n)____ if it has no left and right children.
A) edge
B) branch
C) leaf
D) path
Q4) 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 21
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) In a(n)____ graph,the edges are drawn using arrows.
A) pointed
B) vector
C) directed
D) undirected
Q2) In a graph directed G,for each vertex,v,the vertices adjacent to v are called ____
successors.
A) immediate
B) adjacent
C) path
D) parallel
Pageif 22
Q6) A graph is ____________________ the number of vertices is zero.
To view all questions and flashcards with answers, click on the resource link above.
Chapter 21: Standard Template Library (STL)
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5324
Sample Questions
Q1) The deq.front()operation on a deque object checks whether the container is empty.
A)True
B)False
Q3) The ____ operation on a vector container deletes the last element.
A) vecList.pop_back()
B) vecList.pop()
C) vecList.push_back()
D) vecList.back()
Q4) The ____________________ iterator is used to input data into a program from
an input stream.
To view all questions and flashcards with answers, click on the resource link above.