How do you apply Binary Search on 2D array supposed you have 2D array with integers sorted both horizontally and vertically. If you find any occurrence of the value you are looking for you return true else false. What is the complexity?
For example the 2D array could look like the following
1 4 5 6
2 5 7 9
Read Answers(11) | 13,031 Views |
How to remove extra bracket from expressions,i.e ((((A+B))*C))?
most optimized answer??
Read Answers(10) | 8,640 Views |
How to find median of a BST?
constraint: without storing it in a linear data structure by inorder traversal?
Read Answers(8) | 7,261 Views |
Given an N x M two dimensional array of integers where all rows and columns are sorted in ascending order, write a function that can determine if a certain value exists in the array.
Read Answers(4) | 5,134 Views |
Create an algorithm that can store 100 business cards and return the information quickly(no external databases), keeping in mind that the company would want to increase the no. of cards later !
Read Answers(3) | 5,626 Views |
Implement a C beautifier program. Following beautifications are needed.a. Tab is replaced by 4 spacesb. After every starting brace ie. {, the next statement will start 4 spaces away from the starting of the line that contains opening brace.Example 1:#include <stdio.h> main() /* Hello there */{ int x = 0;/* This is a comment */while (x< 10) { x ++; } if (x) { x++; } else { y = 0; } } Expected output:#include <stdio.h> main() /* Hello there */{ int x = 0; /* This is a comment */ while(x<10) { x ++; } if(x) { x++; } else { y=0; } }
Read Answers(2) | 2,833 Views |
Given an MxN filled up cross word, write a program to print all the words present in the cross word. Cross word table is given as input in a text file that contains ‘0′ for a shaded square and any other valid alphabet [A-Z] for any other position. Each row is a line of text input. A word has to be at least 2 letters long. The program has to read in the input file, and then print out all the words present. Your program has to print the output in the following format: >i is the row and j is the column from which the word begins.
The input file would contain:
12345678901234567890
100000CONGRESS0000000
2000I0000000U00000L00
3000M0000000PRESIDENT
4000P0000000R00I00G0H
5INDEPENDENCE00X00I0E
6000A0000000M00000S0R
70VICEPRESIDENT000L0E
8000H0000000C00TRIAL0
90E0M0S00000O00000T00
0NINETEEN0FOUR000FIVE
10G0N0N00000R000L0V00
20H0T0A00000TWO0AMEND
30T00STATE000000W0000
400000E000000000S0000
The output should contain:<1,6>:CONGRESS:Across
<1,12>:SUPREMECOURT:Down
<2,4>:IMPEACHMENT:Down
<2,18>:LEGISLATIVE:Down
<3,12>:PRESIDENT:Across
<3,15>:SIX:Down
<3,20>:THERE:Down
<5,1>:INDEPENDENCE:Across
<7,2>:VICEPRESIDENT:Across
<8,15>:TRIAL:Across
<9,2>:EIGHT:Down
<9,6>:SENATE:Down
<10,1>:NINETEEN:Across
<10,10>:FOUR:Across
<10,17>:FIVE:Across
<11,16>:LAWS:Down
<12,12>:TWO:Across
<12,16>:AMEND:Across
<13,5>:STATE:Across
Note: The greyed out numbers are row/column number for reference. They are not part of either input or output. The filename of the input text file should be given as the command line argument to your program. The output should appear on STDOUT. Take care to remove all the debug messages before you submit your program.
Read Answers(5) | 3,577 Views |
Implement a C-formatter program that re-renders multi-line C-style comments as per the following cases.
/* This is a multi-line comment. This is line 1.
* This is line 2. This is line 3 */should be rendered as:
/* * This is a multi-line comment. This is line 1. * This is line 2. * This is line 3 */
The following code segment,
int magic_number = 0; /* This implements a magic numberfor the data structure */
should be rendered as
/*
* This implements a magic number * for the data structure. */int magic_number = 0;
Your code can assume that input will not have opening comment /* within string literals. For example ” this is a /* within a literal “. Your code can also assume that input will not have nested comments.
Post An Answer | 1,286 Views |
How do I write a program to print proper subset of given
string . Eg :input: abc
output:{},{a},{b},{c},{a,b},{a,c},{b,c},
{a,b,c}
Read Answers(6) | 6,582 Views |
How would you write an algorithm to draw a cat?
Read Answers(4) | 6,530 Views |