Find popular element in an array

Given a sorted array of integers, find a “popular” element i.e. one which occurs more than n/4 times. If no such element exist (which occurs more […]

Increment a number given in the form of linked list

Given a large number represented in the form of a linked list, Write code to increment the number in-place. For example:

Rearrange array into alternate positive and negative numbers

Given an array containing both positive and negative integers, write code to rearrange the elements so that positive and negative numbers comes alternately. If positive […]

Fix loop in a sorted linked list

Given a Sorted linked list which has a loop (link pointer of last node is not NULL and points to some other node). Fix the […]

Compute x^n (x to the power n)

Write a C function to compute xn which uses minimum number of multiplications. unsigned int power(double x, unsigned int n)

Implement Stack using two Queues

We have seen the code to implement a Queue using two stacks. This question is opposite of that. Use only Queue data structure to implement […]

Implementing a Queue using two Stacks

We have seen how to implement Queue using a linked list and using Array as the base data structure.  The question here is that given […]

Array implementation of Queue data structure

To learn the basics of the Queue visit our previous post on implementing Queue using linked list. In case the Queue is implemented using Linked […]

Singly linked list implementation of Queue

In a general Queue (at any office or bank or any other place), people join the queue at the end and are removed from the […]

Inserting in a linked list

Given a Singly linked list. Write functions to insert at different positions in the list: At start of the linked list. At end of the […]