

Data Structures and Algorithms
Exam Questions
Course Introduction
Data Structures and Algorithms explores the fundamental principles and techniques used to efficiently organize, process, and retrieve data within computer systems. The course covers essential data structures such as arrays, linked lists, stacks, queues, trees, and graphs, and delves into algorithmic strategies for searching, sorting, recursion, and dynamic programming. Emphasis is placed on analyzing the efficiency of algorithms using Big O notation, evaluating trade-offs between different approaches, and applying these concepts to solve real-world computational problems. By mastering these core concepts, students will build a solid foundation for advanced studies in computer science and software development.
Recommended Textbook
Starting Out with Java From Control Structures through Data Structures 2nd Edition by Tony Gaddis
Available Study Resources on Quizplus
22 Chapters
981 Verified Questions
981 Flashcards
Source URL: https://quizplus.com/study-set/3640 Page 2


Chapter 1: Introduction to Computers and Java
Available Study Resources on Quizplus for this Chatper
42 Verified Questions
42 Flashcards
Source URL: https://quizplus.com/quiz/72352
Sample Questions
Q1) Which of the following will compile a program called ReadIt?
A) java ReadIt.java
B) java ReadIt.javac
C) javac ReadIt.java
D) javac ReadIt.javac
Answer: C
Q2) The original name for Java was
A) Java
B) HotJava
C) Elm
D) Oak
Answer: D
Q3) Byte code instructions are:
A) Another name for source code
B) Syntax errors
C) Machine code instructions
D) Read and interpreted by the JVM
Answer: D
To view all questions and flashcards with answers, click on the resource link above.
3
Chapter 2: Java Fundamentals
Available Study Resources on Quizplus for this Chatper
53 Verified Questions
53 Flashcards
Source URL: https://quizplus.com/quiz/72353
Sample Questions
Q1) What would be printed out as a result of the following code? System.out.println("The quick brown fox" + "jumped over the \ n" "slow moving hen.");
A) The quick brown fox jumped over the \ nslow moving hen.
B) The quick brown fox jumped over the Slow moving hen.
C) The quick brown fox Jumped over the Slow moving hen.
D) Nothing.This is an error.
Answer: D
Q2) The boolean data type may contain values in the following range of values
A) true or false
B) -128 to + 127
C) - 2,147,483,648 to +2,147,483,647
D) - 32,768 to +32,767
Answer: A
To view all questions and flashcards with answers, click on the resource link above.

Page 4

Chapter 3: Decision Structures
Available Study Resources on Quizplus for this Chatper
52 Verified Questions
52 Flashcards
Source URL: https://quizplus.com/quiz/72354
Sample Questions
Q1) In Java,when a character is stored in memory,it is actually stored as a(n)_____.
A) Unicode number
B) ASCII character code
C) EBCDIC character code
D) Morse code
Answer: A
Q2) What does the following code display? double x = 12.3798146; System.out.printf("%.2f \ n",x);
A) 123798146
B) 1238
C) %12.38
D) 12.38
Answer: D
Q3) Unicode is an international encoding system that is extensive enough to represent ALL the characters of ALL the world's alphabets.
A)True
B)False
Answer: True
To view all questions and flashcards with answers, click on the resource link above. Page 5

Chapter 4: Loops and Files
Available Study Resources on Quizplus for this Chatper
48 Verified Questions
48 Flashcards
Source URL: https://quizplus.com/quiz/72355
Sample Questions
Q1) In the following code,what values could be read into number to terminate the while loop? Scanner keyboard = new Scanner(System.in); System.out.print("Enter a number: "); Int number = keyboard.nextInt(); While (number < 100 && number > 500)
{ System.out.print("Enter another number: "); Number = keyboard.nextInt();
}
A) Numbers less than 100 or greater than 500
B) Numbers in the range 100 - 499
C) Numbers in the range 100 - 500
D) The boolean condition can never be true
Q2) Assuming that inputFile references a Scanner object that was used to open a file,which of the following statements will read an int from the file?
A) int number = inputFile.nextInt();
B) int number = inputFile.next();
C) int number = inputFile.readInt();
D) int number = inputFile.integer();
To view all questions and flashcards with answers, click on the resource link above.

