Strings

TIPS: Algorithms on Strings/Character_Arrays can be dealt with pointers. Taking pointers one at the beginning of the array and one at the end of the array (using length of the array) will be helpful in solving string algorithms.

algorithm to reverse a string in O(n/2) complexity: There are many ways of reversing a string but best possible case should be considered keeping space and time complexities in mind. Psuedocode for O(n/2) complexity…

algorithm to reverse words of a string: This is a bit tricky algorithm and most frequently asked question in interviews. I will now show how to do it in best time complexity [O(2n)]….

algorithm to find first unrepeated character in a string: We can do it in two different ways; Algorithm with O(2n) time complexity and O(1) space complexity; Algorithm with O(2n) time complexity and O(n) space complexity

algorithm to find substring in a string (KMP Algorithm): Knuth-Morris-Pratt Algorithm (KMP) detailed analysis – Understanding this would show us what a careful algorithmic thinker would code even for a small problem like this. This is one of the algorithms which is easy to implement but one needs lot of attention and hard work to understand the algorithm.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Mawazo

Mostly technology with occasional sprinkling of other random thoughts

amintabar

Amir Amintabar's personal page

101 Books

Reading my way through Time Magazine's 100 Greatest Novels since 1923 (plus Ulysses)

Seek, Plunnge and more...

My words, my world...

ARRM Foundation

Do not wait for leaders; do it alone, person to person - Mother Teresa

Executive Management

An unexamined life is not worth living – Socrates

Diabolical or Smart

Nitwit, Blubber, Oddment, Tweak !!

javaproffesionals

A topnotch WordPress.com site

thehandwritinganalyst

Just another WordPress.com site

coding algorithms

"An approximate answer to the right problem is worth a good deal more than an exact answer to an approximate problem." -- John Tukey