Data Structures and Algorithms Flashcards
A _________________ cannot directly access variables in the outer class. It needs to refer to an ____________ of the outer class.
nested static class, instance
A _____________ is actually defined WITHIN a method (as opposed to the class). It’s not a class within a class, but a class within a ____________.
local class, method
In nested classes, the variable in the nested/inner class ______________ the value from the outer class.
shadows
A nested __________ class cannot directly access variables in the outer class.
static
The ________ is a chain of connected elements. Each element in the list is called a __________. While the type of connection may vary, the core structure consists of elements that point to each other. The first element in the list is the ______, and the last element is the _______
linked list, node, head, tail
A _________________ is like a train, with nodes pointing forward.
singly linked list
A _______________ resembles web browsing history, with nodes pointing forward and backward so that all are connected both ways.
doubly linked list
A ___________________ is a variation of a singly linked list, and the tail node points back to the head
circular linked list
Unlike arrays, a _______________ has non-continuous memory, and it requires you to step through each node to find a given node.
linked list
When compared to an array, why is a linked list less efficient?
You need to traverse each node.
In this type of linked list, the tail node points to the head node.
circular linked
In a singly linked list, the tail node points to what?
Null
How does your browsing history demonstrate a doubly linked list?
You can traverse the list forwards and backwards.
The reason that the == does not work is because arrays are _________ in Java, and so the compiler is comparing their __________ in memory, NOT the values that you gave them.
objects, address
You can use == for _______________ like integers, but not objects, such as arrays.
primitive variables
Are two arrays of the same set of elements equivalent using the comparison operator (==) ?
The two arrays are references to 2 different objects in memory hence not equivalent
What happens when you compare two objects of the same parent class for equivalency on which one of the objects overrides a parent class method? Are the objects equivalent?
The two objects are not equal because the overriding method introduced replaces the initial parent class method
A ____________ of an array only creates a copy of an array (or parts of an array) for primitive data types.
shallow copy
A ______________ creates a copy of an array of objects while still creating new references to objects underneath.
deep copy
The _____________ method lets you copy part of an array or an entire array.
arraycopy
A _________ creates a mirror image of the array.
clone
In Java, a _____ copy would copy only the double data types of an array.
shallow
Clone the oldRates array and name it rates, double data type.
double[] rates = oldRates.clone();
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
If you only want to clone a portion of an array in Java, which method do you use?
arraycopy
Why is cloning multi-dimensional arrays in Java not available using the clone method?
A Java multi-dimensional array is an array of objects
Contra attack
The use of contrapositive and contradiction methods in order to justify a given statement.
Induction
One of the most important tools for analyzing algorithms. It involves proving mathematical statements true with a finite set of elements.
Loop variants
Analyzing the correctness of an algorithm consisting of loops with conditions that both hold true immediately before and immediately after every iteration of the
This can be defined as the function which determines the amount of time an algorithm takes to give the desired output.
Time complexity
This function describes the total memory space consumed upon running an algorithm.
Space complexity
Consumption of space depends on these three things:
1: type of data structures
2: the memory allocations completed for the variables used
3: the results stored after execution
data structure