Skip to main content

Data Structures and Algorithms Exam Questions - 766 Verified Questions

Page 1


Data Structures and Algorithms

Exam Questions

Course Introduction

This course provides a comprehensive introduction to fundamental data structures and algorithms, essential for effective problem solving in computer science. Students will learn to design, analyze, and implement foundational structures such as arrays, linked lists, stacks, queues, trees, and graphs, as well as algorithmic techniques for searching, sorting, and recursion. The course emphasizes computational efficiency and the trade-offs among different approaches, laying the groundwork for advanced study and real-world application development.

Recommended Textbook

Starting out with C++ Early Objects 9th Edition by Tony Gaddis

Available Study Resources on Quizplus

19 Chapters

766 Verified Questions

766 Flashcards

Source URL: https://quizplus.com/study-set/1486

Page 2

Chapter 1: Introduction to Computers and Programming

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Words with a special meaning that may be used only for their intended purpose are known as

A) single purpose words..

B) programmer-defined identifiers.

C) keywords.

D) syntax words.

E) none of the above.

Answer: C

Q2) A variable definition always specifies the name of a variable and tells

A) what type of data it can hold.

B) how many times it will be used in the program.

C) the part of the code where it will be used.

D) what its starting value is.

E) all of the above.

Answer: A

Q3) Most of the lines in a program contain something meaningful; however, some of the lines may contain nothing at all.

A)True

B)False

Answer: True

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

Chapter 2: Introduction to C Plus Plus

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) An operation that copies a value into a variable is called a(n) ________ operation.

A) assignment

B) equals

C) copy

D) declaration

E) cout

Answer: A

Q2) You must have a(n) ________ for every variable you include in a program.

A) purpose

B) definition

C) comment

D) numeric value

E) output statement

Answer: B

Q3) C++ is a case-sensitive language.

A)True

B)False

Answer: True

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

Page 4

Chapter 3: Expressions and Interactivity

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The following pair of C++ statements will cause 3.5 to be output. double number = 7 / 2; cout << number;

A)True

B)False

Answer: False

Q2) Which of the following expressions will evaluate to 2.5?

A) static_cast&lt;double&gt;(5/2)

B) static_cast&lt;double&gt;(5)/2

C) 5/static_cast&lt;double&gt;(2)

D) All three of the above

E) Both B and C, but not A

Answer: E

Q3) Which of the following statements will assign number a value from 90 - 100.

A) number = rand() % 90 + 10;

B) number = rand() % 90 + 11;

C) number = rand() % 10 + 90;

D) number = rand() % 11 + 90;

E) None of the above.

Answer: D

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

Chapter 4: Making Decisions

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) If s1 and s2 are string objects, s1 == s2 is True when

A) s1 = "lion" and s2 = "lioness".

B) s1 = "dog" and s2 = "DOG".

C) s1 = "cat" and s2 = "cat ".

D) None of these because in each case one or more characters in the strings have different ASCII codes.

E) None of these because string objects cannot be compared with relational operators.

Q2) An expression in a C++ if statement that evaluates to 5, -5, or for that matter anything other than 0, is considered True.

A)True

B)False

Q3) Assuming goodData is a Boolean variable, the following two tests are logically equivalent. if (goodData == false) if (!goodData)

A)True

B)False

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

6

Chapter 5: Looping

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) In a for statement, the ________ expression is executed only once.

A) initialization

B) test

C) repeat

D) validate

E) update

Q2) The ++ operator

A) is a unary operator.

B) adds one to the value of its operand.

C) can operate in prefix or postfix mode.

D) All of the above.

E) Both B and C, but not A.

Q3) The ________ statement causes a loop to terminate early.

A) stop

B) break

C) quit

D) terminate

E) continue

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

Chapter 6: Functions

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) In C++ global and local numeric variables are initialized to zero by default.

A)True

B)False

Q2) A function ________ is a statement that causes a function to execute.

A) prototype

B) header

C) definition

D) call

E) parameter list

Q3) Both function headers and function calls must list the data types of all data being passed to the function.

A)True

B)False

