🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Good C Interview questions?

#2436
From: Ed.L.Karrels
Date: Sat, 30 Mar 1996 04:01
53 lines
2508 bytes
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?

  (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)?

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

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.

--
Ed L. Karrels
karree46@sol.acs.uwosh.edu
http://www.uwosh.edu/students/karree46/
Technical Details
Message-ID: <4jibmd$8b5@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4h2s1m$l8@solutions.solon.com> <4h75c1$4nh@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: Ed.L.Karrels@zippo.com
Newsgroups: comp.lang.c.moderated
Subject: Re: Good C Interview questions?
Date: 29 Mar 1996 22:01:17 -0600
Organization: Zippo
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4jibmd$8b5@solutions.solon.com>
References: <4h2s1m$l8@solutions.solon.com> <4h75c1$4nh@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com