🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2439

Re: Good C Interview questions?

#2439
From: Bill Wendling
Date: Sun, 31 Mar 1996 16:43
66 lines
3274 bytes
Ed.L.Karrels@zippo.com inexplicably wrote:
} I've read a lot of posts in this thread about what _would_ be good
} interview questions.  Well, I have a few that _were_ asked of me when
} I had a telephone interview with SGI a few weeks ago.

} What does it mean when you declare something static?
}   (I supplied answers for file scope, local variables, and inside
}    C++ classes.  Do you guys know of other situations?)

} What does the comma operator do, and what does it return?

} What's the best way to get the size of this structure?

}    struct foo {
}       int a;
}       char b;
}       int c;
}       char d;
}    };

}   (I said, "sizeof(struct foo)".  He chuckled and said, "I can tell you're
}    a C programmer.  A C++ programmer would have just said sizeof(foo)." :-))

}    Pick your favorite architecture.  What would the sizeof(foo) be on it?

A compile error, right?

}   (I picked what we have at school, Sun workstations with gcc.  Should have
}    said SGI's :-))

}    Why isn't the size 2*sizeof(int)+2*sizeof(char)?

Byte alignment?

}    How could you decrease the size of the structure without removing
}    any members?

Rearrange the elements.

} Then some C++ <crap> on which I didn't as well, but you guys wouldn't
} wouldn't want to hear about that...

} Then some data structures stuff, like running time for quick sort, heap
} sort, hash tables, and various operations on singly and double linked
} lists.  Then, he asks, "OK, you've correctly told me that some operations
} are more efficient for doubly linked lists than for singly linked lists,
} but doubly linked lists use the extra memory of a pointer at each node.
} How can we get all the efficiency of a doubly linked list, but use
} only as much memory as a singly linked list, assuming the full significance
} of the pointers is required?

} This one, I heard about once on this newsgroup.  Store the bitwise XOR of the
} addresses of the next and previous nodes in each node.  BTW, is there
} another answer you guys know of?  I have some sample code that implements
} this for any interested parties, email me if you want it.

Could you maybe post it?  What about it, moderator?

[I'd rather see a pointer to it posted, unless it's quite small.  In no
 case would I like to see a URL for this code, and the code, xor'd together
 and posted.  See also Torek's post about it, just recently approved.  -mod]
--
Bill Wendling            bwendlin@fgi.net 
GCS/M/S d s-:+ a? C++++$ UL++>++++ P+++>+++++ L+++>+++++ E--- W-- N++ !o
!K w--- O M-- !V PS+++@ PE- Y !PGP t+++(*) 5-- X- R++ tv--- b+++ DI++++
!D G+ e++>+++++ h(++) !r !y+
Technical Details
Message-ID: <4jmcn5$lq6@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4h2s1m$l8@solutions.solon.com> <4h75c1$4nh@solutions.solon.com> <4jibmd$8b5@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: I_should_put_my_domain_in_etc_NNTP_INEWS_DOMAIN!bwendlin@uunet.uu.net (Bill Wendling)
Newsgroups: comp.lang.c.moderated
Subject: Re: Good C Interview questions?
Date: 31 Mar 1996 10:43:17 -0600
Organization: FGInet, Inc., Springfield, IL
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4jmcn5$lq6@solutions.solon.com>
References: <4h2s1m$l8@solutions.solon.com> <4h75c1$4nh@solutions.solon.com> <4jibmd$8b5@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com
X-Newsreader: TIN [version 1.2 PL2]