Write a program to delete a linked list. Given a linked list, we have to write a code to delete a linked list.
To delete a complete linked list, traverse all the nodes of a linked list and delete one by one.
Print Middle Element of a Linked List
How to Delete a Linked List
To delete a node one by one maintain two pointers. The first pointer points to head and the second pointer keeps the reference to next node. So when a node is free, you can assign the reference of next node using the second pointer.
What is insertion sort. How it’s different from Selection sort and Bubble sort. I discussed selection sort and bubble in my previous posts. In this post i’ll discuss another sorting algorithm insertion sort.
Write a program to print 1 to 100 numbers without using loop. Using loop, (for and while loop) we can easily solve this problem. Think for a moment how do we solve this problem without using loop. We can solve this problem using recursion.
Write a program to print triangle pattern of numbers and stars (*). In this program i’ll show how to create triangle pattern of numbers , stars (*) . These type of questions are very important in terms of interviews as well.
Write a C program to multiply two numbers without using * multiplication operator.
Given two numbers, both numbers are positive. Write a program to multiply two numbers without using * multiplication operator. Think for a moment how to solve this problem .
You can use multiple approaches to find the solution of a problem.
C Program to Multiply Two Numbers without using *
Write a c program to reverse a linked list using recursion. Given a singly linked list, we have to write a code to reverse a linked list using recursion. This question is very important in terms of interviews.
In my previous post, I have explained C program to reverse a singly linked list. In this post, We are going to write a code to reverse a linked list using recursion. If you are not familiar with the concept of recursion then check my previous tutorial on recursion vs iteration.
The time complexity to reverse a linked list using recursion is O(n).
Write a C program to print Fibonacci Series using recursion. Given an input number, we have to write a code to print Fibonacci series up to that number using Recursion.
This question is very important in terms of technical interviews.
You can check my previous post for PHP script to print Fibonacci series in PHP.
What is Recursion?
In recursion, A function calls itself until the base condition is reached. Recursive code is much cleaner and shorter as compared to iterative code.
For better understanding you can my previous post on recursion and what’s the difference between recursion and iteration.
For practice, you can solve Objective Question on Recursion
Write a PHP script to Fibonacci series in PHP. In this tutorial, We are going to write a PHP script which prints Fibonacci series from 1 to N, where N is the input integer. We are going to use both iterative and recursive approach to print Fibonacci series.
How to find missing number in array of 1 to n. This question is generally asked in technical interviews. The problem statement is something like that. Given an array of numbers from 1 to 100. The array is sorted. One number is missing from an array. You have to find the missing number from an array. Also there is no duplicates in an array.
Write a c program to count number of nodes in a linked list. In this tutorial, We are going to write a c code to count the number of nodes in a linked list.
What is Linked List?
A linked list is a collection of nodes, each pointing to next node by means of a pointer. In linked list, each node consists of two parts, a data and a pointer to next node.
C Program to Count Number of Nodes in a Linked List
An Algorithm to Count Number of Nodes in a Linked List
i) Take a count variable and initialize it to zero, count = 0.
ii) Traverse a linked list and increment a count variable.
iii) When a node points to a null, it means we reach at end of a linked list then return the value of a count variable.