Accounting
Anthropology
Archaeology
Art History
Banking
Biology & Life Science
Business
Business Communication
Business Development
Business Ethics
Business Law
Chemistry
Communication
Computer Science
Counseling
Criminal Law
Curriculum & Instruction
Design
Earth Science
Economic
Education
Engineering
Finance
History & Theory
Humanities
Human Resource
International Business
Investments & Securities
Journalism
Law
Management
Marketing
Medicine
Medicine & Health Science
Nursing
Philosophy
Physic
Psychology
Real Estate
Science
Social Science
Sociology
Special Education
Speech
Visual Arts
Computer Science
Q:
Which statement is false?
a) Cast expressions cannot be evaluated in preprocessor directives.
b) Arithmetic expressions cannot be evaluated in preprocessor directives.
c) sizeof expressions cannot be evaluated in preprocessor directives.
d) Enumeration constants cannot be evaluated in preprocessor directives.
Q:
Conditional compilation cannot be used to
(a) perform loops.
(b) ignore large blocks of code.
(c) debug programs.
(d) selectively define symbolic constants.
Q:
Which of the following is not a valid directive?
(a) #endif
(b) #ifdef
(c) #for
(d) #elif
Q:
Large portions of code can be prevented from compiling by
(a) #if 0
code prevented from compiling
#endif
(b) #nodefine
code prevented from compiling
#endif
(c) #if 1
code prevented from compiling
#endif
(d) #ifndef 0
code prevented from compiling
#endif
Q:
Which statement is correct?
a) Expressions with side effects (i.e., variable values are modified) should not be passed to a macro because macro arguments may be evaluated more than once.
b) Expressions with side effects (i.e., variable values are modified) should not be passed to a macro because macro arguments are evaluated only once.
c) Expressions with side effects (i.e., variable values are modified) should be passed to a macro because macro arguments may be evaluated more than once.
d) Expressions with side effects (i.e., variable values are modified) should be passed to a macro because macro arguments are evaluated only once.
Q:
A macro commonly defined in the stdio.h header file is
a) #define getchar() getchar(stdin)
b) #define getchar() getc(stdin)
c) #define getc() getchar (stdin)
d) #define getc() getc(stdin)
Q:
Which statement about symbolic constants and/or macros is true?
a) The effects of symbolic constants and macros, once defined, cannot be modified.
b) Preprocessor directive #removedef undefines a symbolic constant or macro.
c) The scope of a symbolic constant or macro is normally from its point of definition to the end of the file, but this can be modified with a preprocessor directive.
d) A name can always be redefined with #define.
Q:
Symbolic constants and macros can be discarded by using the __________ preprocessor directive.
a) #undefine
b) #discard
c) #dscrd
d) #undef
Q:
Macros
a) can help avoid the overhead of a function call.
b) execute before a program is compiled.
c) never add subtle bugs to programs.
d) cannot be used to replace a function call with inline code.
Q:
The parentheses around the two rightmost occurrences of x in the following preprocessor directive:
#define CIRCLE_AREA(x) ((PI) * (x) * (x))
a) are always required.
b) are included to improve program readabiliy.
c) are included to eliminate bugs when an expression is substituted for x.
d) should be curly braces { }.
Q:
Which statement about macros is true?
a) Macros always make programs run faster.
b) Macros cannot have arguments.
c) Macros cause text replacement at execution time.
d) Macro arguments should be enclosed in parentheses in the replacement text.
Q:
Macros are defined
a) in an #include preprocessor directive
b) in a #define preprocessor directive
c) in a #macro preprocessor directive
d) using keyword #MACRO in a C function.
Q:
Macros have the disadvantage, when compared to functions, of
(a) having the overhead of a function call.
(b) increasing program size (if the macros are called from many places in the program).
(c) having to fit the macro definition on a single line.
(d) taking only one argument.
Q:
Which of the following is false? Macros
(a) must be defined with arguments.
(b) are replaced by their replacement text during execution time.
(c) cannot be redefined once defined.
(d) have no data type checking.
Q:
The #undef preprocessor directive
(a) can only be used once per macro name.
(b) can only be used on symbolic constants.
(c) allows macros to be redefined with #define later in the program.
(d) must be called for all symbolic constants before the end of the file.
Q:
If the macro
#define RECTANGLE_AREA(x, y) ((x) * (y))
has been defined. Then the line
rectArea = RECTANGLE_AREA(a + 4, b + 7);
will be expanded to
(a) rectArea = 11;
(b) rectArea = (a + 4 * b + 7);
(c) rectArea = ((a + 4) * (b + 7));
(d) RECTANGLE_AREA(a + 4 , b + 7);
Q:
What is a problem with the preprocessor statement:
#define PI 3.14159;
a) It will make a program run slower.
b) #define should be #def
c) PI should be spelled with lowercase letters.
d) The semicolon is part of the substitution text, so 3.14159; will be substituted whereever PI is used and this could lead to syntax errors.
Q:
Which statement about symbolic constants is true?
a) They make programs run faster.
b) They always make programs clearer.
c) They make it more difficult to modify programs.
d) Using meaningful names for symbolic constants helps make programs more self-documenting.
Q:
Which statement is false?
a) Symbolic constants are constants represented as symbols.
b) Macros are operations defined as symbols.
c) All text replacement with symbolic constants and macros occurs before the program is compiled.
d) Symbolic constants may be redefined with new values.
Q:
Which of the following statements is correct?
(a) #define X = 3
(b) #define X 3, Y 4
(c) #define X 3
(d) #define X:3
Q:
. const variables are preferred to symbolic constants (from #define) because
(a) constvariables take up less memory.
(b) symbolic constants can be changed.
(c) const variable names are visible to the compiler
(d) const variables do not have to be of a specific data type.
Q:
Which statement about the #include preprocessor directive is false?
a) It is used with programs consisting of several source files that are to be compiled together.
b) A header file containing definitions common to separate program files is often created and included in a program with #include.
c) #include header files often contain structure and union definitions, enumerations and function prototypes.
d) It includes standard library header files such as standardio.h.
Q:
Which statement about the #include directive is false?
a) The difference between the various forms of the #include directive is the location the preprocessor searches for the file to be included.
b) If the file name is enclosed in quotes, the preprocessor searches in the same directory as the file being compiled for the file to be included.
c) If the file name is enclosed in angle brackets, the preprocessor searches in the same directory as the file being compiled for the file to be included.
d) The preprocessor searches for standard library header files in an implementation-dependent manner.
Q:
Which is a correct form of the #include directive
a) #include "filename"
b) #include /filename/
c) #include #filename
d) #include <filename>
Q:
The #include directive
a) must begin in column 1
b) includes a file in the program at execution time
c) includes a file in the program before compilation
d) appends a file to the end of the program
Q:
Which include statement is usually appropriate for user-defined files?
(a) include <filename>
(b) #include "filename"
(c) Both (a) and (b) are appropriate.
(d) Neither (a) nor (b) is appropriate.
Q:
The #includepreprocessor directive causes a(n) ____________ to be included in place of the directive.
(a) copy of a file
(b) # character
(c) pointer to a file
(d) bitfield
Q:
Which statement about the preprocessor is false?
a) it can perform conditional compilation of program code
b) it can perform conditional execution of preprocessor directives
c) all preprocessor directives begin with #
d) all preprocessor directives must end in a semicolon.
Q:
Which is not a capability of the preprocessor?
a) inclusion of other files in the file being compiled
b) definition of functions
c) definition of symbolic constants
d) definition of macros
Q:
Preprocessor directives
(a) begin with include
(b) are C statements.
(c) are ignored if whitespace characters before them on the same line.
(d) do not end in a semicolon.
Q:
Preprocessing occurs
(a) before a program is compiled.
(b) during compilation.
(c) after compilation but before execution.
(d) immediately before execution.
Q:
Which of the following statements is false?
(a) Pointers should not be left uninitialized.
(b) When you use free to deallocate dynamically allocated memory, the pointer passed to free is set to NULL.
(c) Undefined behavior occurs when you attempt to use free to deallocate dynamic memory that was already deallocated
(d)Function malloc returns NULL if it's unable to allocate the requested memory.
Q:
Which statement about the level-order traversal of a binary tree is false?
a) It visits the nodes of a tree row by row.
b) The search begins at the root node.
c) The search begins at the row of the leftmost leaf node.
d) On each level of the tree, the nodes are visited left to right.
Q:
Which of the following statements about binary search trees is false?
a) The binary search tree facilitates duplicate elimination.
b) In a tightly packed binary search tree, each level contains about half as many elements as the previous level. (The previous level is the level closer to the root node.)
c) When searching a tightly packed billion-element search tree, only about 30 elements (or fewer) are required to locate most elements.
d) When searching a tightly packed million-element search tree, only about 20 elements (or fewer) are required to locate most elements.
Q:
Which type of binary search tree traversal processes the node values in ascending order?
a) in-order traversal
b) pre-order traversal
c) post-order traversal
d) duplicate elimination traversal
Q:
The steps for an in-order traversal of a binary search tree include each of the following except _________.
a) Traverse the left subtree in-order.
b) Process the value in the root node.
c) Skip over duplicate values.
d) Traverse the right subtree in-order,
Q:
A node can only be inserted __________ in a binary search tree.
a) as the root node
b) as a leaf node
c) as a parent node
d) as an ancestor node
Q:
Which of the following statements about binary search trees with no duplicate values is false?
a) The values in any left subtree are less than the values in its parent node.
b) The values in any right subtree are less than the values in its parent node.
c) The shape of the tree that corresponds to a particular set of data can vary based on the order in which the values are inserted into the tree.
d) It is possible that a binary tree could contain all its values along one straight path through the tree.
Q:
Which statement is not true for binary trees.
a) The left child in the root node is the first node in the left subtree.
b) The children of a node are called siblings.
c) A node with no children is called an orphan.
d) The root node is the first node in the tree.
Q:
Which statement about trees is false?
a) A tree is a non-linear, two-dimensional data structure.
b) Tree nodes contain two or more links.
c) Binary tree nodes contain two or fewer links.
d) Binary tree nodes contain exactly two links.
Q:
If you have a 1000-element balanced binary search tree, what is the maximum number of comparisons that may be needed to find an element in the tree?
(a) 500
(b) 10
(c) 20
(d) 8
Q:
Suppose you have a list of names sorted in alphabetical order, already stored in one of the data types below. The easiest way to print the names in reverse alphabetical order would be to use a
(a) binary search tree
(b) stack
(c) queue
(d) circular, singly linked list
Q:
Add the following nodes to a binary search tree in the order they appear.
6 34 17 19 16 10 23 3
What is the output of a postorder traversal of this tree?
(a) 3 10 16 23 19 17 34 6
(b) 3 6 17 16 10 19 23
(c) 6 3 34 17 16 10 19 23
(d) 10 16 23 19 17 34 3 6
Q:
Select the incorrect statement. Binary trees (regardless of the order in which the values are inserted into the tree)
(a) always have multiple links per node.
(b) can be sorted efficiently.
(c) always have the same shape for a particular set of data.
(d) are nonlinear data structures.
Q:
Which of the following is not true of queues?
a) Network packets wait in queues for service at routers .
b) The entry at the front (or head) of the queue is the next to be removed.
c) Queues are used to support print spooling.
d) Queues are used to support high-speed sorting algorithms.
Q:
Queues are linear data structures with the property that queue nodes are inserted only at the tail of the queue and removed only from the head of the queue. For this reason, queues are referred to as __________ data structures.
a) first-in, first-out
b) first-in, last-out
c) last-in, first-out
d) first-come, first-served
Q:
A linked list has the functions insertAtFront, removeFromFront, insertAtBack, and removeFromBack, which perform operations on nodes exactly as their names describe. Which two functions would most
naturally model the operation of a queue?
(a) insertAtBackand removeFromBack.
(b) insertAtBackand removeFromFront.
(c) insertAtFrontand removeFromFront.
(d) insertAtFrontand removeFromBack.
Q:
A queue receives the following commands (in pseudo-code):
enqueue 4, 6, 8, 3, 1
dequeue three elements
enqueue 3, 1, 5, 6
dequeue two elements
What number is at the front of the queue?
(a) 3
(b) 4
(c) 5
(d) 6
Q:
Which is not a popular application of stacks?
a) enabling called functions to return to their callers
b) supporting recursive function calls
c) containing the space created for automatic variables
d) maintaining waiting lines
Q:
Which of the following statements is false?
a) The primary functions used to manipulate a stack are push and pop.
b) Function pop removes a node from the bottom of the stack.
c) Function push creates a new node and places it on top of the stack.
d) A stack can be implemented as a constrained version of a linked list by allowing insertions and deletions only at one end of the linked list.
Q:
The link member in the last node of a stack is typically set to __________ indicate the bottom of the stack.
a) void
b) void *
c) NULL
d) empty
Q:
New nodes can be added to a stack and removed from the stack only at its top. For this reason a stack is referred to as a __________ data structure.
a) first-in, first-out
b) linear
c) last-in, first-out
d) dynamic
Q:
A stack is initially empty, then the following commands are performed.
push 5
push 7
pop
push 10
push 5
pop
Which of the following is the correct stack (assume the top of the stack is on the left).
(a) 5 10 7 5
(b) 5 10
(c) 7 5
(d) 10 5
Q:
Which of the following statements about stacks is incorrect?
(a) stacks can be implemented using linked lists.
(b) stacks are first in, first-out (FIFO) data structures.
(c) new nodes can only be added to the top of the stack.
(d) the last node (the bottom) of a stack has a null (zero) link.
Q:
Passing a pointer to a pointer is called __________.
a) double direction
b) pointer passing
c) double indirection
d) indirection
Q:
Functions such as isEmpty and isFull that test a condition and return a value that can be interpreted as true or false, are called __________ functions.
a) imperative
b) declarative
c) predicate
d) conditional
Q:
Which statement is false?
a) Arrays are normally stored contiguously in memory.
b) Dynamic memory allocation can sometimes use memory more efficiently than using fixed-size data structures.
c) Dynamic memory allocation incurs execution-time overhead.
d) Linked lists are normally stored contiguously in memory.
Q:
Which of the following is false?
a) Arrays can be maintained in sorted order.
b) Linked lists can be maintained in sorted order.
c) Insertion and deletion in a sorted array (while maintaining sorted order) is efficient.
d) Once the insertion point or the node to be deleted has been located, insertion or deletion in a sorted linked list (while maintaining sorted order) is efficient.
Q:
Which of the following is false?
a) Lists of data can be stored in arrays.
b) The length of a linked list can vary dynamically.
c) Arrays can become full.
d) Linked lists cannot become full.
Q:
Which of the following is a non-linear data structure?
a) linked list
b) queue
c) binary tree
d) stack
Q:
A linked list is a __________ collection of self-referential structures, called nodes, connected by pointer links.
a) hierachical
b) linear
c) branching
d) constant
Q:
How many pointers are contained in a circular, doubly linked list with five nodes?
(a) 5
(b) 8
(c) 15
(d) 10
Q:
For a non-empty linked list, select the code that should appear in a function that adds a node to the end of the list. newPtris a pointer to the new node to be added, and lastPtris a pointer to the current last node. Each node contains a pointer nextPtr, a link to a node.
(a)
lastPtr->nextPtr = newPtr;
lastPtr = newPtr;
(b)
lastPtr = newPtr;
lastPtr->nextPtr = newPtr;
(c)
newPtr->nextPtr = lastPtr;
lastPtr = newPtr;
(d)
lastPtr = newPtr;
newPtr->nextPtr = lastPtr;
Q:
__________ is not an advantage of linked lists when compared to arrays.
(a) Dynamic memory allocation
(b) Efficient insertion and deletion
(c) Direct access to any list element
(d) Efficient use of memory
Q:
Which of these is not a common programming error?
a) Referring to memory that has been freed.
b) Freeing memory (with free) that was not dynamically allocated.
c) Assuming that the size of a structure is simply the sum of the sizes of its members.
d) Calling malloc in a statement without using sizeof.
Q:
When memory allocated with malloc is no longer needed, return that memory to the system immediately with __________.
a) free_memory
b) free_storage
c) return
d) free
Q:
Not returning dynamically allocated memory when it is no longer needed can cause a system to run out of memory prematurely. This is called a(n) __________.
a) outage
b) memory hole
c) memory access violation
d) memory leak
Q:
Which is correct?
a) Use the size operator to determine the size of a structure.
b) Use the struct size operator to determine the size of a structure.
c) Use the sizeof operator to determine the size of a structure.
d) Determine the size of a structure manually by carefully adding up the sizes of the members.
Q:
Which of the following statements is true?
a) A structure's size is sometimes smaller than the total of the sizes of its members.
b) A structure's size is always larger than the total of the sizes of its members.
c) A structure's size is not necessarily the sum of the sizes of its members.
d) A structure's size is the sum of the sizes of its members.
Q:
If no memory is available mallocreturns a(n) __________ pointer.
a) self
b) NULL
c) void
d) empty
Q:
Function malloc takes as an argument the number of bytes to be allocated, and returns a pointer of type __________ to the allocated memory.
a) char *
b) int *
c) void *
d) NULL *
Q:
__________ memory allocation is the ability for a program to obtain more memory space at execution time and to release space no longer needed.
a) Static
b) Active
c) Selective
d) Dynamic
Q:
A __________ occurs when dynamically allocated memory is not returned when it's no longer needed.
(a) memory leak
(b) self-referential error
(c) allocation error
(d) sizeoferror
Q:
A(n) __________ pointer normally indicates the end of a data structure.
a) uninitialized
b) NULL
c) self
d) dereferenced
Q:
A self-referential structure contains a ________ member that points to ________.
(a) integer, a structure of the same structure type
(b) pointer, an integer
(c) integer, an integer
(d) pointer, a structure of the same structure type
Q:
__________ facilitate high-speed searching and sorting of data, efficient elimination of duplicate items and compiling expressions into machine language.
a) Linked lists
b) Queues
c) Stacks
d) Binary Trees
Q:
__________ represent waiting lines; insertions are made at the back (also called the tail) and deletions are made from the front (also called the head) of a __________.
a) Linked lists, linked list
b) Queues, queue
c) Stacks, stack
d) Binary trees, binary tree
Q:
__________ are important in compilers and operating systemsinsertions and deletions are made only at one end of a __________its top.
a) Linked lists, linked list
b) Queues, queue
c) Stacks, stack
d) Binary trees, binary tree
Q:
__________ are collections of data items "lined up in a row"insertions and deletions are made anywhere in a __________.
a) Linked lists, linked list
b) Queues, queue
c) Stacks, stack
d) Binary trees, binary tree
Q:
Which of the following statements is true?
(a) Files written in binary format are always portable.
(b) C11's new exclusive mode allows fopen to open a file only if it does not already exist.
(c) All platforms allow you to open an unlimited number of files.
(d)None of the above