You are not logged in. Please login at to post your questions!



asked 23 Dec '14, 13:03

abeyaar's gravatar image

accept rate: 30%

closed 23 Dec '14, 15:35

The question has been closed for the following reason "The question is answered, right answer was accepted" by abeyaar 23 Dec '14, 15:35

In line 58-
parent.freq1=left_child.freq1+right_child.freq1*(FREQUENT.a[mid]==FREQUENT.a[parent.start]?1:0); parent.freq2=right_child.freq2+left_child.freq2*(FREQUENT.a[mid+1]==FREQUENT.a[parent.end]?1:0);
Dont u think it should be mid+1 in the first line and mid in the second? Like-
parent.freq1=left_child.freq1+right_child.freq1*(FREQUENT.a[mid+1]==FREQUENT.a[parent.start]?1:0); parent.freq2=right_child.freq2+left_child.freq2*(FREQUENT.a[mid]==FREQUENT.a[parent.end]?1:0); You add the right parts frequency only when the first value in right subtree is same as the first value in the parent. Likewise for the other part. Your given code fails here: The correct answer is 5 Do upvote if this helps :) Happy Coding! :)

answered 23 Dec '14, 14:38

shivam1511's gravatar image

accept rate: 22%

edited 23 Dec '14, 14:43

Thanks got AC. :) . Can you look into this??

(23 Dec '14, 15:35) abeyaar1★
Umm u mind accepting my answer? :D
I would really appreciate that!
(23 Dec '14, 20:52) shivam15115★

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 23 Dec '14, 13:03

question was seen: 1,157 times

last updated: 23 Dec '14, 20:53