
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 1339 Articles for C

394 Views
Given with number of lines the program must print the symmetric double triangle pattern with least complexity.ExampleInput: 5 Output: X X O X O X X O X O X X O X O X XThe entire problem contains 3 different partitions −Print upper half with n-1 lines for odd n or n-2 lines for even n.Print middle lines, 1 line for odd n or ... Read More

6K+ 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

269 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

462 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

157 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

1K+ 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

3K+ 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

342 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

396 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

235 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