0% found this document useful (0 votes)
5 views

Notes

Uploaded by

Sc
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Notes

Uploaded by

Sc
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Searching & Sorting:  Removing elements: linkList.

remove
(element); (removes first instance of element) or
 Linear Search: Checks sequentially to find an linkList.remove (int index);
element. O(n)
 Binary Search: Searches a sorted array by splitting Stacks:
it around the center and continuing to split around  Stores elements in a vertical stack.
the subarray that contains the element. O(logn)  Push: Adds an element to the top.
 Selection Sort: Finds the minimum element in the  Pop: Removes the element on the top.
array and places it at the beginning. Inefficient on  Peek: Returns the element on the top.
large lists. O(n2)  Size: Returns the number of elements in the Stack.
 Insertion Sort: Goes from the second element to n,
comparing them to the element before them. If they Queues:
are smaller, compare them to the next element  Ordered list of elements with first in first out
before them, finishing when the element is bigger  Enqueue: Adds an element at the back. (add)
than the one before. Less efficient on large lists.  Dequeue: Removes the front element. (remove)
O(n2)  First: Returns the element at the front.
 Quick Sort: Picks a pivot (first element, last  IsEmpty: Returns if the Queue is empty.
element, random element, or median). Splits the
array around that element, lower in one, higher in Trees:
another and continues to do that to each split array  Binary Tree: Data structure where each element
until sorted in relation to the pivots. O(nlogn) has up to two child elements.
 Merge Sort: Splits the array around the center and  Binary Search Tree: Binary Tree where the left
then splits each array again until they have only one child element is lesser than the element and the
element than merges them back together sorted. right is greater. Each child element is also a binary
O(nlogn) search tree.
 Heap Sort: Sorts the array into a binary tree and
then reorders the binary tree to where the child Traversals:
nodes are lesser than all parent nodes. O(nlogn)
 Inorder: Leftmost child, root, right
Big-O notation:  Preorder: Root, left, right
 Postorder: Leftmost child, right, root
 Describes the performance of an algorithm and its
complexity. GUI:

Recursion:
 Breaking operations down into a version that calls
itself to continuously perform the operation until the
base case.
Linked lists:
 A linear collection of elements that are accessed
sequentially.
 Initializing: LinkedList<datatype> linkList =  Panes:
new LinkedList<datatype>();
o Pane: Base class for layout panes. It
 Adding elements: linkList.add(element); or
linkList.add(int index, element); contains the getChildren() method for
 Changing elements: linkList.set(int index, returning a list of nodes in the pane.
element); o StackPane: Places nodes on top of each
other in the center in the same space.
o FlowPane: Places the nodes in columns or  Have abstract methods and can only
rows. have constants and implemented
o GridPane: Places the nodes in cells in a methods.
grid.  Other classes extend the abstract
o BorderPane: Places the nodes in the top, class.
right, bottom, left, and center areas. o Interfaces:
o HBox: Places the nodes in a horizontal row.  Have only abstract methods or
o VBox: Places the nodes in a vertical constants.
column.  Other classes implement the
 Nodes: interface
Comparable Interface:
 Part of the Java.lang package
 Contains compareTo() method that allows the
class’s instantiated objects to be compared in a way
that the programmer wishes.
 Public int compareTo(Object obj):
o Used to compare the current object with the
o ComboBox: Select from drop-down list of
specified object.
options. o Returns:
Final ComboBox comboBox = new
ComboBox();  Positive int if the object is greater.
comboBox.getItems().addAll(“ItemOne  Negative int if the object is lesser.
”,“ItemTwo”,“ItemThree”);  Zero if the object is equal.
comboBox.setValue(“ItemOne”);
 Event Handling: Iterator:
o Events are objects created when there is  An interior interface can be implemented to create
change in the GUI like a signal indicating an iterator to parse through a linked list.
change.  Iterator interface must implement the hasNext(),
o Component that generated event is the next(), and remove() methods.
source object.
Event.getSource(); Polymorphism:
o Event handlers determine how the event is
 Same method with same signature (same
processed. parameters and method name) but performs
button1.setOnAction(new
ButtonHandler()); different actions as redefined by a class.
o Override inherited methods from parent or
Nested Classes: abstract class or implemented method from
 Nested classes are classes within classes. interface.
 Typically, the nested class is private and only used Exception Handling:
within the outer class.
 Usually used for Event Handlers.  Try-catch blocks are used to catch exceptions
created in the try block.
Interfaces, Abstract Classes, and Inherited Classes: o The catch blocks can catch specific
 Interface is a collection of abstract methods and exceptions or general exceptions.
constants. o Exceptions should be caught and processed
 Classes can implement multiple interfaces. by the program otherwise the program will
 Abstract vs Interfaces: terminate and produce an error message.
o Abstract Classes:  Exceptions can also be caught using the throws
clause which is included in the method header.
 Try catch blocks the process the caught exception
within the method while the throws clause throws
the exception elsewhere to be processed.

You might also like