Q4) When a function just needs to use a copy of an argument passed to it, the argument should normally be passed by value.

A)True

B)False

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

8

Chapter 7: Introduction to Classes and Objects

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The name of a destructor must begin with

A) the name of the class.

B) a tilde (~).

C) a capital letter.

D) an underscore.

E) none of the above.

Q2) A C++ member function that sets or changes the value stored in a member variable is called

A) an accessor.

B) a mutator.

C) a user.

D) a get function.

E) an updater.

Q3) Public members of a class object can be accessed from outside the class by using the

A) dot operator.

B) get function.

C) extraction operator.

D) member access operator.

E) class name.

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

Chapter 8: Arrays

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) When an array is passed to a function, it is actually ________ the array that is/are passed.

A) a copy of all the values in B) the value stored in the first element of C) the starting memory address of D) the data type and size of E) none of the above

Q2) When you pass an array as an argument to a function, the function can modify the contents of the array.

A)True

B)False

Q3) To step through a one-dimensional array, accessing the elements one by one, it would be most appropriate to use ________ loop.

A) an infinite

B) a sentinel controlled loop

C) a for loop

D) a nested loop

E) no

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

10

Chapter 9: Searching, Sorting, Algorithm Analysis

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The ________ search is adequate for searching through small arrays, but not through large ones.

A) binary

B) linear

C) selection

D) bubble

E) random

Q2) Bubble sort and selection sort can also be used with STL vectors.

A)True

B)False

Q3) To find a value in an ordered array of 50 items, how many values must binary search examine at most.

A) 1

B) 6

C) 10

D) 25

E) 50

Q4) A binary search requires that the elements be in order.

A)True

B)False

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

Chapter 10: Pointers

Available Study Resources on Quizplus for this Chatper

62 Verified Questions

62 Flashcards

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

Sample Questions

Q1) The delete operator should only be used on pointers that A) have not yet been used.

B) have been correctly initialized.

C) point to storage allocated by the new operator.

D) are appropriately dereferenced.

E) None of the above

Q2) It is legal to subtract a pointer variable from another pointer variable.

A)True

B)False

Q3) Memory cannot be allocated after a program is already running.

A)True

B)False

Q4) The ________ and ________ operators can respectively be used to increment and decrement a pointer variable.

A) dereferencing, indirection

B) modulus, division

C) ++, --

D) All of the above

E) None of the above

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

Chapter 11: More About Classes and Object-Oriented Programming

Available Study Resources on Quizplus for this Chatper

70 Verified Questions

70 Flashcards

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

Sample Questions

Q1) Arguments are passed to the base class destructor function by the ________ class ________ function.

A) derived, constructor

B) derived, destructor

C) base, constructor

D) base, destructor

E) None of the above

Q2) A lambda expression is

A) an expression whose value can only be assigned to a local variable.

B) used by the C++ compiler to check the types of other expressions.

C) a class derived from a function object.

D) an object of a class whose only member is the function call operator.

E) None of the above

Q3) When a class declares an entire class as its friend, the friendship status is reciprocal. That is, each class's member functions have free access to the other's private members.

A)True

B)False

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

Page 13

Chapter 12: More on C-Strings and the String Class

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The ________ library function reverses the order of a character array.

A) reverstr

B) strrev

C) reversit

D) backward

E) None of the above

Q2) A good way to convert a string such a "572" to an equivalent integer such as 572

A) is to use the C-library function itoa.

B) is to use an ostringstream object and the insertion operator <<.

C) is to use an istringstream object and the extraction operator >>.

D) is to use an ostringstream object and the extraction operator >>.

E) None of the above

Q3) The string class member function ________ returns the C-string value of the string object.

A) c_string(string s)

B) c_str(string s)

C) c_str()

D) c_string()

E) None of the above

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

Page 14

Chapter 13: Advanced File and Io Operations

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The ________ data type can be used to create files and write information to them.

A) ofstream

B) ifstream

C) istream

D) ostream

E) None of the above

Q2) ofstream, ifstream, and fstream are

A) header files.

B) libraries.

C) data types.

D) string arrays.

E) None of the above

