Quantcast
Browsing all 34 articles
Browse latest View live

Why do we need the copy and swap idiom in C++

Why do we need the copy and swap idiom in C++ ? But let me ask a question what is copy and swap idiom in c++ ?  Let us take an example to understand. #include <iostream> #include <string.h>...

View Article


Image may be NSFW.
Clik here to view.

c program to reverse linked list using recursion

Write a C program to reverse linked list using recursion. As we already know liked list data structure ,each node contains the data and address of next node. The last node contains data and NULL...

View Article


Image may be NSFW.
Clik here to view.

C program to count size of binary tree

Given a binary tree write a C program to count size of binary tree. For example the size of  binary tree is 4 in below binary tree. (3) / \ (5) (6) / (2) C program to count size of binary tree...

View Article

Image may be NSFW.
Clik here to view.

find kth smallest element in binary search tree

You are given a binary search tree. Write c or c++ program to find kth smallest element in it. For in  given bst the 3 is first smallest and 4 is 2nd smallest. Let us write a program to find 2nd...

View Article

Image may be NSFW.
Clik here to view.

merge two sorted linked lists in sorted order

Write a c program to merge two sorted linked lists in sorted order.  For example if one linked list is 1->2->3->null and other is 1->3->5->6->null then the output should be...

View Article


Image may be NSFW.
Clik here to view.

C program for longest substring without repeating characters

Write a C program for longest substring without repeating characters. For example if the string is “abcdabc” the longest substring without repeating is “abcd” of length 4. C program for longest...

View Article

Image may be NSFW.
Clik here to view.

Print all nodes of the same level from binary tree

Print all nodes of the same level from binary tree. For example the output for the below binary tree is 6,8,5,8,3. C++ Print all nodes of the same level from binary tree #include <iostream>...

View Article

Image may be NSFW.
Clik here to view.

Binary tree inorder traversal without recursion using stack

In this blog we are going to discuss how to implement binary tree inorder traversal without recursion using stack. #include <iostream> #include<stack> using namespace std; typedef struct l...

View Article


Image may be NSFW.
Clik here to view.

c program for range minimum query

In this blog post we are going to learn how to write c program for range minimum query. What is range minimum query? The range minimum query is a problem of finding minimum value in a given range. For...

View Article


Image may be NSFW.
Clik here to view.

How enum in c is different from enum in c++?

In this blog we will learn how enum in c is different from enum in c++. • In C enums are created as below #include<stdio.h> enum DAY { MON, TUE, WED, THU, FRI, SAT, SUN }; enum DAY day; int...

View Article

Use of typedef in defining structure In C programming

In this blog we we will learn “use of typedef in defining structure In C programming+”.  So let us write a very simple linked list data structure program without typedef and review the code....

View Article

interview questions on doubly linked list

Many times when we face an interview doubly link list questions comes. In this blog we will see some important doubly linked list interview questions. What is doubly linked list and where it is used?...

View Article

make binary search tree from array

Write a C program to make binary search tree from array. Given a array of positive integers like [3, 5, 2, 1, 4] the binary search tree would look like 3 / \ 1 4 / \ 2 5 The above binary search tree is...

View Article


How to reverse a const string in c++

In this blog we will learn How to reverse a const string in c++.  In normal case , i mean when string is not constant we can use standard c++ std::reverse() function. For example let us take an example...

View Article
Browsing all 34 articles
Browse latest View live