Chapter 5: Methods
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/72356
Sample Questions
Q1) Any method that calls a method with a throws clause in its header must A) handle the potential exception
B) have the same throws clause
C) Both of the above
D) do nothing,the called program will take care of the throws clause
Q2) Which of the following would be a valid method call for the following method? public static void showProduct (int num1,double num2)
{
Int product;
Product = num1 * (int)num2; System.out.println("The product is " + product);
}
A) showProduct(5.5,4.0);
B) showProduct(10.0,4);
C) showProduct(10,4.5);
D) showProduct(33.0,55.0);
Q3) In the method header the static method modifier means the method is available to code outside the class.
A)True B)False
To view all questions and flashcards with answers, click on the resource link above. Page 7

Chapter 6: A First Look at Classes
Available Study Resources on Quizplus for this Chatper
49 Verified Questions
49 Flashcards
Source URL: https://quizplus.com/quiz/72357
Sample Questions
Q1) Instance methods should be declared static.
A)True
B)False
Q2) Look at the following statement. import java.util.*;
This is an example of
A) a wildcard import
B) an explicit import
C) unconditional import
D) conditional import
Q3) A constructor
A) always accepts two arguments
B) has return type of void
C) has the same name as the class
D) always has an access specifier of private
Q4) What does the following UML diagram entry mean? + setHeight(h : double): void
A) this is a public attribute named Height and is a double data type
B) this is a private method with no parameters and returns a double data type
C) this is a private attribute named Height and is a double data type
D) this is a public method with a parameter of data type double and does not return a value
8
To view all questions and flashcards with answers, click on the resource link above.

Chapter 7: A First Look at Gui Applications
Available Study Resources on Quizplus for this Chatper
49 Verified Questions
49 Flashcards
Source URL: https://quizplus.com/quiz/72358
Sample Questions
Q1) Assume that the variable checkbox references a JCheckBox object.To determine whether the check box has been selected,use the following code.
A) if (isSelected(checkBox)){/*code to execute,if selected*/}
B) if (checkBox.isSelected()){/*code to execute,if selected*/}
C) if (checkBox){/*code to execute,if selected*/}
D) if (checkBox.doClick()){/*code to execute,if selected*/}
Q2) If panel references a JPanel object,which of the following statements adds the GridLayout to it?
A) panel.setLayout(new (GridLayout(2,3));
B) panel.addLayout(new (GridLayout(2,3)); C) panel.GridLayout(2,3); D) panel.attachLayout(GridLayout(2,3));
Q3) The following statement adds the FlowLayout manager to the container,centers the components,and separates the components with a gap of 10 pixels. setLayout(new FlowLayout());
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 9

Chapter 8: Arrays and the Arraylist Class
Available Study Resources on Quizplus for this Chatper
52 Verified Questions
52 Flashcards
Source URL: https://quizplus.com/quiz/72359
Sample Questions
Q1) What would be the results of the following code? int[] array1 = new int[25]; // Code that will put values in array1
Int value = array1[0];
For (int a = 1;a < array1.length;a++)
{ If (array1[a] < value)
Value = array1[a];
}
A) value contains the highest value in array1
B) value contains the lowest value in array1
C) value contains the sum of all the values in array1
D) value contains the average of the values in array1
Q2) This ArrayList class method deletes an item from an ArrayList.
A) remove
B) delete
C) erase
D) purge
Q3) Java limits the number of dimensions that an array may have to 15.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 10

Chapter 9: A Second Look at Classes and Objects
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/72360
Sample Questions
Q1) Look at the following declaration. enum Tree { OAK,MAPLE,PINE }
What is the fully-qualified name of the PINE enum constant?
A) PINE
B) enum.PINE
C) Tree.PINE
D) enum.PINE.
E) PINE.Tree
Q2) Assuming the following declaration exists: enum Tree { OAK,MAPLE,PINE }
What will the following code display?
System.out.println(Tree.OAK);
A) Tree.OAK
B) 0
C) 1
D) OAK
E) Nothing.This statement will cause an error.
Q3) You can declare an enumerated data type inside of a method.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above.
11

