Kruskal’s Algorithm in Kotlin

Kruskal’s Algorithm is a greedy algorithm used to find the minimum spanning tree of a weighted undirected graph. It works by sorting the edges of the graph in increasing order of weight and adding them to the tree one by one, provided that the edge does not create a cycle in the tree. The algorithm … Read more

Prim’s Algorithm in Kotlin MST

Prim’s Algorithm is a greedy algorithm used to find the minimum spanning tree of a weighted undirected graph. It starts by selecting a random vertex from the graph and repeatedly adding the closest vertex that has not yet been added to the tree. The algorithm maintains a priority queue of edges with their weights and … Read more

DFS in Kotlin. Depth First Search

DFS stands for Depth-First Search. It is a graph traversal algorithm that starts at a given source vertex and explores as far as possible along each branch before backtracking. In other words, it explores the vertices of a graph in depth-first order until there are no more vertices left to explore. To implement DFS, we … Read more

Doubly Linked List in Kotlin

A doubly linked list is a type of linked list in which each node has a reference to both the previous and next nodes in the list, unlike singly linked lists that only have a reference to the next node. This additional reference allows for efficient traversal of the list in both forward and backward … Read more

Circular Linked List in Kotlin

A circular linked list is a data structure in which the nodes form a circular sequence, where each node points to the next node, and the last node points back to the first node. In this implementation, we define a Node class to represent each node in the linked list, and a CircularLinkedList class to … Read more

BFS in Kotlin. Breath First Search

In this implementation, we define a Graph class that stores the graph as an adjacency list. The addEdge method adds an undirected edge between two vertices. The bfs method performs BFS starting from the given startVertex. We maintain a visited array to keep track of which vertices we have visited, and a queue to store … Read more

Binary Search Tree in Kotlin

A binary search tree (BST) is a data structure that is commonly used in computer science for efficient searching, insertion, and deletion operations. A BST is a binary tree where each node has at most two child nodes, and the left child is less than the parent node, and the right child is greater than … Read more