Categories
Uncategorized

Delete an element from a doubly linked list

Delete an element from a doubly linked list.

Categories
Uncategorized

Detect a palindrome

Devise an algorithm for detecting when a string is a palindrome. Ex: A man, a plan, a canal, Panama”.

(Another from: http://www1.cs.columbia.edu/~kns10/interview/)

Example palindromes I got from a quick web search. 

Don’t nod
Dogma: I am God
Never odd or even
Too bad – I hid a boot
Rats live on no evil star
No trace; not one carton
Was it Eliot’s toilet I saw?
Murder for a jar of red rum
May a moody baby doom a yam?
Go hang a salami; I’m a lasagna hog!
Satan, oscillate my metallic sonatas!
A Toyota! Race fast… safe car: a Toyota
Straw? No, too stupid a fad; I put soot on warts
Are we not drawn onward, we few, drawn onward to new era?
Doc Note: I dissent. A fast never prevents a fatness. I diet on cod
No, it never propagates if I set a gap or prevention
Anne, I vote more cars race Rome to Vienna
Sums are not set as a test on Erasmus
Kay, a red nude, peeped under a yak
Some men interpret nine memos
Campus Motto: Bottoms up, Mac
Go deliver a dare, vile dog!
Madam, in Eden I’m Adam
Oozy rat in a sanitary zoo
Ah, Satan sees Natasha
Lisa Bonet ate no basil
Do geese see God?
God saw I was dog
Dennis sinned

Categories
Uncategorized

Algorithm to detect a loop in a linked list

Write an algorithm to detect a loop in a link list

Categories
Uncategorized

Print out a binary tree

Write a function and the node data structure to visit all of the nodes in a binary tree

(Got it from: http://www1.cs.columbia.edu/~kns10/interview/)

Categories
Uncategorized

Detect overflow in addition

Whats the simples way to check if the sum of two unsigned integers has resulted in an overflow.

(Another from http://www1.cs.columbia.edu/~kns10/interview/)

Categories
Uncategorized

Subtract all the characters in S1 from a string S2

Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.

 

(Another problem from http://www1.cs.columbia.edu/~kns10/interview/)

Categories
Uncategorized

Write a simple lexical analyzer

Write a small lexical analyzer – interviewer gave tokens. expressions like “a*b” etc.

( Another from: http://www1.cs.columbia.edu/~kns10/interview/ )

Categories
Uncategorized

Spiral print a 2D array

Write a routine that prints out a 2-D array in spiral order! (another one from http://www1.cs.columbia.edu/~kns10/interview/)

Categories
Uncategorized

Implement uniqe for a sorted array

Write code to extract unique elements from a sorted array. e.g. (1,1,3,3,3,5,5,5,8,8,8,8) -> (1,3,5,9)

Slow ball question but good for practice. (I got it from http://www1.cs.columbia.edu/~kns10/interview/)

Categories
Uncategorized

Count the bits in a 32 bit integer

Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution). (Got this question from http://www1.cs.columbia.edu/~kns10/interview/ )