Articles for author: Namanjeet Singh

Hamiltonian Cycle

What is Hamiltonian Cycle? Hamiltonian Cycle or Circuit is a path in an undirected graph that visits all the vertices in the graph exactly once and terminates back at the starting node. Problem Statement Given an undirected graph, our task is to determine whether the graph contains a Hamiltonian cycle or not. Example Explanation In the above example, ...

Trailing Zeros in Factorial

Problem Statement Given an integer n, our task is to write a function that returns the count of trailing zeros in n!. Here n! is the factorial of a number n which is the product of all numbers in the range $[1, n]$. Example : Explanation Example – 1 :When $n = 3$, Factorial of ...

Sort an Array of 0s 1s and 2s

Problem Statement We are given an array consisting of only 0s, 1s, and 2s. Our task is to write a program to sort the given array without using inbuilt functions. Example Example Explanation Since we already know that an array is a linear data structure that contains data elements of the same data type at ...

Activity Selection Problem

We are given N activities with their start time and finish time. Our task is to find the maximum number of non-conflicting activities that can be performed within a given time assuming that only a single activity can be performed at a time. Scope In this article we are looking upon Activity selection problem. In ...

Difference Between Array and Linked List

Arrays and Linked Lists are linear data structures that store data in memory. An array stores data elements in contiguous memory locations, thus allowing faster access using array indexes. In contrast, a Linked list contains a sequence of data elements where each element is linked to its next element with the help of pointers. In this article, we ...