
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 33676 Articles for Programming

353 Views
A matrix can have one or more than one minimum and maximum values. Also, the size of the matrix can be just one column and multiple rows or thousands of columns and thousands of rows. The row number and column number for the minimum and maximum values in a matrix can be found by using the following syntax −For Maximumwhich(“Matrix_Name”==min(“Matrix_Name”),arr.ind=TRUE)For Minimum>which(“Matrix_Name”==max(“Matrix_Name”),arr.ind=TRUE)Example M1

696 Views
The pairwise maximum refer to the values that are largest between the vectors. For example, if we have a vector that contains 1, 2, 3 and a second vector contains 2, 1, 4 then the pairwise maximum will be 2, 2, 4 because the maximum between 1 and 2 is 2, the maximum between 2 and 1 is 2, and the maximum between 3 and 4 is 4. In R, we can find these maximum values for many vectors using pmax function.Example> x1 y1 pmax(x1, y1) [1] 27 28 65 25 17 21 29 > x2 x2 [1] 7 ... Read More

153 Views
Suppose we have an array of numbers; we have to find a number B which is the divisor of all except for exactly one element in the given array. We have to keep in mind that the GCD of all the elements is not 1.So, if the input is like {8, 16, 4, 24}, then the output will be 8 as this is the divisor of all except 4.To solve this, we will follow these steps −n := size of arrayif n is same as 1, thenreturn(array[0] + 1)prefix := an array of size n, and fill with 0suffix := ... Read More

274 Views
Suppose we have two strings S and T, we have to check whether a string of the same length which is lexicographically bigger than S and smaller than T. We have to return -1 if no such string is available. We have to keep in mind that S = S1S2… Sn is termed to be lexicographically less than T = T1T2… Tn, provided there exists an i, so that S1= T1, S2= T2, … Si – 1= Ti – 1, Si < Ti.So, if the input is like S = "bbb" and T = "ddd", then the output will be ... Read More

150 Views
Suppose we have a set of elements; we have to find which permutation of these elements would result in worst case of Merge Sort? As we know asymptotically, merge sort always consumes O (n log n) time, but some cases need more comparisons and consumes more time. Here we have to find a permutation of input elements that will require higher number of comparisons when sorted implementing a typical Merge Sort algorithm.So, if the input is like [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26] , then the output will be [11, ... Read More

131 Views
Suppose we have a balanced binary search tree and a target sum, we have to define a method that checks whether it is a pair with sum equals to target sum, or not. In this case. We have to keep in mind that the Binary Search Tree is immutable.So, if the input is likethen the output will be (9 + 26 = 35)To solve this, we will follow these steps −Define stacks s1, s2done1 := false, done2 := falseval1 := 0, val2 := 0curr1 := root, curr2 := rootinfinite loop, do −while done1 is false, do −if curr1 is not ... Read More

122 Views
Suppose we have an array A, we have to find a number X such that (A[0] XOR X) + (A[1] XOR X) + … + A[n – 1] XOR X is as minimum as possible.So, if the input is like [3, 4, 5, 6, 7], then the output will be X = 7 , Sum = 10To solve this, we will follow these steps −Define a function search_res() . This will take arr, nelement := arr[0]for i in range 0 to size of arr, doif arr[i] > element, thenelement := arr[i]p := integer of (log of element base 2) + ... Read More

269 Views
Suppose we have two sorted linked lists, we have to make a linked list that consists of largest sum path from start node to end node. The final list may consist of nodes from both input lists.When we are creating the result list, we may switch to the other input list only for the point of intersection (two node with the same value in the lists). We have to solve it using constant amount of extra space.So, if the input is like [6, 8, 35, 95, 115, 125], [5, 8, 17, 37, 95, 105, 125, 135], then the output will ... Read More

1K+ Views
Suppose we have one matrix, we have to convert it to 2d linked list using recursive approach.The list will have the right and down pointer.So, if the input is like102030405060708090then the output will beTo solve this, we will follow these steps −Define a function make_2d_list(), this will take matrix mat, i, j, m, n, if i and j are not in the matrix boundary, then −return nulltemp := create a new node with value mat[i, j]right of temp := make_2d_list(mat, i, j + 1, m, n)down of temp := make_2d_list(mat, i + 1, j, m, n)return tempExampleLet us see the ... Read More

218 Views
Suppose we have one matrix, we have to convert it to 2d linked list using iterative approach. The list will have the right and down pointer.So, if the input is like102030405060708090then the output will beTo solve this, we will follow these steps −real_head := NULLDefine an array head_arr of size: m.for initialize i := 0, when i < m, update (increase i by 1), do −head_arr[i] := NULLfor initialize j := 0, when j < n, update (increase j by 1), do −p := new tree node with value mat[i, j]if real_head is null, then −real_head := pif head_arr[i] is ... Read More