I am looking for some tough interview questions.

# Thread: I am looking for some tough interview questions.

1. Junior Member
Join Date
Dec 1969
Posts
6

## I am looking for some tough interview questions.

I know some of you have been around this forum for a long time and have had to answer some good questions. I am setting up an interview and have quite a few doozies but I am finding it difficult to come up with "interview-type" but "tough" programming questions.<BR><BR>So what are the best of the best you have seen?<BR><BR>Cheers.

2. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: I am looking for some tough interview question

I always ask people <BR>&#039;How do you determine that a program is running correctly?&#039;<BR><BR>The answers can be quite enlightening

3. Senior Member
Join Date
Dec 1969
Posts
16,931

## RE: I am looking for some tough interview question

Out of interest, WK, what do you expect as a "correct" answer?<BR><BR>My initial response was "Does it do what it was meant to?". But running correctly and being well written or being efficient or being written so it&#039;s expandable or manageable in the future etc are completely different things.<BR><BR>Craig.

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## One that got me...

Describe an algorithm for traversing a binary tree.<BR><BR>Implement it in your favorite language.<BR><BR>Now do it again, WITHOUT using recursion.<BR><BR><BR>I did it, but my solution on the spur of the moment was pretty ugly.<BR><BR>**********<BR><BR>Imagine that you are playing a tic-tac-toe kind of game where a win consists of N consecutive "marked" squares on an arbitrarily sized board. Describe an algorithm for determining if a move produced a win or not.<BR><BR>Now assume that the board is N by N squares in size. Provide an optimal algorithm.<BR><BR>[Hint: the NxN solution doesn&#039;t even resemble that arbitrary size solution.]<BR><BR>

5. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: I am looking for some tough interview question

I don&#039;t look upon anything as a right answer!<BR>Actually It&#039;s a way that people can very quickly paint themselves into a corner.<BR><BR>Interesting to see the responses. Your for example shows that you are thinking of how potable your code is

6. Senior Member
Join Date
Dec 1969
Posts
96,118

## Yeah, I've written potable code...

...code that makes *anybody* want to go out and find plenty of potables. Potent ones, even.<BR><BR>

7. Senior Member
Join Date
Dec 1969
Posts
380

## RE: One that got me...

reminds me of a request/compo once that asked to write the smallest (c-64) code to flip bits of a byte without using the eor op-code.<BR><BR>most people used loops like (or not even this small)<BR><BR>ldx #0<BR>stx \$fe<BR>lda #val<BR>sta \$ff<BR>lda \$ff<BR>and bitlookuptable,x<BR>cmp bitlookuptable,x<BR>beq biton<BR>lda #0<BR>beq skip<BR>biton:<BR>lda bitlookuptable,x<BR>skip:<BR>sta \$fe<BR>inx<BR>cpx #8<BR>bpl loop<BR>rts<BR>bitlookuptable .byte 1,2,4,8,16,32,64,128<BR><BR>I did it with<BR><BR>lda #\$ff<BR>sbc #val<BR>rts <BR><BR>=)

8. Senior Member
Join Date
Dec 1969
Posts
96,118

## Well, you just flunked...

...the interview!!!<BR><BR>Since you didn&#039;t specifically set the state of the carry bit *BEFORE* doing SBC, you only have a 50% chance of getting the right answer!<BR><BR>[I wrote 6502 code almost exclusively for 4 years.]<BR><BR>The other code you show, using the table is yuck, though.<BR><BR>Why not simply do<BR> ROR one<BR> ROL two<BR>eight times.<BR><BR><BR>

9. Senior Member
Join Date
Dec 1969
Posts
11,247

## Ahhh you're referencing this

http://www.gotw.ca/publications/mill03.htm

10. Senior Member
Join Date
Dec 1969
Posts
96,118

## Heh! I did that twice...

...wrote articles for April editions of my column that were jokes.<BR><BR>Funniest part was, though, that I got some people to believe them!<BR><BR>Best April Fool article ever, though, was one about how National Semiconductor was creating an infinite capacity memory sytem. A WOM. The article showed a picture of the (suitably touched up) Sunnyvale water tower.<BR><BR>Yes, WOM. Write-Only Memory.<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•