Chapter 10: Text Processing and More About Wrapper
Classes
Available Study Resources on Quizplus for this Chatper
49 Verified Questions
49 Flashcards
Source URL: https://quizplus.com/quiz/72361
Sample Questions
Q1) What will be printed after the following code is executed? String str = "abc456"; Int m = 0; While ( m < 6 )
{ If (Character.isLetter(str.charAt(m))) System.out.print( Character.toUpperCase(str.charAt(m))); M++;
}
A) abc456
B) ABC456
C) ABC
D) 456
Q2) When you are writing a program with String objects that may have unwanted spaces at the beginning or end of the strings,use this method to delete them. A) replace B) trim
C) valueOf D) substring
To view all questions and flashcards with answers, click on the resource link above. Page 12
Chapter 11: Inheritance
Available Study Resources on Quizplus for this Chatper
49 Verified Questions
49 Flashcards
Source URL: https://quizplus.com/quiz/72362
Sample Questions
Q1) When one object is a specialized version of another object,there is this type of relationship between them.
A) "has a"
B) "is a"
C) direct
D) "contains a"
Q2) In the following statement,which is the superclass? public class ClassA extends ClassB implements ClassC
A) ClassA
B) ClassB
C) ClassC
D) Cannot tell
Q3) In UML diagrams,inheritance is shown
A) With a line that has an open arrowhead at one end that points to the superclass
B) With a line that has an open arrowhead at one end that points to the subclass
C) With a line that has a closed arrowhead at one end that points to the superclass
D) With a line that has a closed arrowhead at one end that points to the subclass
To view all questions and flashcards with answers, click on the resource link above.

13

Chapter 12: Exceptions and Advanced File Io
Available Study Resources on Quizplus for this Chatper
46 Verified Questions
46 Flashcards
Source URL: https://quizplus.com/quiz/72363
Sample Questions
Q1) Classes that inherit from the Error class are
A) for exceptions that are thrown when a critical error occurs,and the application program should not try to handle them.
B) for exceptions that are thrown when a critical error occurs,and the application program should try to handle them.
C) for exceptions that are thrown when an IOException occurs,and the application program should not try to handle them.
D) for exceptions that are thrown when an IOException error occurs,and the application program should try to handle them.
Q2) If the code in a method can potentially throw a checked exception,then that method must
A) handle the exception
B) have a throws clause listed in the method header
C) Neither a or b
D) Either a or b
Q3) The throws clause causes an exception to be thrown.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above.
Chapter 13: Advanced Gui Applications
Available Study Resources on Quizplus for this Chatper
46 Verified Questions
46 Flashcards
Source URL: https://quizplus.com/quiz/72364
Sample Questions
Q1) What will happen when the following code is executed? JPanel panel = new JPanel(); Color selectedColor;
SelectedColor = JColorChooser.showDialog(null, "Select color",Color.BLUE);
A) A Color Chooser will be displayed in the upper,left-hand corner of the screen with "Select color" in its Title Bar and blue pre-selected.
B) A Color Chooser will be displayed in the center of the screen with "Select color" in its Title Bar and blue pre-selected.
C) A Color Chooser will be displayed in the center of the screen with "Select color" as the OK button's text and blue pre-selected.
D) A Color Chooser will be displayed in the lower,right-hand corner of the screen with "Select color" in its Title Bar and blue pre-selected.
Q2) By default the scroll bars are always displayed in a JList component.
A)True B)False
To view all questions and flashcards with answers, click on the resource link above.

15

