0% found this document useful (0 votes)
9 views23 pages

Algorithm Design and Analysis Practice Questions

Algorithm Design and Analysis Practice Questions available on Quizplus.com. The resource URL is https://quizplus.com/study-set/319-c-programming-program-design-including-data-structures

Uploaded by

27ftj86zyf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views23 pages

Algorithm Design and Analysis Practice Questions

Algorithm Design and Analysis Practice Questions available on Quizplus.com. The resource URL is https://quizplus.com/study-set/319-c-programming-program-design-including-data-structures

Uploaded by

27ftj86zyf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Algorithm Design and Analysis

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

complexity, and introduces the concept of computational intractability and

NP-completeness. Through theoretical insights and practical problem-solving, students

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

Available Study Resources on Quizplus


21 Chapters
1050 Verified Questions
1050 Flashcards
Source URL: https://quizplus.com/study-set/319

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

Q4) The ASCII data set consists of ____________________ characters.


Answer: 128 Page 3

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

Q2) ____________________ is the process of planning and creating a program.


Answer: Programming
programming

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


A) 9
B) 10
C) 9.9
D) 9.0
Answer: A

Q4) Which of the following is a reserved word in C++?


A) char
B) Char
C) CHAR
D) character
Answer: A

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 &lt;assert>
B) #include &lt;cassert>
C) #include &lt;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

Q4) The symbol > is a(n)____________________ operator.

Q5) A ____________________ operator allows you to make comparisions in a


program.
Page 6
To view all questions and flashcards with answers, click on the resource link above.
Chapter 5: Control Structures II (Repetition)
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/128467

Sample Questions
Q1) ____ loops are called posttest loops.
A) break
B) for
C) while
D) do...while

Q2) The ____________________ statement is typically used for two purposes:


• To exit early from a loop.
• To skip the remainder of a switch structure.

Q3) The ____________________ loop has an exit condition but no entry condition.

Q4) When a continue statement is executed in a ____,the update statement always


executes.
A) while loop
B) for loop
C) switch structure
D) do...while loop

Q5) A for loop is typically called a counted or ____________________ for loop.

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);

Q2) The execution of a return statement in a user-defined function terminates the


program.
A)True
B)False

Q3) The statement: return 2 * 3 + 1,1 + 5; returns the value ____.


A) 2
B) 3
C) 6
D) 7

Q4) The following function heading in a C++ program is valid:


int funcExp(int u,char v,float g)
A)True
B)False

Q5) ____________________ identifiers are not accessible outside of the function


(block).
Page 8
To view all questions and flashcards with answers, click on the resource link above.
Chapter 7: User-Defined Simple Data Types, Namespaces,

and the string Type


Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5310

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;

Q4) A function cannot return the value of an enumeration type.


A)True
B)False Page 9

Q5) The length of the string "Hello There." is ____________________.

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");

Q2) All components of an array are of the same data type.


A)True
B)False

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);

Q4) The statement strlen("Marylin Stewart"); returns ____________________.

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.

Q2) Consider the following statements: struct rectangleData


{
\(\quad\)double length;
\(\quad\)double width;
\(\quad\)double area;
\(\quad\)double perimeter;
};
rectangleData bigRect;
Which of the following statements correctly initializes the component length of bigRect?
A) bigRect = {10};
B) bigRect.length = 10;
C) length[0]= 10;
D) bigRect[0]= 10

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


A) Arithmetic
B) Assignment
C) Input/output
D) Comparison

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

Q2) A(n)____________________ is a statement specifying the condition(s)that


must be true before the function is called.

Q3) Which of the following is true about classes and structs?


A) By default, all members of a struct are public and all members of a class are private.
B) A struct variable is passed by value only, and a class variable is passed by reference
only.
C) An assignment operator is allowed on class variables, but not on struct variables.
D) You cannot use the member access specifier private in a struct.

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
};

Q2) The constructor of a derived class cannot directly access the


____________________ member variables of the base class.

To view all questions and flashcards with answers, click on the resource link above.
Page 13
Chapter 12: Pointers, Classes, Virtual Functions, Abstract

Classes, and Lists


Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/5315

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

Q3) The C++ operator ____ is used to create dynamic variables.


A) dynamic
B) new
C) virtual
D) dereferencing

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

Q6) The ____________________ of a list is the number of elements in the list.

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

Q3) The ____________________ operator causes a member-wise copy of the


member variables of the class.

Q4) The ____________________ operator function as a member of a class has only


one parameter; as a nonmember of a class,it has two parameters.

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;

Q3) Throwing an exception is typically done using the ____________________


statement.

Q4) If a length greater than the maximum allowed for a string object is used,the class
____________________ deals with the error that occurs.

Q5) In C++,throw is a(n)____________________ word.

Q6) The class ____________________ contains the function what.

Q7) The string concatenation operator is Page


____________________.
16

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

Q2) The collating sequence of A in the ASCII character set is


____________________.

Q3) If you execute a(n)____________________ recursive function on a


computer,the function executes until the system runs out of memory.

Q4) The recursive algorithm must have one or more base cases,and the general solution
must eventually be reduced to a(n)____________________.

Q5) Consider the accompanying definition of a recursive function.Which of the


statements represent the base case?
A) Statements in Lines 3 and 4
B) Statements in Lines 5 and 6
C) Statements in Lines 3-6
D) Statements in Lines 5-10

Q6) Recursive algorithms are implemented using ____________________


functions. Page 17

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;

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

Q4) The ____________________ constructor executes when an object is declared


and initialized using another object.

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

Q2) In a queuing system,we use a(n)____________________ variable to set the


status of the server.

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

Q4) A stack is a(n)____ data structure.


A) FIFO
B) FILO
C) LIFO
D) LILO

Q5) In a(n)____________________ simulation,the clock is implemented as a


counter,and the passage of,say,one minute can be implemented by incrementing the
counter by one.

Page 19 access data structure.


Q6) An array is a(n)____________________

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.

Q3) The ____________________ search algorithm is the optimal worst-case


algorithm for solving search problems by using the comparison method.

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

Q3) Linked lists cannot be used to implement an adjacency list.


A)True
B)False

Q4) We can always traverse an entire graph from a single vertex.


A)True
B)False

Q5) A set Y is called a(n)____________________ of X if every element of Y is also an


element of X.

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

Q2) The first element in a vector container is at location 1.


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.

Q5) The operator ____________________,supported by the stack container


class,inserts a copy of item onto the stack.

Q6) The term ____________________ stands for double-ended queue.

Q7) List containers are implemented as doubly ____________________.

Q8) The operator ____________________,supported by the queue container


Page 23
class,removes the next element in the queue.

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

You might also like