Algorithms And Programming #7

61. What are various problems unique to distributed databases?

62. Declare a void pointer

ANS. void *ptr;

63. Make the pointer aligned to a 4 byte boundary in a efficient manner ANS. Assign the pointer to a long number and the number with 11...1100 add 4 to the number

64. What is a far pointer (in DOS)

65. What is a balanced tree?

66. Given a linked list with the following property node2 is left child of node1,
if node2 < nod1 else, it is the right child.

O P
|
|
O A
|
|
O B
|
|
O C

How do you convert the above linked list to the form without disturbing the property. Write C code for that.


O P
|
|
O B
/ / / O ? O ?

Determine where do A and C go

67. Describe the file system layout in the UNIX OS

ANS. describe boot block, super block, inodes and data layout

68. In UNIX, are the files allocated contiguous blocks of data

ANS. no, they might be fragmented

69.How is the fragmented data kept track of?

ANS. Describe the direct blocks and indirect blocks in UNIX file system

70. Write an efficient C code for 'tr' program. 'tr' has two command line arguments. They both are strings of same length. tr reads an input file, replaces each character in the first string with the corresponding character in the second string. e.g. 'tr abc xyz' replaces all 'a's by 'x's, 'b's by 'y's and so on.

ANS.
a) have an array of length 26.
put 'x' in array element corr to 'a'
put 'y' in array element corr to 'b'
put 'z' in array element corr to 'c'
put 'd' in array element corr to 'd'
put 'e' in array element corr to 'e'
and so on.

The code
while (!eof)
{
c = getc ();
putc (array [c - 'a']);
}



NEXT
BACk

No comments:

Post a Comment