Skip to main content

Introduction to Algorithms and Programming Mock Exam - 891 Verified Questions

Page 1


Introduction to Algorithms and Programming

Mock Exam

Course Introduction

Introduction to Algorithms and Programming provides students with the foundational concepts essential for problem-solving in computer science. The course covers the basics of algorithm design, flowcharting, and computational thinking while introducing structured programming using a high-level language such as Python or C++. Students learn about variables, data types, control structures, functions, arrays, and debugging techniques. Through a blend of theoretical instruction and practical coding exercises, the course emphasizes the development of logical reasoning and the ability to translate real-world problems into efficient algorithmic solutions. No prior programming experience is required, making it suitable for beginners interested in software development or computational analysis.

Recommended Textbook

Starting Out with C++ from Control Structures to Objects 8th Edition by Tony Gaddis

Available Study Resources on Quizplus

20 Chapters

891 Verified Questions

891 Flashcards

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

Chapter 1: Introduction to Computers and Programming

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Programs are commonly referred to as hardware.

A)True

B)False Answer: False

Q2) A(n)________ is a diagram that shows the logical flow of a program.

A)UML diagram

B)flowchart

C)hierarchy chart

D)program schematic

E)None of these Answer: B

Q3) Words that have a special meaning and may be used only for their intended purpose are known as:

A)Operators

B)Programmer Defined Words

C)Key Words

D)Syntax

E)None of the above

Answer: C

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

60 Verified Questions

60 Flashcards

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

Sample Questions

Q1) A variable whose value can be either true or false is of this data type.

A)binary

B)bool

C)T/F

D)float

E)None of the above

Answer: B

Q2) In memory, C++ automatically places a ________ at the end of string literals.

A)Semicolon

B)Quotation marks

C)Null terminator

D)Newline escape sequence

E)None of the above

Answer: C

Q3) C++ 11 introduces an alternative way to define variables, using the template key word and an initialization value.

A)True

B)False

Answer: False

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

44 Verified Questions

44 Flashcards

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

Sample Questions

Q1) This manipulator is used to establish a field width for the value immediately following it.

A)field_width

B)set_field

C)setw

D)iomanip

E)None of the above

Answer: C

Q2) If you want to know the length of the string that is stored in a string object, you can call the object's size member function.

A)True

B)False

Answer: False

Q3) When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive.

A)True

B)False

Answer: False

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

53 Verified Questions

53 Flashcards

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

Sample Questions

Q1) Whereas < is called a relational operator, x < y is called a(n)________.

A)Arithmetic operator

B)Relative operator

C)Relational expression

D)Largeness test

E)None of these

Q2) When a program lets the user know that an invalid choice has been made, this is known as:

A)input validation

B)output correction

C)compiler criticism

D)output validation

E)None of these

Q3) The ________ of a variable is limited to the block in which it is declared.

A)precedence

B)associativity

C)scope

D)branching ability

E)None of these

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

Page 6

Chapter 5: Loops and Files

Available Study Resources on Quizplus for this Chatper

63 Verified Questions

63 Flashcards

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

Sample Questions

Q1) A while loop's body can contain multiple statements, as long as they are enclosed in braces.

A)True

B)False

Q2) If you want a user to enter exactly 20 values, which loop would be the best to use?

A)do-while

B)for

C)while

D)infinite

E)None of these

Q3) To read data from a file, you define an object of this data type.

A)inputFile

B)ifstream

C)fstream

D)ofstream

Q4) The increment and decrement operators can be used in mathematical expressions; however, they cannot be used in relational expressions.

A)True

B)False

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

49 Verified Questions

49 Flashcards

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

Sample Questions

Q1) This is a collection of statements that performs a specific task.

A)infinite loop

B)variable

C)constant

D)function

E)None of these

Q2) A static variable that is defined within a function is initialized only once, the first time the function is called.

A)True

B)False

Q3) One reason for using functions is to break programs into manageable units, or modules.

A)True

B)False

Q4) A parameter is a special-purpose variable that is declared inside the parentheses of a function definition.

A)True

B)False

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

Page 8

Chapter 7: Arrays

Available Study Resources on Quizplus for this Chatper

58 Verified Questions

58 Flashcards

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

Sample Questions

Q1) If an array is partially initialized, the uninitialized elements will be set to zero.

A)True

B)False

