PROGRAMS
A set of instructions that you give to a computer so that it will do a particular task is a program.
PATTERN
We use for and while loop to print various pattern.
METHODS
If a function is part of an instance of a class i.e. (Object) then it is called method else it is called function.
SEARCHING
A searching algorithm is a step-by-step procedure used to locate a specific element within a data structure, such as an array or a list. Searching algorithms play a crucial role in programming, as they enable efficient data retrieval and manipulation.
ARRAY
An array is a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created. After creation, its length is fixed.
SORTING
The process of arranging data elements in a specific order, such as ascending or descending, based on a set of criteria.
2D ARRAY
It includes rows and column there could be N-D array on the basis of recuriment. Memory/Address is not in contigious fashion 2D array divides individually in n number of 1D array based on number of rows. Size of 2D array is n*m
Example:- 1) To store marks of different subject of 50 Students
2) 3D Image Processing and 4D video processing
STRINGS
An object that represents a number of character values is called String. They are immutable can be mutable by StringBuilder and StringBuffer
OOPS
Object-oriented programming aims to implement real-world entities like Encapsulations, inheritance, Abstraction polymorphism in programming.
RECURSION:
Recursion is method to solve computational problem by dividing the problem and the solution of the problem is depend on the solution of smaller instances of the same problem.
Divide and Conquer
Merge sort and quick sort
Backtracking
It involves finding a solution incrementally by trying different options and undoing them if they lead to a dead end. Types:- 1)Decision 2) optimization 3)Enumeration
ArrayList
Linear data structure and java collection framework.
Array | ArrayList |
---|---|
Static Memory | Dynamic Memory |
Primitive Data can be store | Primitive Data can not be store |
Implementing MultiDimensionalarrayList ---> ArrayList<ArrayList<Integer>> mainlist =new ArrayList<>();
ArrayList<Integer> list1 =new ArrayList<>();
ArrayList<Integer> list2 =new ArrayList<>();
mainlist -> | list1 | list2 |
---|
🔗LINKED_LIST
Linear data structure and in which memory is dynamic.Contains node which is originally the object. Two parts of node:- data and next(reference variable).
🧱 STACK
Stack is a linear data structure that follows LIFO (Last In First Out) or FILO (First In Last Out).
Uses:- Valid Paranathesis,Max Area in Histogram
Operation | Time and Space Complexity |
---|---|
push() | O(1) |
pop() | O(1) |
peek() | O(1) |
isEmpty() | O(1) |
🧠Queue
A Queue is a linear data structure. The order is First In First Out (FIFO).
Types of Queues:-
1) Simple Queue
2) Circular Queue
3) Priority Queue
4) Dequeue
Uses:- TicketCounter,Job Schedulling
Disadvantage:- 1) Searching an element takes O(N) time.
2) The operations such as insertion and deletion of elements from the middle are time consuming.
3) Maximum size of a queue must be defined prior in case of array implementation.
LinkedLists Class | ArrayDequeue Class |
---|---|
Implements queue and list | Implements dequeue |
accessing specific index is possible in O(n) | accessing specific index is not possible |
allows null elements | Doesn't allows null elements |
More memory due to overhead storing of references | Memory Efficient |
Greedy Algorithm
Locally optimium choices at each stage and hope to achieve a global optimum.
1) Used for Optimization
2) No fixed rule
3) Sorting first
Pros:- Simple and easy ,Good Time Complexity
Disadvantage:- lots of time global optimum is not achieved.
🌳Binary Tree
A binary tree is a hierarchical data structure in which each node has at most two children, referred to as the left child and the right child.
Key Terminology:
1. Root: The topmost node in a tree.
2. Parent: A node that has one or more children.
3. Child: A node that has a parent.
4. Leaf: A node with no children.
5. Subtree: A tree consisting of a node and its descendants.