Computer Science 201: Detailed Study of Data Structures & Algorithms - Chapter 3

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/44

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 11:25 PM on 8/10/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

45 Terms

1
New cards

How many dimensions does the following array have?

float[][][] complexCube;

3

2
New cards

What is the most common type of loop used to step through an array?

For

3
New cards

What type of an array is this?

chat[] enterCustomerName;

Character

4
New cards

A Java array that would have rows and columns is called a _____ array?

Two-dimensional

5
New cards

Which of the following is the correct way to declare and fill an int array?

int[] gameScores = {3, 4, 8, 9};

6
New cards

What does the binarySearch method allow us to do?

Use both the number and the index we're looking for

Find a sub-array with the results of your search

Use only the number we're looking for in the array

Find the position of the item we're looking for in the array

Find the position of the item we're looking for in the array

7
New cards

Which is the Java library that will help you access more tools to manipulate and sort arrays?

java.list.Sort

java.util.Array

java.util.Arrays

java.list.Array

java.util.Arrays

8
New cards

How does Insertion-Sort work?

Going through the array twice to put each item in the correct order.

Finding if each item is in the right position of the array according to the criteria

Manually getting each item at the first position of the array, then pushing it or pulling it according to the criteria

Getting a pivot item and switching values between both ends and the pivot

Finding if each item is in the right position of the array according to the criteria

9
New cards

What is Range sorting?

It is a sorting algorithm more efficient than Insertion-Sort.

It is a way to call the sorting method when you are using different data types.

It is used when you need to sort an array according to mathematical criteria.

It's used when you only need some part of an array sorted.

It's used when you only need some part of an array sorted.

10
New cards

If you use sorting methods contained in the Java library, do you have to code the sorting algorithm?

No, the library does all the sorting according to the set criteria

Yes, you have to specify the limits of the array and the size of it to the library methods

Yes, you have to manually specify the sorting procedure to the library

No, you don't have to do anything, the library will automatically identify arrays and will sort them.

No, the library does all the sorting according to the set criteria

11
New cards

Although we use the term multidimensional arrays, a multidimensional array is really an array of _____

Arrays

12
New cards

The number that references the row/column in a multidimensional array is called a(n) _____

Index

13
New cards

Which of these code samples correctly processes a 2-dimensional array?

https://study.com/cimages/multimages/16/java_2d_answer1.png

14
New cards

The following code declares a character array with 3 rows and 5 columns:

char [] [] matrix;

matrix = new char[3][5];

15
New cards

The following code correctly references the fourth row, fifth column, and seventh plane in a 3D array named matrix:

matrix[3][4][6];

16
New cards

The components of a linked list are most commonly referred to as _____

Nodes

17
New cards

Which of the following is the most appropriate example of a doubly linked list?

Browsing history

18
New cards

When compared to an array, why is a linked list less efficient?

You need to traverse each node.

19
New cards

In a singly linked list, the tail node points to what?

Null

20
New cards

In this type of linked list, the tail node points to the head node.

Circular linked

21
New cards

When an item is removed from a linked list, what happens to the other element references?

All indexes increase by one.

Element indexes are re-ordered.

The numbers are replaced by letters.

They keep their same numbering.

Element indexes are re-ordered.

22
New cards

In the following linked list (named m in your code), you need to change the Z to an S. Which code example accomplishes this?

[M, A, R, Z];

m.add("S");

m.set(3, "S");

m.addLast("S");

m.addFirst("S");

m.set(3, "S");

23
New cards

The following linked list, called j, exists in your program:

[J, U, P, I, T, E, R]

If you execute the following code, what will be the final value?

j.add(2, "CERES");

This will result in a compiler error.

[J, CERES, U, P, I, T, E, R]

[J, U, CERES, P, I, T, E, R]

[J, U, P, I, T, E, R, CERES]

[J, U, CERES, P, I, T, E, R]

24
New cards

When would it be most appropriate to create a linked list in Java?

Storing only a fixed number of elements.

Saving constant global variables.

Storing elements in a dynamic array.

Storing elements in descending order.

Storing elements in a dynamic array.

25
New cards

Which of the following correctly appends a new value specifically to the tail of the following linked list:

LinkedList l = new LinkedList();

l.add("M");

l.add("A");

l.add("R");

l.addLast("S");

l.replace("S");

l.remove("S");

l.addFirst("S");

l.addLast("S");

26
New cards

Why would an enhanced for loop not work with a circular linked list?

It is not defined in the Java utility

The nodes are not connected

It is not an array and so a loop is disallowed

Nodes are all connected, it would result in infinite loop

Nodes are all connected, it would result in infinite loop

27
New cards

When you add a new element to the tail of a circularly linked list, what is true of the current tail?

Its value is set to 0

It has no connections

