Sudhir sharma has Published 1149 Articles

Print 2-D co-ordinate points in ascending order followed by their frequencies in C++

sudhir sharma

sudhir sharma

Updated on 03-Feb-2020 10:09:17

192 Views

In this problem, we are given 2 arrays x[] , y[] such that (x, y) gives a cordinate of a point in 2D plane. Our task is to print all points along with their frequencies of occurence.Let’s take an example to understand the problemInput: x[]={0, 1, 1, 0, 0} ; ... Read More

Print 2D matrix in different lines and without curly braces in C/C++

sudhir sharma

sudhir sharma

Updated on 03-Feb-2020 09:58:11

272 Views

Here, we will see the code that will print a 2D matrix in c/c++ programming language without using curly braces.Curly braces are separators in a programming language that are used to define separate code blocks in the program. Without curly braces defining scopes is difficult in c/c++.Let’s see the basic ... Read More

Print a case where the given sorting algorithm fails in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2020 06:50:32

115 Views

In this problem, we are given a sorting algorithm and a number n. Our task is to print an array of n elements that could not be sorted by the algorithm. i.e the algorithm will fail.Algorithmloop i from 1 to n-1    loop j from i to n-1    if ... Read More

Print a closest string that does not contain adjacent duplicates in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2020 06:47:12

142 Views

In this problem, we are given a string. Our task is to print a string that is closest to the current string and does not contain any adjacent duplicate characters.Let’s take an example to understand the problemInput: string = “good” Output: goadIn this example, we found that the elements at ... Read More

Print a given matrix in counter-clockwise spiral form in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2020 06:42:59

898 Views

In this problem, we are given a 2-dimensional matrix. And our task is to print the elements of the matrix in a counter-clockwise spiral from.Counterclockwise Spiral Form − It is a spiral traversal which starts from top-left and the goes in the counter-clockwise direction to first bottom-right-up-left.The counter-clockwise traversal will ... Read More

Print a given matrix in reverse spiral form in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2020 06:38:54

446 Views

In this problem, we are given a 2-dimensional matrix. Our task is to print all the elements of the matrix in reverse spiral form.Let’s take an example to understand the problemInput:    12 23 54 67    76 90 01 51    43 18 49 5    31 91 75 ... Read More

Print a given matrix in zigzag form in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2020 06:36:07

720 Views

In this problem, we are given a 2-dimensional matrix. Our task is to print the zigzag form of the matrix.Let’s take an example to understand the problemInput:    12 99 43    10 82 50    15 75 5 Output: 12 99 43 50 82 10 15 75 5To solve ... Read More

Print a matrix in a spiral form starting from a point in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2020 06:34:01

206 Views

In this problem, we are a 2d matrix and a point P(c, r). Our task is to print all elements of the matrix in a spiral form (anti-clockwise) that starts from a given point P.Let’s take an example to understand our problem, Input: matrix[][] = {{3, 5, 7} } Output:To ... Read More

Print a matrix in alternate manner (left to right then right to left) in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2020 06:31:54

497 Views

In this problem, we are given a 2D array. Our task is to print all the elements of the array starting from the first row, from left to right, then right to left in the next row and again from left to right and so on.Let’s take an example to ... Read More

Print a matrix in Reverse Wave Form in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2020 06:29:07

462 Views

In this problem, we are given a matrix. Our task is to print the matrix in reverse waveform in a single line.This example will make the problem clear, Input:    1 4 6 11    2 5 8 54    7 9 3 43    1 7 4 34 Output: ... Read More

Advertisements