Q3) The ________ data type can be used to connect to files and read information from them into memory.

A) ofstream

B) istream

C) ifstream

D) instream

E) None of the above

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

Page 15

Chapter 14: Recursion

Available Study Resources on Quizplus for this Chatper

20 Verified Questions

20 Flashcards

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

Sample Questions

Q1) When a recursive function directly calls itself, this is known as direct recursion.

A)True

B)False

Q2) The base case of a recursive function

A) is 0.

B) is 1.

C) is depth / 2.

D) is 1 / (depth * 3.1415).

E) depends on the problem being solved.

Q3) Recursive algorithms tend to be less efficient than iterative algorithms.

A)True

B)False

Q4) When a function A calls a function B, which in turn calls A, we have A) direct recursion.

B) indirect recursion.

C) function call cycling.

D) perfect recursion.

E) None of the above

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

Page 16

Chapter 15: Polymorphism and Virtual Functions

Available Study Resources on Quizplus for this Chatper

22 Verified Questions

22 Flashcards

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

Sample Questions

Q1) ________ to a base class may be assigned the address of a derived class object.

A) Access specifiers

B) Static members

C) Private members

D) Pointers

E) None of the above

Q2) Declaring a member function of a class to be a ________ will cause the C++ compiler to use dynamic binding.

A) constructor function

B) destructor function

C) static function

D) virtual function

E) None of the above

Q3) ________ functions are dynamically bound by the compiler.

A) Constructor

B) Destructor

C) Static

D) Virtual

E) None of the above

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

Page 17

Chapter 16: Exceptions, Templates, and the Standard

Template Library Stl

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The beginning of a function template is marked by a A) return type.

B) parameter list.

C) template prefix.

D) semicolon.

E) None of the above

Q2) The Standard Template Library (STL) contains templates for useful algorithms and data structures.

A)True

B)False

Q3) The STL vector and list classes are examples of sequential containers.

A)True

B)False

Q4) Function templates allow you to write a single function definition that works with many different data types.

A)True

B)False

Q5) An exception is a condition that can be caused by a syntax error in the program. A)True

B)False

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

Chapter 17: Linked Lists

Available Study Resources on Quizplus for this Chatper

38 Verified Questions

38 Flashcards

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

Sample Questions

Q1) Deleting an entire linked list requires a call to the delete operator for each node in the list.

A)True

B)False

Q2) Linked lists of items are commonly implemented by

A) using an array to hold list items.

B) using a function to compute the link to the next item.

C) using a class template to represent list items.

D) using a structure containing an item and a pointer to the structure type.

E) None of the above

Q3) Which of the following are linked list operations?

A) adding an item

B) traversing the list

C) removing an item

D) All of the above

E) None of the above

Q4) In a non-empty list, there must be exactly one list item with no successor.

A)True

B)False

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

Chapter 18: Stacks and Queues

Available Study Resources on Quizplus for this Chatper

36 Verified Questions

36 Flashcards

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

Sample Questions

Q1) The queue data structure is commonly applied in connection with A) managing the order of print jobs.

B) communications software.

C) operating systems.

D) All of the above

E) None of the above

Q2) A static queue can be implemented as a A) circular array.

B) stack.

C) dynamic linked list.

D) dynamic vector.

E) None of the above

Q3) Queues that are implemented as arrays are called ________ queues.

A) dynamic

B) stack

C) static

D) deque

E) None of the above

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

38 Verified Questions

38 Flashcards

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

Sample Questions

Q1) A node that has no children is a

A) root node.

B) head node.

C) leaf node.

D) pure binary node.

E) None of the above

Q2) The ________ in a binary tree is analogous to the head pointer in a linked list.

A) root pointer

B) leaf pointer

C) null pointer

D) binary pointer

E) None of the above

Q3) The main difference between a binary tree and a linked list is that

A) a linked list can be empty, but a binary tree cannot.

B) a binary tree can be empty, but a linked list cannot.

C) nodes in a binary tree have two successors instead of one.

D) recursion is useful on binary trees, but not on linked lists.

E) None of the above

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

Turn static files into dynamic content formats.

Create a flipbook