C++ Interview Questions And Answers _ 9

Started by ravindar, Mar 27, 2008, 04:27 PM

Previous topic - Next topic

ravindar

C++ Interview Questions And Answers

C++ programming on UNIX

Could you tell something about the Unix System Kernel?

The kernel is the heart of the UNIX openrating system, it's reponsible for controlling the computer's resouces and scheduling user jobs so that each one gets its fair share of resources.

What are each of the standard files and what are they normally associated with?
They are the standard input file, the standard output file and the standard error file. The first is usually associated with the keyboard, the second and third are usually associated with the terminal screen.

Detemine the code below, tell me exectly how many times is the operation sum++ performed ?
for ( i = 0; i < 100; i++ )
for ( j = 100; j > 100 - i; j–)
sum++;

(99 * 100)/2 = 4950
The sum++ is performed 4950 times.

Give 4 examples which belongs application layer in TCP/IP architecture?

FTP, TELNET, HTTP and TFTP

What's the meaning of ARP in TCP/IP?

The "ARP" stands for Address Resolution Protocol. The ARP standard defines two basic message types: a request and a response. a request message contains an IP address and requests the corresponding hardware address; a replay contains both the IP address, sent in the request, and the hardware address.

What is a Makefile?

Makefile is a utility in Unix to help compile large programs. It helps by only compiling the portion of the program that has been changed.
A Makefile is the file and make uses to determine what rules to apply. make is useful for far more than compiling programs.

What is deadlock?

Deadlock is a situation when two or more processes prevent each other from running. Example: if T1 is holding x and waiting for y to be free and T2 holding y and waiting for x to be free deadlock happens.

What is semaphore?

Semaphore is a special variable, it has two methods: up and down. Semaphore performs atomic operations, which means ones a semaphore is called it can not be inturrupted.

The internal counter (= #ups - #downs) can never be negative. If you execute the "down" method when the internal counter is zero, it will block until some other thread calls the "up" method. Semaphores are use for thread synchronization.

Is C an object-oriented language?

C is not an object-oriented language, but limited object-oriented programming can be done in C.

Name some major differences between C++ and Java.

C++ has pointers; Java does not. Java is platform-independent; C++ is not. Java has garbage collection; C++ does not. Java does have pointers. In fact all variables in Java are pointers. The difference is that Java does not allow you to manipulate the addresses of the pointer

C++ Networking Interview Questions and Answers

What is the difference between Stack and Queue?

Stack is a Last In First Out (LIFO) data structure.
Queue is a First In First Out (FIFO) data structure

Write a fucntion that will reverse a string.

char *strrev(char *s)
{
int i = 0, len = strlen(s);
char *str;
if ((str = (char *)malloc(len+1)) == NULL)
/*cannot allocate memory */
err_num = 2;
return (str);
}
while(len)
str[i++]=s[–len];
str = NULL;
return (str);
}

What is the software Life-Cycle?

The software Life-Cycle are
1) Analysis and specification of the task
2) Design of the algorithms and data structures
3) Implementation (coding)
4) Testing
5) Maintenance and evolution of the system
6) Obsolescence

What is the difference between a Java application and a Java applet?

The difference between a Java application and a Java applet is that a Java application is a program that can be executed using the Java interpeter, and a JAVA applet can be transfered to different networks and executed by using a web browser (transferable to the WWW).

Name 7 layers of the OSI Reference Model?

-Application layer
-Presentation layer
-Session layer
-Transport layer
-Network layer
-Data Link layer
-Physical layer


C++ Algorithm Interview Questions and Answers


What are the advantages and disadvantages of B-star trees over Binary trees?

Answer1
B-star trees have better data structure and are faster in search than Binary trees, but it's harder to write codes for B-start trees.

Answer2
The major difference between B-tree and binary tres is that B-tree is a external data structure and binary tree is a main memory data structure. The computational complexity of binary tree is counted by the number of comparison operations at each node, while the computational complexity of B-tree is determined by the disk I/O, that is, the number of node that will be loaded from disk to main memory. The comparision of the different values in one node is not counted.


Write the psuedo code for the Depth first Search.

dfs(G, v) //OUTLINE
Mark v as "discovered"
For each vertex w such that edge vw is in G:
If w is undiscovered:
dfs(G, w); that is, explore vw, visit w, explore from there as much as possible, and backtrack from w to v. Otherwise:
"Check" vw without visiting w. Mark v as "finished".


Describe one simple rehashing policy.

The simplest rehashing policy is linear probing. Suppose a key K hashes to location i. Suppose other key occupies H. The following function is used to generate alternative locations:
rehash(j) = (j + 1) mod h
where j is the location most recently probed. Initially j = i, the hash code for K. Notice that this version of rehash does not depend on K.

Describe Stacks and name a couple of places where stacks are useful.

A Stack is a linear structure in which insertions and deletions are always made at one end, called the top. This updating policy is called last in, first out (LIFO). It is useful when we need to check some syntex errors, such as missing parentheses.


Suppose a 3-bit sequence number is used in the selective-reject ARQ, what is the maximum number of frames that could be transmitted at a time?

If a 3-bit sequence number is used, then it could distinguish 8 different frames. Since the number of frames that could be transmitted at a time is no greater half the numner of frames that could be distinguished by the sequence number, so at most 4 frames can be transmitted at a time.