Chapter 14: Applets and More
Available Study Resources on Quizplus for this Chatper
39 Verified Questions
39 Flashcards
Source URL: https://quizplus.com/quiz/72365
Sample Questions
Q1) Everything that appears between these tags in an HTML document is the content of the Web page.
A) < head > and < /head >
B) < html > and < /html >
C) < doc > and < /doc >
D) < content > and < /content >
Q2) The following getAudioClip()method returns an object that will load the sound file and assign the location of that file to clip which can then be used to call methods that may play the sound file one or more times:
Audioclip clip = getAudioClip(getDocumentBase(),"mysound.wav");
A)True
B)False
Q3) Which of the following will load the applet,TestApplet?
A) < applet code="TestApplet.class" width=200 height=50 >< /applet >
B) < applet code=TestApplet.class width=200 height=50 >< /applet >
C) < load code="TestApplet.class" width=200 height=50 >< /load >
D) < load code=TestApplet.class width=200 height=50 >< /load >
Q4) Some browsers do not directly support the Swing classes of applets.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 16

Chapter 15: Recursion
Available Study Resources on Quizplus for this Chatper
34 Verified Questions
34 Flashcards
Source URL: https://quizplus.com/quiz/72366
Sample Questions
Q1) Look at the following pseudocode algorithm. algorithm Test14(int x)
If (x < 8)
Return (2 * x)
Else
Return (3 * Test14(x - 8)+ 8)
End Test14
What is the recursive case for the algorithm?
A) x < 8
B) 2 * x
C) x != 8
D) x >= 8
Q2) The Towers of Hanoi is
A) a mathematical game
B) often used in computer science textbooks
C) demonstrates the power of recursion
D) All of the above
Q3) Indirect recursion occurs when a method calls another method that in turn calls the first method.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 17
Chapter 16: Sorting, Searching, and Algorithm Analysis
Available Study Resources on Quizplus for this Chatper
46 Verified Questions
46 Flashcards
Source URL: https://quizplus.com/quiz/72367
Sample Questions
Q1) A basic step is
A) an operation that can be executed within a constant amount of time
B) an operation that is used only in the simplest algorithms
C) one that is implemented in a library package
D) None of the above
Q2) Linear time is the class of all complexity functions that are in
A) O(1)
B) O(n.
C) O(n log n.
D) O(log n.
Q3) Let F be an algorithm with complexity function f(n),and let G be an algorithm with complexity function g(n).If the ratio f(n)/g(n)converges to infinity as n increases to infinity,then
A) the algorithm F is asymptotically faster than G
B) the algorithm G is asymptotically faster than F
C) the two algorithms are asymptotically equivalent in efficiency
D) None of the above
To view all questions and flashcards with answers, click on the resource link above.

18

Chapter 17: Generics
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/72368
Sample Questions
Q1) Let Point< T > be a generic type.We want to write a method that takes as parameter Point objects whose type parameter is the Number class,or any superclass of Number.We can do this by writing
A) Point< Number >
B) Point< ? super Number >
C) Point< ? extends Number >
D) Point< ? sub Number >
Q2) The automatic conversion of a primitive type to the corresponding wrapper type when being passed as parameter to a generic class is called
A) type promotion
B) type wrapping
C) autoconversion
D) autoboxing
Q3) A generic class
A) can only extend a class that is also generic
B) can extend generic and non-generic classes
C) can only extend a non generic class
D) cannot extend any class
To view all questions and flashcards with answers, click on the resource link above.
19
Chapter 18: Collections
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/72369
Sample Questions
Q1) A collection that does not impose a positional order on its elements,and does not allow duplicates is called a
A) set
B) linked list
C) non-positional map
D) hash map
Q2) A LinkedList is the right kind of list to use when
A) most of the elements added to the list are being added at the end
B) there are lots of insertions and deletions in the middle of the list
C) elements are added to the list in groups of twos,threes,or more
D) each element added is a reference to another item
Q3) Which of the following is true?
A) Both the Set and List interfaces extend the Collection interface
B) Both the Set and Map interfaces extend the Collection interface
C) Both the List and Map interfaces extend the Collection interface
D) None of the above
To view all questions and flashcards with answers, click on the resource link above.

