• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/28

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

28 Cards in this Set

  • Front
  • Back

Which data types are appropriate for which situations?

int: represent an unsigned 32-bit integer


short: useful for saving memory in large arrays


long: need a range of values wider than int's


byte: useful for saving memory in large arrays


float: saving memory in large arrays of floating points numbers


double: decimal values, never precise values


char: single 16-bit Unicode character


boolean: true/false situations

How do you declare a variable?

To declare a variable in Java, all that is needed is the data type followed by the variable name.

What are some control structures?

-switch


-if else


-boolean


-while


-do...while


-for loop

What are some decision structures?

if statement


else clause


switch(case) statement


logical AND


logical OR


logical NOT


Relation Precedence

How do ArrayLists differ from arrays?

-Once an array has been created, its length cannot be changed. An ArrayList is able to re-size itself depending upon capacity and load factor.

How do ArrayLists eliminate the complexity of dealing with arrays?

ArrayLists support dynamic resizing

What makes a method recursive?

A method becomes recursive when it calls itself.

When does recursion end?

When an error code is reached or when the recursion is purposefully ended

What is the potential for infinite recursion?

When a method has no way of ending; it endlessly calls itself with no way out.

How are Queues & Stacks different? How are they the same?

-The diff. between them is in removing. In a stack, we remove the item most recently added; in a queue, we remove the item the least recently added.




-Similarly, they are both a collection of elements, which can be stored and retrieved one at a time.

How do they store data? In what order?

Stack: Items that need to be stored are put on "top" of the stack. Items that need to be removed are also taken from the "top".




Queues: Items are stored on one end and items are deleted on the other end. (<---->)

How do Search Algorithms work?

An algorithm is a sequence of steps for accomplishing a task. An algorithm typically uses a number of steps proportional to the size of the input

Are Linear (sequential) or Binary searches faster?

Binary searches are faster.

What are some examples of sorting algorithsms?

bubbleSort, mergeSort, selectionSort, quickSort.

bubbleSort

mergeSort

Merge sort is a sorting algorithm that divides a list into two halves, recursively sorts each half, and then merges the sorted halves into a completely sorted list.

selectionSort

Selection sort is a sorting algorithm that treats the input as two parts, a sorted part and an unsorted part, and repeatedly selects the proper next value to move from the unsorted part to the end of the sorted part.

quickSort

Quicksort is a sorting algorithm that repeatedly partitions the input into low and high parts (each part unsorted), and then recursively sorts each of those parts. To partition the input, quicksort chooses a pivot to divide the data into low and high parts.

How do sorting algorithm's work?

Sorting is the process of converting a list of elements into ascending (or descending) order.

How do HashMaps work?

Objects are stored by calling put(key, value) method of HashMap and retrieved by calling get(key) method. When we call put method, hashcode() method of the key object is called so that hash function of the map can find a bucket location to store value object, which is actually an index of the internal array, known as the table. HashMap internally stores mapping in the form of Map.Entry object which contains both key and value object. When you want to retrieve the object, you call the get() method and again pass the key object.

How do you add things into HashMaps?


How do you take them out?

HashMap stores key-value pair (both key and value must be an Object).




In order to store a key-value (assume ref is the reference to a HashMap): ref.put(key, value);




In order to retrieve a value with a key (you can always cast the return value if you know what specified type it is):


Object value = ref.get(key);

How do HashMaps store data? In what order?

HashMap maintains a table of entries, with references to the associated keys and values, organized according to their hash code.


If you mutate a key, then the hash code will change, but the entry in HashMap is still placed in the hash table according to the original hash code.


That's why map.get(keyOriginal) will return null.

What are some ways you can iterate through a HashMaps values?

By checking various keys of the map

What are Binary Trees?

A data structure in which a record is linked to two successor records, usually referred to as the left branch when greater and the right when less than the previous record.

How do Binary Trees store data? In what order?

Binary trees are typically constructed by having a tree node structure which contains some data and references to its left child and its right child

What's the difference between a binary tree and a binary search tree?

A binary search tree is simply a ordered version of a binary tree.

What does a (binary tree) node look like? (Conceptually? In Java?)

O


/ \


/ \


O O


/ \


/ \


O O

What happens when you call the compareTo() method of an object?




What are the potential values or categories of values?