* Tight coupling: If one class is strongly interrelated to another class, it is said to have a tight coupling with that class.
#Source_code
#OOP_Concepts_java
#coupling_in_java
#119
#Source_code
#OOP_Concepts_java
#coupling_in_java
#119
* Loose coupling: If one class is weakly interrelated to another class ,it is said to have loose coupling with that class. Loose coupling is preferred over tight coupling. A class can achieve this with the help of interfaces, as shows.
#Source_code
#OOP_Concepts_java
#coupling_in_java
#120
#Source_code
#OOP_Concepts_java
#coupling_in_java
#120
* Low Cohesion: In the following code, we have a class called Book. But it is less cohesive because it comprises less focussed and independent attributes and methods to the class. This class should contain information related to the Book. Therefore, the person's name and age method are making this classless cohesive.
#Source_code
#Cohesion_In_Java
#Low_Cohesion
#OOP_Concepts_java
#121
#Source_code
#Cohesion_In_Java
#Low_Cohesion
#OOP_Concepts_java
#121
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