It connects to the head

It is the first item

It connects to the head

28
New cards

If you need to remove an element from the tail of a circular linked list, what special step is needed?

Check to see if the head's next item is zero

Check to make sure the previous element is the tail

None, simply use an addToTail() method

Make sure the tail is really the last item

Make sure the tail is really the last item

29
New cards

What is the function of the following code?

tail = head;

head = head.next;

Rotating the list

Deleting the list

Nothing

Removing a node

Rotating the list

30
New cards

What will the list look like if the following code is run:

myList.addNodeToHead(75);

myList.addNodeToTail(100);

myList.addNodeToHead(50);

100, 75, 50

75, 100, 50

50, 75, 100

75, 50, 100

50, 75, 100

31
New cards

Which of the following is a practical example of a doubly linked list?

A game in which the player runs forward.

A quest in a game that lets users retry stages.

A first-in-first out scheduling system.

A browser cookie file.

A quest in a game that lets users retry stages.

32
New cards

If you had a Java class called myDll, how would you create a new doubly linked list instance?

myDll dll = new myDll();

myDll = new Node();

new Node = myDll

this.node = new myDll();

myDll dll = new myDll();

33
New cards

Which of the following Java code snippets correctly checks whether a given Node 'm' is at the end of a linked list?

if(m.next == null)

while(m != null)

while(m.end == null)

if(m.prev == null)

if(m.next == null)

34
New cards

Which of the following correctly checks to see if the current node is the head of a doubly linked list?

Node myNode = new Node(element);

if(myNode == null) {

}

Node myNode = new Node(element);

if(myNode.next == null) {

}

Node myNode = new Node(element);

if(myNode.prev == null) {

}

Node myNode = new Node(element);

if(myNode.next == tail) {

}

Node myNode = new Node(element);

if(myNode.prev == null) {

}

35
New cards

What is the purpose of the following Java code in context of a doubly-linked list?

Node myNode = new Node(element);

Node end = head;

while(end.next != null) {

// Perform some operation or update on the current node

System.out.println(end.data);

// Example: Print the data of the current node

// Move to the next node

end = end.next;

}

Looping until the last node is found.

This code will result in an error.

Looping to find the first node of the list.

Rotating the head and the tail.

Looping until the last node is found.

36
New cards

Which of the following is TRUE about the comparison of two objects of the same parent class for equivalency on which one of the objects overrides a parent class method

The two objects are not equal because the overriding method introduced replaces the initial parent class method

37
New cards

What is the result of executing the program shown?

import java.util.Arrays;

public class Main {

public static void main(String args) {

String classList = {"John", "Jean","James"};

String graduatesList = {"John", "Jean", "James"};

if(Array.equals(classList, graduatesList)) {

System.out.println("All the students in this class are graduating");

} else {

System.out.println("Some of the students are not graduating.");

}

}

}

It throws an error on the line where the 2 arrays are being compared because the s is missing on Array.equals

38
New cards

Which of the following would lead to two arrays with the same set of values not being equivalent when compared using the Arrays.equals() method?

When one or more elements in the second array is of a different data type to corresponding element(s) in the first array

39
New cards

What is the result of executing the code shown below?

import java.util.Arrays;

public class Main {

public static void main(String args) {

String student1 = {"John", "Doe", "Jane"};

String student2 = {"John", "Doe", "Jane"};

Object objectArray1 = {student1};

Object objectArray2 = {student2};

if(Arrays.equals(objectArray1, objectArray2)) {

System.out.println("Same Students List");

} else {

System.out.println("Different Students List");

}

}

}

It prints 'Different Students List'

40
New cards

Which of the following is TRUE about checking if two arrays of the same set of elements are equivalent using the comparison operator (==) ?

The two arrays are references to 2 different objects in memory hence not equivalent

41
New cards

In Java, a _____ copy would create a new array that references to all the values of the other.

empty

null

deep

shallow

shallow

42
New cards

Which of the following Java statements will make a clone of an array?

oldRates.arraycopy() = new rates[]

double[] rates = new oldRates[].clone();

double[] rates = oldRates.clone();

double[] rates = oldRates.arraycopy();

double[] rates = oldRates.clone();

43
New cards

If you only want to clone a portion of an array in Java, which method do you use?

copyto

clone

cloneArray

arraycopy

arraycopy

44
New cards

Why is cloning multi-dimensional arrays in Java not available using the clone method?

A Java multi-dimensional array is an array of primitives

Java doesn't support pointers

A Java multi-dimensional array is an array of objects

Only the copyArray or arraycopy methods work in Java

A Java multi-dimensional array is an array of objects

45
New cards

If a program needed to create a copy of an array with new references to an object, what type of copy would be performed?

Deep copy

Empty copy

Shallow copy

Narrow copy

Deep copy