# Data Structure

## C/C++ Program to add a node to an ascending order linked list

Write a program to add a node to an ascending order linked list in C/C++. In simple words, we need to insert data in a sorted linked list such that the linked list remains sorted even after the insertion of a new node. Example, If the current linked list is 9 -> 12 -> 14 …

## C/C++ Program to find factorial using stack

Write a program to find factorial using stack in c/c++. Example, Input: 5 Output: 120 For this tutorial, we will implement our own stack. If you are using C++ then you may use an inbuilt stack. Method 1 To calculate factorial without a stack, we use a variable and initialize it to 1. We then …

## Program to Print all the Root to Leaf Paths in the Binary Search Tree

Given a Binary Search Tree (BST), print all paths starting from root to leaf. Example, Input Output 20 -> 10 -> 520 -> 10 -> 1520 -> 30 -> 2520 -> 30 -> 35 Algorithm The question is very simple. If you look carefully at the output of the above example, you will notice that …

## Program to Reverse Stack Using Queue

Reverse Stack Using Queue. Pop stack and push all the elements to a queue. Then pop queue and push all the elements back to the stack.

## Student Management System using Linked List in C

In this article, we will implement student management system using linked list in c. Student structure First we create a structure to store student data. head is a global pointer of type Student which will point to the first node in the linked list. The advantage of declaring head global is we can directly use …

## Singly Linked List Program in C++ using class

In this article, we will be discussing Singly Linked List Program in C++ using class. A Singly Linked List is unidirectional. Each node stores the reference to the next node. Since we are not storing the address of the previous node, we cannot traverse back, making it unidirectional. The head pointer points to the first …

## Difference between Array and Linked List

The main difference between array and the linked list is that array occupies contiguous memory whereas linked list memory is scattered.

## Prefix To Infix

Prefix to Infix Conversion. Algorithm to convert Prefix to Infix. using Stack. Read Prefix Expression from right-to-left, in reverse order.

## Evaluation of Prefix Expressions (Polish Expressions)

Evaluation of Prefix Expression is faster than an Infix Expression. This is because Prefix Expression has no parenthesis or precedence rules.

## Reverse a Linked List in Group of Given size

Reverse the given Linked List is Group of given size K using recursion (recursively) and without recursion (iteratively).