- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1401 Articles for C
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
5K+ Views
We have to print the data of nodes of the linked list at the given index. Unlike array linked list generally don’t have index so we have to traverse the whole linked list and print the data when we reached a particular.Let’s say, list contains the nodes 29, 34, 43, 56 and 88 and the value of indexes are 1, 2 and 4 than the output will be the nodes at these indexes that are 34, 43 and 88.ExampleLinked list: 29->34->43->56->88 Input: 1 2 4 Output: 34 43 88In above representation of Linked List the yellow highlighted nodes are the ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
153 Views
We have to print the k number of nodes of the linked list in reverse order. We have to apply the iterative approach to solve this problem.Iterative method is the one which generally uses loops that are executed till the condition holds value 1 or true.Let’s say, list contains the nodes 29, 34, 43, 56 and 88 and the value of k is 2 than the output will be the alternate nodes till k such as 56 and 88.ExampleLinked List: 29->34->43->56->88 Input: 2 Output: 56 88Since we have to remove last k elements from the list the best way to ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
346 Views
We are given an positive integer n and make a spiral matrix of n x n, with only using O(1) extra space in clockwise directionSpiral matrix is a matrix that works like a spiral which will start from the origin of a circle and rotates in clockwise fashion. So the task is to print the matrix in spiral form using O(1) space starting from 2 → 4 → 6 → 8 → 10 → 12 → 14 → 1 6→ 18.Given below is the example of spiral matrix −ExampleInput: 3 Output: 9 8 7 2 1 6 ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
112 Views
The task is to print the k nodes starting from the end of the linked list using recursive approach.Recursive approach is the one in which the function call itself again and again till the call is being made and hence stores the result.Let’s say, list contains the nodes 29, 34, 43, 56 and 88 and the value of k is 2 than the output will be the last k nodes such as 56 and 88.ExampleLinked List: 29->34->43->56->88 Input: 2 Output: 88 56As specified the recursive approach should be used which will traverse the list from the end keeping track of ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
764 Views
In this problem, program must print the alternates from the given linked list that is leaving one printing other and so on using iterative method.Iterative method is the one which generally uses loops that are executed till the condition holds value 1 or true.Let’s say, list contains the nodes 29, 34, 43, 56 and 88 and than the output will be the alternate nodes such as 29, 43 and 88.ExampleInput: 29->34->43->56->88 Output: 29 43 88The approach is to traverse the entire list till the last node. While, traversing a counter variable can be taken which is incremented to 1 and ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
2K+ Views
The task is to print the matrix of n x n of the diagonal pattern.If n is 3 then to print a matrix in Diagonal pattern is −So the output will be like −ExampleInput: 3 Output: 1 2 4 3 5 7 6 8 9 Input: 4 Output: 1 2 4 7 3 5 8 11 6 9 12 14 10 13 15 16The problem suggests we have to give a number n and generate a matrix of n x n and then we have to traverse the matrix in a diagonal pattern ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
248 Views
The task is to print the reverse of a given linked list by using recursive function. The program must print the reverse but not reverse the list that means the order of the nodes remains the sameHere, the program will move head pointer containing the address of a first node to next node until the NULL is examined which is stored in last node of a list and printing the data of a head node.ExampleInput: 29 34 43 56 Output: 56 43 34 29Firstly, the nodes are inserted into the list and a pointer will start pointing to the nodes ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
305 Views
The task is to print the right nodes of a given binary tree. Firstly user will insert data for creating a binary tree and than print right view of the tree so formed.The above diagram showcase the binary tree created with the nodes 10, 42, 93, 14, 35, 96, 57 and 88 amongst these nodes the one that lies in the right side of a tree are chosen and displayed over the screen. For example, 10, 93, 57 and 88 are the rightmost nodes of a binary tree.ExampleInput : 10 42 93 14 35 96 57 88 Output : 10 ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
139 Views
The program should print the middle level of a binary tree e.g. if there are 4 levels in a binary tree than the program must print the level 2 nodes but the demand here is to calculate the level without finding the height.Perfect binary tree is a tree in which interior nodes must have two children and all leave nodes should be at the same level or depth.Here, Interior nodes 21 and 32 both are having childrenLeaf nodes are 41, 59, 33 and 70 all lies at the same level.Since it is satisfying both the properties it’s a perfect binary ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
154 Views
According to the problem we are given an array of n positive integers, we have to find a pair with maximum AND value from the array.ExampleInput: arr[] = { 4, 8, 12, 16 } Output: pair = 8 12 The maximum and value= 8 Input:arr[] = { 4, 8, 16, 2 } Output: pair = No possible AND The maximum and value = 0For finding Maximum AND value is similar to find out Maximum AND value in an array. Program must find out the pair of elements resulting in obtained AND value. For finding the elements, simply traverse the ... Read More