Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
76 views6 pages

CSE 205 - Quick Notes

The document discusses various searching and sorting algorithms like linear search, binary search, selection sort, insertion sort, quick sort, merge sort, and heap sort. It also covers big O notation, recursion, linked lists, stacks, queues, binary trees, GUI components like panes and nodes, nested classes, interfaces, polymorphism, and exception handling.

Uploaded by

Sc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views6 pages

CSE 205 - Quick Notes

The document discusses various searching and sorting algorithms like linear search, binary search, selection sort, insertion sort, quick sort, merge sort, and heap sort. It also covers big O notation, recursion, linked lists, stacks, queues, binary trees, GUI components like panes and nodes, nested classes, interfaces, polymorphism, and exception handling.

Uploaded by

Sc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Searching & Sorting:

⦁ Linear Search: Checks sequentially to find an element. O(n)

⦁ Binary Search: Searches a sorted array by splitting it around the center and
continuing to split around the subarray that contains the element. O(logn)

⦁ Selection Sort: Finds the minimum element in the array and places it at the
beginning. Inefficient on large lists. O(n2)

⦁ Insertion Sort: Goes from the second element to n, comparing them to the
element before them. If they are smaller, compare them to the next element before
them, finishing when the element is bigger than the one before. Less efficient on
large lists. O(n2)

⦁ Quick Sort: Picks a pivot (first element, last element, random element, or
median). Splits the array around that element, lower in one, higher in another and
continues to do that to each split array until sorted in relation to the pivots.
O(nlogn)

⦁ Merge Sort: Splits the array around the center and then splits each array again
until they have only one element than merges them back together sorted. O(nlogn)

⦁ Heap Sort: Sorts the array into a binary tree and then reorders the binary tree to
where the child nodes are lesser than all parent nodes. O(nlogn)

Big-O notation:

⦁ Describes the performance of an algorithm and its complexity.

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 = new LinkedList<datatype>


();

⦁ Adding elements: linkList.add(element); or linkList.add(int index,


element);

1
⦁ Changing elements: linkList.set(int index, element);

⦁ Removing elements: linkList.remove (element); (removes first instance of


element) or linkList.remove (int index);

Stacks:

⦁ Stores elements in a vertical stack.

⦁ Push: Adds an element to the top.

⦁ Pop: Removes the element on the top.

⦁ Peek: Returns the element on the top.

⦁ Size: Returns the number of elements in the Stack.

Queues:

⦁ Ordered list of elements with first in first out

⦁ Enqueue: Adds an element at the back. (add)

⦁ Dequeue: Removes the front element. (remove)

⦁ First: Returns the element at the front.

⦁ IsEmpty: Returns if the Queue is empty.

Trees:

⦁ Binary Tree: Data structure where each element has up to two child elements.

⦁ Binary Search Tree: Binary Tree where the left child element is lesser than the
element and the right is greater. Each child element is also a binary search tree.

Traversals:

⦁ Inorder: Leftmost child, root, right

⦁ Preorder: Root, left, right

⦁ Postorder: Leftmost child, right, root

GUI:

2
⦁ Panes:

⦁ Pane: Base class for layout panes. It contains the getChildren() method
for returning a list of nodes in the pane.

⦁ StackPane: Places nodes on top of each other in the center in the same
space.

⦁ FlowPane: Places the nodes in columns or rows.

⦁ GridPane: Places the nodes in cells in a grid.

⦁ BorderPane: Places the nodes in the top, right, bottom, left, and center
areas.

⦁ HBox: Places the nodes in a horizontal row.

⦁ VBox: Places the nodes in a vertical column.

⦁ Nodes:

⦁ ComboBox: Select from drop-down list of options.


Final ComboBox comboBox = new ComboBox();

3
comboBox.getItems().addAll(“ItemOne”,“ItemTwo”,“ItemThree”);

comboBox.setValue(“ItemOne”);

⦁ Event Handling:

⦁ Events are objects created when there is change in the GUI like a signal
indicating change.

⦁ Component that generated event is the source object.


Event.getSource();

⦁ Event handlers determine how the event is processed.


button1.setOnAction(new ButtonHandler());

Nested Classes:

⦁ Nested classes are classes within classes.

⦁ Typically, the nested class is private and only used within the outer class.

⦁ Usually used for Event Handlers.

Interfaces, Abstract Classes, and Inherited Classes:

⦁ Interface is a collection of abstract methods and constants.

⦁ Classes can implement multiple interfaces.

⦁ Abstract vs Interfaces:

⦁ Abstract Classes:

⦁ Have abstract methods and can only have constants and


implemented methods.

⦁ Other classes extend the abstract class.

⦁ Interfaces:

⦁ Have only abstract methods or constants.

⦁ Other classes implement the interface

Comparable Interface:

4
⦁ 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):

⦁ Used to compare the current object with the specified object.

⦁ Returns:

⦁ Positive int if the object is greater.

⦁ Negative int if the object is lesser.

⦁ Zero if the object is equal.

Iterator:

⦁ An interior interface can be implemented to create an iterator to parse through a


linked list.

⦁ Iterator interface must implement the hasNext(), next(), and remove() methods.

Polymorphism:

⦁ Same method with same signature (same parameters and method name) but
performs different actions as redefined by a class.

⦁ Override inherited methods from parent or abstract class or implemented


method from interface.

Exception Handling:

⦁ Try-catch blocks are used to catch exceptions created in the try block.

⦁ The catch blocks can catch specific exceptions or general exceptions.

⦁ Exceptions should be caught and processed by the program otherwise the


program will terminate and produce an error message.

⦁ 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

5
throws clause throws the exception elsewhere to be processed.

You might also like