Showing posts with label Algorithm. Show all posts
Showing posts with label Algorithm. Show all posts
Maximum Number of Points in a Line
Resources:
wikipedia.org ==>> Collinearity
GFG
How To Determine If Points Are Collinear In Coordinate Geometry?
Collinear
Maximum Number of Points in a Line
Implementation basis Spoj & Codechef problem:
A* search algorithm
Resources:
wikipedia.org ==> A*_search_algorithm
hackerearth blog
GFG
stanford.edu
hackerrank Problems
implementation from Youtube Video:
Expression parsing
Resources:
Cp_Algorothm
Problem Link:
1309 - Children`s Math
1324 - Equivalent Boolean Expressions
Implementation:
Longest Increasing Subsequence (LIS)
Resource:
Longest Increasing Subsequence (GFG)
LIS and variation
ডাইনামিক প্রোগ্রামিং এ হাতেখড়ি-৪
Problem:
990 - Diving for Gold
1501. Sense of Beauty
1167. Bicolored Horses
231 - Testing the CATCHER
10926 - How Many Dependencies?
10000 - Longest Paths
XMEN SOLUTTION
10635 - Prince and Princess
1277 - Looking for a Subsequence SOLUTION
Code:
Topological Sorting
Resource Link
Topological Sorting (E-Maxx)
Kahn’s algorithm for Topological Sorting
Topological Sorting
TopSort using DFS:
TopSort using BFS: (Kahn’s algorithm)
F1. Tree Cutting (Easy Version
F1. Tree Cutting (Easy Version)
Topic: DFS
Concept: প্রতিটা প্যারেন্ট এর চাইল্ড কোন কোন কালার আছে তার হিসাব রাখবো, যেমন প্রথম উদাহরনে -
১ নং নোডের চাইল্ড এর সংখ্যা হবে ১টা লাল, ২টা নীল , ১টা নরমাল।
২ নং নোডের চাইল্ড এর সংখ্যা হবে ১টা লাল, ১টা নীল , ২টা নরমাল।
৩ নং এর ১টা নরমাল (নিজের কালার)।
৪ নং নোডের চাইল্ড এর সংখ্যা হবে ১টা লাল ( এইটা বাদ দিয়ে এন্সার পাব)।
৫ নং নোডের চাইল্ড এর সংখ্যা হবে 1টা নীল।
Solution 01:
Bucket Sort
Bucket Sort
geeksforgeeks
hackerearth
visualization
Time Complexity: If we assume that insertion in a bucket takes O(1) time then steps 1 and 2 of the above algorithm clearly take O(n) time. The O(1) is easily possible if we use a linked list to represent a bucket (In the following code, C++ vector is used for simplicity). Step 4 also takes O(n) time as there will be n items in all buckets.
Heap Sort
Heap Sort
Time Complexity: Time complexity of heapify is O(nLogn). Time complexity of createAndBuildHeap() is O(n) and overall time complexity of Heap Sort is O(nLogn).