Q2) By using the same ________ you can build relationships between data stored in two or more arrays.

A)array name

B)data

C)subscript

D)arguments

E)None of these

Q3) When writing functions that accept multi-dimensional arrays as arguments, ________ must be explicitly stated in the parameter list.

A)all dimensions

B)all but the first dimension

C)the size declarator of the first dimension

D)all element values

E)None of these

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

9

Chapter 8: Searching and Sorting Arrays

Available Study Resources on Quizplus for this Chatper

20 Verified Questions

20 Flashcards

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

Sample Questions

Q1) In the average case, an item is just as likely to be found near the beginning of an array as near the end.

A)True

B)False

Q2) Array elements must be ________ before a binary search can be performed.

A)summed

B)set to zero

C)sorted

D)positive numbers

E)None of these

Q3) The ________ sort usually performs fewer exchanges than the ________ sort.

A)bubble, selection

B)binary, linear

C)selection, bubble

D)ANSI, ASCII

E)None of these

Q4) The bubble sort is an easy way to arrange data into ascending order, but it cannot arrange data into descending order.

A)True

B)False

10

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

Chapter 9: Pointers

Available Study Resources on Quizplus for this Chatper

45 Verified Questions

45 Flashcards

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

Sample Questions

Q1) An array name is a pointer constant because the address stored in it cannot be changed during runtime.

A)True

B)False

Q2) With pointer variables, you can ________ manipulate data stored in other variables.

A)never

B)seldom

C)indirectly

D)All of these

E)None of these

Q3) C++ does not perform array bounds checking, making it possible for you to assign a pointer the address of an element out of the boundaries of an array.

A)True

B)False

Q4) A pointer can be used as a function argument, giving the function access to the original argument.

A)True

B)False

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

Chapter 10: Characters, C-Strings, and More About the String Class

Available Study Resources on Quizplus for this Chatper

45 Verified Questions

45 Flashcards

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

Sample Questions

Q1) The string class's front and back member functions were introduced in C++ 11.

A)True

B)False

Q2) If an uppercase character is passed as an argument to toupper, the result will be an uppercase character.

A)True

B)False

Q3) This function accepts a C-string containing a number as its argument and returns the integer equivalent.

A)strToInt

B)itoa

C)atoi

D)int_from

E)None of these

Q4) A library function that can find one C- string inside another is:

A)strcmp

B)strstr

C)strfind

D)strsearch

E)None of these

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

Chapter 11: Structured Data

Available Study Resources on Quizplus for this Chatper

53 Verified Questions

53 Flashcards

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

Sample Questions

Q1) The structure pointer operator is used to dereference a pointer to a structure, not a pointer that is a member of a structure.

A)True

B)False

Q2) A structure ________ contain members of the same data type.

A)cannot

B)can

C)shouldn't

D)None of these

Q3) A good reason to pass a structure as a constant reference is ________.

A)to prevent changes to the structure members

B)to ensure changes to the structure members

C)to slow down the function's execution, preventing errors

D)to speed up the function's modification of the structure members

E)None of these

Q4) In C++ 11, if you want to retrieve a strongly typed enumerator's underlying integer value, you must use a cast operator.

A)True

B)False

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

Chapter 12: Advanced File Operations

Available Study Resources on Quizplus for this Chatper

38 Verified Questions

38 Flashcards

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

Sample Questions

Q1) When used by itself, the ios::app flag causes the file's existing contents to be deleted if the file already exists.

A)True

B)False

Q2) Only one file stream object can be declared per C++ program.

A)True

B)False

Q3) In order, the three-step process of using a file in a C++ program involves:

A)Insert a disk, open a file, remove the disk

B)Create the file contents, close the file, name the file

C)Open the file, read/write/save data, close the file

D)Name the file, open the file, delete the file

E)None of these

Q4) All stream objects have ________, which indicate the condition of the stream.

A)error state bits

B)condition statements

C)markers

D)intrinsic error messages

E)None of these

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

Chapter 13: Introduction to Classes

Available Study Resources on Quizplus for this Chatper

47 Verified Questions

47 Flashcards

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

Sample Questions

Q1) Assume that myCar is an instance of the Car class, and that the Car class has a member function named accelerate. Which of the following is a valid call to the accelerate member function?

A)Car->accelerate();

B)myCar::accelerate();

C)myCar.accelerate();

D)myCar:accelerate();

