All Easy Articles

## Print list items containing all characters of a given word 2.2

There is a list of items. Given a specific word, e.g., “sun”, print out all the items in list which contain all the characters of… Read More »

## Data Structures and Algorithms | Set 22 2.6

Following questions have been asked in GATE CS 2005 exam. 1) A program P reads in 500 integers in the range [0..100] representing the scores… Read More »

## Split a Circular Linked List into two halves 2.2

Original Linked List Result Linked List 1 Result Linked List 2 If there are odd number of nodes, then first list should contain one extra.… Read More »

## Find whether a given number is a power of 4 or not 2.7

Given an integer n, find whether it is a power of 4 or not. Example : Input : 16 Output : 16 is a power… Read More »

## Reverse a Doubly Linked List 2.2

Write a C function to reverse a given Doubly Linked List See below diagrams for example. (a) Original Doubly Linked List (b) Reversed Doubly Linked… Read More »

## How to determine if a binary tree is height-balanced? 2.7

A tree where no leaf is much farther away from the root than any other leaf. Different balancing schemes allow different definitions of “much farther”… Read More »

## Data Structures and Algorithms | Set 18 2

Following questions have been asked in GATE CS 2006 exam. 1. Consider the polynomial p(x) = a0 + a1x + a2x^2 +a3x^3, where ai !=… Read More »

## gets() is risky to use! 2.3

Consider the below program. filter_none edit close play_arrow link brightness_4 code void read() {    char str[20];    gets(str);    printf(“%s”, str);    return; } chevron_right filter_none The code… Read More »

## Queue using Stacks 2.5

The problem is opposite of this post. We are given a stack data structure with push and pop operations, the task is to implement a… Read More »

## How does “void *” differ in C and C++? 2

C allows a void* pointer to be assigned to any pointer type without a cast, whereas C++ does not; this idiom appears often in C… Read More »

## Data Structures and Algorithms | Set 16 2

Following questions have been asked in GATE CS 2009 exam. 1. Consider a binary max-heap implemented using an array. Which one of the following array… Read More »

## C function to Swap strings 2.9

Let us consider the below program. filter_none edit close play_arrow link brightness_4 code #include<stdio.h> void swap(char *str1, char *str2) {   char *temp = str1;   str1… Read More »

## An Uncommon representation of array elements 2.3

Consider the below program. filter_none edit close play_arrow link brightness_4 code int main( ) {   int arr[2] = {0,1};   printf(“First Element = %d\n”,arr[0]);   getchar();   return… Read More »

## Output of C Programs | Set 13 2.1

Difficulty Level: Rookie Question 1 Predict the output of below program. filter_none edit close play_arrow link brightness_4 code int main() {   char arr[] = “geeksforgeeks”;… Read More »

## k largest(or smallest) elements in an array | added Min Heap method 2.8

Question: Write an efficient program for printing k largest elements in an array. Elements in array can be in any order. For example, if given… Read More »

## What is return type of getchar(), fgetc() and getc() ? 2.1

In C, return type of getchar(), fgetc() and getc() is int (not char). So it is recommended to assign the returned values of these functions… Read More »

## C Language | Set 5 2.8

Following questions have been asked in GATE CS 2008 exam. 1. What is printed by the following C program? filter_none edit close play_arrow link brightness_4… Read More »

## Maximum and minimum of an array using minimum number of comparisons 2.5

Write a C function to return minimum and maximum in an array. You program should make minimum number of comparisons. Recommended: Please solve it on… Read More »

## Check for Majority Element in a sorted array 2.3

Question: Write a C function to find if a given integer x appears more than n/2 times in a sorted array of n integers. Basically,… Read More »

## G-Fact 6 2.5

The C standard C99 allows inline functions and variable-length-arrays. So following functions are valid in C99 compliant compilers. Example for inline functions filter_none edit close… Read More »