20

Chapter 19: Array-Based Lists
Available Study Resources on Quizplus for this Chatper
20 Verified Questions
20 Flashcards
Source URL: https://quizplus.com/quiz/72370
Sample Questions
Q1) A constructor for an array-based list takes an integer parameter,to be used as the capacity of the internal array of the list.Which exception should the constructor throw if its parameter is zero or negative?
A) IllegalArgumentException
B) IllegalStateException
C) RuntimeException
D) NullPointerException
Q2) The boolean contains(E element)method searches a ArrayList for a given element.A correct and efficient implementation of this method
A) throws an exception if the element is not found in the list
B) uses binary search to locate the element
C) uses sequential search to locate the element
D) returns 0 if the element is not found in the list
Q3) The E get(int index)method of the List interface should throw an exception if
A) the index passed to it is negative
B) the index passed to it nonnegative
C) the index passed to it is negative or greater or equal to the size of the list
D) the index passed to is negative or greater than the size of the list
To view all questions and flashcards with answers, click on the resource link above.
21

Chapter 20: Linked Lists
Available Study Resources on Quizplus for this Chatper
36 Verified Questions
36 Flashcards
Source URL: https://quizplus.com/quiz/72371
Sample Questions
Q1) To remove a node with a positive index k from a linked list,
A) decrement k by 1,and set the reference to the node to be removed to null
B) start a reference r at the head of the list,walk r forward k steps,and then set r to null
C) assign the successor reference in the node with index k to the successor reference in the node with index k-1
D) decrement k by 1,and then use recursion
Q2) In a linked list,the successor of a node X
A) may not exist
B) is the node that comes after X,and it always exists
C) is the last node in the list
D) is the node whose index is one greater than the index of X
Q3) A list in which each stored element is associated with a reference to its successor is called
A) an array list
B) a map
C) a linked list
D) None of the above
To view all questions and flashcards with answers, click on the resource link above. Page 22
Chapter 21: Stacks and Queues
Available Study Resources on Quizplus for this Chatper
36 Verified Questions
36 Flashcards
Source URL: https://quizplus.com/quiz/72372
Sample Questions
Q1) The stack pop operation
A) removes all items currently on the stack
B) extracts one element from the stack and returns it
C) removes from the stack the number of elements specified by its integer parameter
D) does not exist: There is no such stack operation
Q2) In an implementation of a stack based on a singly-linked list,it is most efficient to add a new item so that
A) the new item has the highest index of all items in the list
B) the new item has the lowest index of all items in the list
C) the new item is not duplicated by any other item already in the stack
D) the items in the stack stay sorted in ascending order
Q3) In a list implementation of a stack,the end of the list at which elements are added and removed is called
A) the active end of the stack
B) the head of the stack
C) the top of the stack
D) the bottom of the stack
To view all questions and flashcards with answers, click on the resource link above.

23
Chapter 22: Binary Trees, Avl Trees, and Priority Queues
Available Study Resources on Quizplus for this Chatper
45 Verified Questions
45 Flashcards
Source URL: https://quizplus.com/quiz/72373
Sample Questions
Q1) Binary trees have been used
A) in compilers and interpreters to represent expressions
B) in computer hardware to model branching patterns of electronic signals
C) in the Java Collections Framework to internally implement the Vector class
D) None of the above
Q2) Consider the operation of deleting the root of a binary search tree.If the root is a leaf,then
A) the method doing the deletion should throw an exception
B) the root should be replaced with a dummy place-holder node
C) the reference to the root of the tree should be set to null
D) the element stored in the root node should be replaced with null,or with 0.
Q3) A ternary tree is like a binary tree,except each node may have up to three successors.Write a TNode class that can be used to represent a ternary tree.Define a notion of preorder and postorder traversal for ternary trees,and write methods void postorder(TNode tree)and void preorder(TNode tree)that implements your notion of those traversals.
To view all questions and flashcards with answers, click on the resource link above.

Page 24