Q2) You must use the private access specification for all data members of a class.

A)True

B)False

Q3) When an object is defined without an argument list for its constructor, the compiler automatically calls the object's default constructor.

A)True

B)False

Q4) Class objects can be defined prior to the class declaration. A)True

B)False

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

15

Chapter 14: More About Classes

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) C++ permits you to overload the sizeof operator and the this pointer.

A)True

B)False

Q2) In C++, if you overload the < operator, you must also overload the > operator.

A)True

B)False

Q3) You can overload the conditional operator to make it function as an unconditional operator.

A)True

B)False

Q4) A(n)________ informs the compiler that a class will be declared later in the program.

A)static function

B)private data member

C)forward declaration

D)object conversion

E)None of these

Q5) It is possible to declare an entire class as a friend of another class.

A)True

B)False

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

Chapter 15: Inheritance, Polymorphism, and Virtual Functions

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Protected members of a base class are like ________, but they may be accessed by derived classes.

A)constructor functions

B)static members

C)private members

D)public members

E)None of these

Q2) When a derived class has two or more base classes, the situation is known as ________.

A)multiple inheritance

B)polymorphism

C)encapsulation

D)access specification

E)None of these

Q3) ________ 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 these

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

39 Verified Questions

39 Flashcards

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

Sample Questions

Q1) An exception thrown from outside a try block ________.

A)will be caught outside the catch block

B)will be caught inside the catch block

C)will remain inside the throw block

D)will cause the program to abort execution

E)None of these

Q2) The algorithms provided by the STL are implemented as ________, and perform various operations on elements of containers.

A)virtual functions

B)function templates

C)global variables

D)private data members

E)None of these

Q3) A program may not contain both a "regular" version of a function and a template version of the function.

A)True

B)False

Q4) Using a function template requires less code than overloading a function.

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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) When you delete a node from a list, you must ensure that the links in the list are not permanently broken.

A)True

B)False

Q2) The Standard Template Library (STL)provides a linked list container.

A)True

B)False

Q3) A linked list is called "linked" because each node in the series has a pointer that points to the next node in the list.

A)True

B)False

Q4) A linked list can grow and shrink as a program runs.

A)True

B)False

Q5) A doubly-linked list keeps track of the next node in the list, as well as: A)itself

B)the head node

C)the tail node

D)the previous node

E)None of these

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

47 Verified Questions

47 Flashcards

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

Sample Questions

Q1) This is a container that provides quick access to elements at the front and the back of the list.

A)stack

B)queue

C)deque

D)All of these

E)None of these

Q2) The pop function in the stack template of the STL does not retrieve the value from the top of the stack.

A)True

B)False

Q3) The programmer must declare in advance the size of a dynamic stack or queue.

A)True

B)False

Q4) Two primary queue operations are:

A)push and pop

B)enqueue and dequeue

C)insert and delete

D)onqueue and offqueue

E)None of these

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

Chapter 19: Recursion

Available Study Resources on Quizplus for this Chatper

22 Verified Questions

22 Flashcards

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

Sample Questions

Q1) The QuickSort algorithm works on the basis of A)three sublists

B)two sublists and a pivot

C)two pivots and a sublist

D)three pivots

E)None of these

Q2) When recursion is used on a linked list, it will always display the contents of the list in reverse order.

A)True

B)False

Q3) Like a loop, a recursive function must have some method to control the number of times it repeats.

A)True

B)False

Q4) Any algorithm that can be coded with recursion can also be coded with an iterative structure.

A)True

B)False

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

Page 21

Chapter 20: Binary Trees

Available Study Resources on Quizplus for this Chatper

38 Verified Questions

38 Flashcards

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

Sample Questions

Q1) A binary tree can be created using a struct or class containing a data value and

A)a pointer to the first child node

B)a pointer to the last child node

C)two pointers, one for the left child and one for the right child

D)two data nodes

E)None of these

Q2) Binary trees can be divided into:

A)branches

B)leaves

C)subtrees

D)sawdust

E)None of these

Q3) In a binary tree class, you usually have a pointer as a member that is set to

A)the leftmost child node

B)the first leaf node

C)the root of the tree

D)the deepest leaf node

E)None of these

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

Turn static files into dynamic content formats.

Create a flipbook
Introduction to Algorithms and Programming Mock Exam - 891 Verified Questions by Quizplus - Issuu