## Next greater element in array

Write a c++ code to print next greater element for every element. Time Complexity of Brute for solution would be O(n^2). Example Input 12 15 22 9 7 2...

## Cocktail sort algorithm

Cocktail sort is a comparison and exchange based sorting algorithm. It is also known as bidirectional sort algorithm. The Cocktail sort algorithm works same as bubble sort , it...

## comb sort in c

Comb sort is a comparison and exchange based sorting algorithm and an extension to bubble sort algorithm. In bubble sort “Bubble sort is sorting algorithm in which 0th element...

## Shell sort algorithm implementation in C

Shell Sort algorithm Shell sort is in-place comparison based sorting algorithm. it is also known as diminishing incremental sort. It is based on insertion sort algorithm which improves the time complexity...

## Reverse a Linked List using Recursion in C

Interview Question on link list Write a recessive function to reverse a singly linked list in c? some time interviewer at beginning level can ask this type of question to test...

## C/C++ program for Z algorithm string matching

Z Algorithm Z algorithm is a linear time string matching algorithm which runs in O(n) complexity. Many programmers are still not aware this algorithm. It is used to find all occurrence...

## string matching z algorithm

string matching problem Given a pattern P find all occurrence of P in text T. For example if P = “aba ” and T = “bbabayababay’ ,then P occurs in...

## Maximum subarray problem

Maximum subarray problem is to find the largest contiguous sub-array which has largest sum total. For example in array {-1,-2,3,4} the largest contiguous array which has largest sum is...

## longest palindromic substring

Longest palindrome sub-string problem is famous for software programmers specially for interview purpose. you can be questioned to write a function that returns the longest palindrome in a given string. A palindrome...

## Disjoint-set data structure c++ implementation

Disjoint-set data structure is very useful data structure which keeps track of collection of items and its set, i.e which item belongs to which set. it is also called...