code.png
410.4 KB
Association is relation between two separate classes that establishes with the help of their Object.
#Source_code
#OOP_Concepts_java
#Association_in_java
#123
#Source_code
#OOP_Concepts_java
#Association_in_java
#123
A method that has the static keyword in the declaration is known as the static method. In other words, a method that belongs to a class rather than an instance of a class is known as a static method. We can also create a static method by using the keyword static before the method name. The main benefit of a static method is that we can invoke the static method without even creating an object. It can access static data members and also change their values and is also used to create an instance method. The main() method is a common example of the static method.
#Source_code
#OOP_Concepts_java
#Static_method_in_java
#126
#Source_code
#OOP_Concepts_java
#Static_method_in_java
#126
A method that is declared final is called a final method. We cannot override a final method. This means the child class can still call the final method of the parent class without any problem, but it cannot override it. This is because the main purpose of making a method final is to stop the modification of the method by the sub-class.
#Source_code
#OOP_Concepts_java
#Final_Method_in_java
#128
#Source_code
#OOP_Concepts_java
#Final_Method_in_java
#128
Java
A method that is declared final is called a final method. We cannot override a final method. This means the child class can still call the final method of the parent class without any problem, but it cannot override it. This is because the main purpose of…
Instead of modifying the method, we can use it as shown:
#Source_code
#OOP_Concepts_java
#Final_Method_in_java
#129
#Source_code
#OOP_Concepts_java
#Final_Method_in_java
#129
code.png
1.5 MB
Magnet Puzzle
We are given a set of bipolar magnets, each domo-shaped. The objective is to place magnet on an M * N board, which satisfies a set of conditions where both M and N are not odd.
The time complexity of the above solution is exponential and requires additional space for the recursion (call stack)
#Source_code
#Data_Structures
#Magnet_Puzzle
#130
We are given a set of bipolar magnets, each domo-shaped. The objective is to place magnet on an M * N board, which satisfies a set of conditions where both M and N are not odd.
The time complexity of the above solution is exponential and requires additional space for the recursion (call stack)
#Source_code
#Data_Structures
#Magnet_Puzzle
#130
code.png
563.2 KB
Quickselect Algorithm
Quickselect is a selection algorithm to find the k'th smallest element in an unordered list. It is closely related to the Quicksort sorting algorithm. Like Quicksort, it is efficient traditionally and offers good average-case performance, but has a poor worst-case performance.
#Source_code
#Quickselect_Algorithm
#131
Quickselect is a selection algorithm to find the k'th smallest element in an unordered list. It is closely related to the Quicksort sorting algorithm. Like Quicksort, it is efficient traditionally and offers good average-case performance, but has a poor worst-case performance.
#Source_code
#Quickselect_Algorithm
#131
Find the missing term in a sequence in logarithmic time
Given the missing term in a sequence in logarithmic time
#Source_code
#Data_structure
#132
Given the missing term in a sequence in logarithmic time
#Source_code
#Data_structure
#132
code.png
2 MB
Huffman Coding Compression Algorithm
Huffman coding (also known as Huffman Encoding) is an algorithm for doing data compression, and it forms the basic idea behind file compression. This post talks about the fixed-length and variable length encoding, uniquely decodable codes, prefix rules, and Huffman Tree construction.
#Data_Strucutre
#Source_code
#133
Huffman coding (also known as Huffman Encoding) is an algorithm for doing data compression, and it forms the basic idea behind file compression. This post talks about the fixed-length and variable length encoding, uniquely decodable codes, prefix rules, and Huffman Tree construction.
#Data_Strucutre
#Source_code
#133
code.png
479.9 KB
When looking for a place to insert a new key, traverse the tree from root-to-leaf, making comparisons to keys stored in the tree’s nodes and deciding based on the comparison to continue searching in the left or right subtrees. In other words, we examine the root and recursively insert the new node to the left subtree if its key is less than that of the root or the right subtree if its key is greater than or equal to the root.
#Source_code
#Data_structure
#Recursion_Version
#135
#Source_code
#Data_structure
#Recursion_Version
#135
code.png
679.7 KB
Activity Selection Problem
Activity Selection Problem: Given a set of activities, along with the starting and finishing time of each activity, find the maximum number of activities performed by a single person assuming that a person can only work on a single activity at a time.
#Source_code
#Data_Structure
#136
Activity Selection Problem: Given a set of activities, along with the starting and finishing time of each activity, find the maximum number of activities performed by a single person assuming that a person can only work on a single activity at a time.
#Source_code
#Data_Structure
#136
Given a set of positive integers S, partition set S into two subsets, S1 and S2, such that the difference between the sum of elements in S1 and S2 is minimized. The solution should return the minimum absolute difference between the sum of elements of two partitions.
#Source_code
#Minimum_Sum_Partition_problem
#Data_structure
#137
#Source_code
#Minimum_Sum_Partition_problem
#Data_structure
#137