@jalaj: u are more or less rightactually u check first that
whether the given seq first increases or dec then accordingly call
functionhere u have assumed that seq first increases n then
decreases so first u better check either increases or decreases.bt
overall good buddy..!!!
On 2
char *start is const char *start, pointer to const char, u can't derefernce
it and change it.
take a char start[256].try this.
On Tue, Feb 15, 2011 at 12:31 PM, dinesh bansal wrote:
> Hi All,
>
> Can you please point me to the error in the following function. It gives
> segmentation fault.
>
> i
Hi All,
Can you please point me to the error in the following function. It gives
segmentation fault.
int main()
{
char *start = "12.12.12.12.12976665176069214";
char *hex_buf = "65003a0a";
unsigned short i, j = 0;
int new_len2 = strlen(hex_buf);
for (i = 0; ((j+1) < new_len2);
I simply used arrays to count the frequency of each numberMy
accepted solution is:
#include
int main()
{
int t,n,i,p,x,chk,k;
int pos[1000];
int neg[1000];
int nos[100];
scanf("%d",&t);
while(t--)
{
chk=0;
if we have "RBGGGBGGBR"
what should be the answer???
"RBGR" or ""(empty string)
On Mon, Feb 7, 2011 at 3:51 PM, rajan goswami wrote:
> yeh.
> Agree with ramkumar.
> Simplest solution is to use Stack...
>
>
> On Sun, Feb 6, 2011 at 8:11 PM, Abhijit K Rao wrote:
>
>> I could not get it for recursiv
This problem does not seem to have a O(n) time solution in the general case
because it is a version of the Element uniqueness problem (
http://en.wikipedia.org/wiki/Element_distinctness_problem) which has a
proven tight asymptotic bound of *n log n*.
On Sun, Jan 16, 2011 at 11:17 PM, awesomeandroi
First Question:
Nt sure but shldnt t1 be greater than t2?
Second:
Since, Q is a subset of P.
P intersection Q would be Q itself.
Would be great if you can share some more questions
On Mon, Feb 14, 2011 at 7:52 PM, sankalp srivastava <
richi.sankalp1...@gmail.com> wrote:
> First question
> mode
Hi Ritu,
I was following this problem & I believe I was lost in between. Would you
please let me know what was the original problem?
This is what my understanding is & the code I have written. It is of O(n) time
complexity & constant space complexity. Let me know if I have mistaken anything
yes
On Sun, Feb 13, 2011 at 1:39 AM, Umer Farooq wrote:
> You mean that input/output is on console and that they don't appreciate
> filing?
>
> On Sat, Feb 12, 2011 at 7:51 PM, Wesley Mesquita
> wrote:
>>
>> You should use the standard input/output... simple scanf/printf for C and
>> cin/cout C+
```ONLY HOT VIDEOS FOR YOUTH
HOT VIDEOS
http://sexy-rainsongs.blogspot.com/
FUNNY VIDEOS
http://sexy-rainsongs.blogspot.com/p/funny-video.html
TELUGU FUNNY VIDEOS
http://sexy-rainsongs.blogspot.com/p/telugu-f
5 7 9 17 21 20 19 18
monotonic sequence consists of one increasing and 1 decreasing sequence
so first lets find out pivot position .. can be done with modified binary
search to find out two array
first then applying binary search on both the arrays.. total O(logn) +
O(logn1) +O(logn2) n>n1,n2
in
A few problems with your code :
1)Very Unclear (sorry !):- Either use a camelCase like java or use the
c++ underscores style .Paste ur code on pastebin etc.
2)Too many loops :- It is O(n) , but perhaps O(4000*n) , much worse
than O(n^2) in this case.
3)The problem is based on majority element con
You mean that input/output is on console and that they don't appreciate
filing?
On Sat, Feb 12, 2011 at 7:51 PM, Wesley Mesquita
wrote:
> You should use the standard input/output... simple scanf/printf for C and
> cin/cout C++ do the deal.
>
> I don't know about java.
>
> Regards,
>
> On Wed, Feb
You can also free the memory of q , we don't need it anymore .
but , the code is just fine .
On Feb 13, 5:03 pm, dinesh bansal wrote:
> On Tue, Jan 11, 2011 at 10:14 PM, snehal jain wrote:
> > what is the wrong in the program?
>
> > main()
> > {
> > char *p,*q;
> > p=(char *)malloc(25);
>
> Chec
What is a majority element ?
If you are refering to your previous post , then , use hashing
On Feb 13, 10:12 pm, Akshata Sharma wrote:
> oops... ignore the post :-/
>
> On Feb 13, 10:07 pm, Akshata Sharma wrote:
>
>
>
> > Given an element and an array, how will you find whether the element
> > i
Just a slight addition , you would also like to keep a record for the
maximum range of the levels (assuming the function is called as
(root , 0))
On Feb 14, 5:25 pm, jalaj jaiswal wrote:
> use hash
>
> take an array verticalsum[]={0};
>
> the function will be like this
> void vertcal_sum(node *r
Try scanf/printf instead of cin/cout.
For huge data set, the IO time matters.
On 2011-2-14 20:09, Akshata Sharma wrote:
link to problem: http://www.spoj.pl/problems/MAJOR/
On Feb 14, 5:03 pm, Akshata Sharma wrote:
I am trying to submit my solution but its giving TLE. My implemetation is
O(n).
First question
mode switch time < context switch time .
t1 we have embed tag
refresh -> we have meta tag
automatically redirect --> again meta tag
Display client time -- > javascript or ajax (Alert(some function ))
Third :-
It uses DP , also in a bottom up fashion .
--
You received this messa
@ sanchit
m dong inorder traversal and at every step chking whether the node's p
pointer is pointing to its inorder predecesor, which is temp or not and
making it NULL otherwise. when count is 0 the node do not hv any predecessor
so m directly pointing that to NULL.
*please see the below alg0 , th
explain algo instead of writing the code.
thanx
On Mon, Feb 14, 2011 at 9:28 PM, jalaj jaiswal wrote:
> @tushar that would modify the tree structure
>
> here is a different approach
>
> int count=0; //global
> void modified_inorder(node *root){
>if(root!=NULL){
> modifie
how will you search an element in a bitonic sequence Time
complexity should be lessthan linear time
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this
@tushar that would modify the tree structure
here is a different approach
int count=0; //global
void modified_inorder(node *root){
if(root!=NULL){
modified_inorder(root->left);
node *temp;
if(count==0){
root->p=NULL;
@tushar thnxx for correction :D
On Mon, Feb 14, 2011 at 7:50 PM, SEHAJ SINGH KALRA wrote:
> HAD MISSED OUT SOPME THINGS IN PREVIOUS REPLY.
> SORRY GUYS
> hereby i rectify the mistakes:
>
>
>
> Claim: any given vertical line will start with a node.(This is obvious)
> Divide this proble
I think the following algo should work:
1. Create a DLL of the inorder traversal of the tree
2. for each node, check whether P of that node points to the previous node
in the DLL or not.
3. If not, assign it value NULL
--
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919
What is meant by :
"preceding P’s node in the in-order
traversal of the tree" ?
On Mon, Feb 14, 2011 at 7:03 PM, bittu wrote:
> You have a tree, in which each node has an additional pointer, P. P
> can either be NULL or point a node preceding P’s node in the in-order
> traversal of the tree. Wr
HAD MISSED OUT SOPME THINGS IN PREVIOUS REPLY.
SORRY GUYS
hereby i rectify the mistakes:
Claim: any given vertical line will start with a node.(This is obvious)
Divide this problem into 2 subparts.
1st: Finding the starting node of given line.
2nd : finding the required sum.
Let T be
Claim: any given vertical line will start with a node.(This is obvious)
Divide this problem into 2 subparts.
1st: Finding the starting node of given line.
2nd : finding the required sum.
Let T be the tree and L be the given level.
For 1st part: Find the leftmost node of the given tree,T.This corr
It would be
*vertcal_sum(root->right,level+1);
*in the last line
--
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com, tushicom...@gmail.com
--
You received this message because you are subscribed to the Google Groups
"Algor
try replacing cin, cout by printf,scanf
On Mon, Feb 14, 2011 at 5:39 PM, Akshata Sharma
wrote:
> link to problem: http://www.spoj.pl/problems/MAJOR/
>
> On Feb 14, 5:03 pm, Akshata Sharma wrote:
> > I am trying to submit my solution but its giving TLE. My implemetation is
> > O(n).. and i am not
You have a tree, in which each node has an additional pointer, P. P
can either be NULL or point a node preceding P’s node in the in-order
traversal of the tree. Write a program to check in a tree if each
node’s P is assigned correctly. If not, make P null
Thanks
Shashank
--
You received this mes
use hash
take an array verticalsum[]={0};
the function will be like this
void vertcal_sum(node *root, int level){
if(root!=NULL){
verticalsum[level]+=root->data;
vertcal_sum(root->left,level-1);
vertcal_sum(root->left,level+1);
}
}
On Mon,
link to problem: http://www.spoj.pl/problems/MAJOR/
On Feb 14, 5:03 pm, Akshata Sharma wrote:
> I am trying to submit my solution but its giving TLE. My implemetation is
> O(n).. and i am not able to think a faster algo than this for the problem.
> The problem is based on finding the majority ele
I am trying to submit my solution but its giving TLE. My implemetation is
O(n).. and i am not able to think a faster algo than this for the problem.
The problem is based on finding the majority element concept. Please help
My code:
#include
#include
using namespace std;
struct res{
string boo;
Given a binary tree with no size limitation, write a program to find
the sum of each vertical level and store the result in an appropriate
data structure (Note: You cannot use an array as the tree can be of
any size).
4
34 matches
Mail list logo